yeahuh / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-virtiofsd-Parse-flag-FUSE_WRITE_KILL_PRIV.patch

ddf19c
From ade3dcad8a907d281549b341a8908851e36ba458 Mon Sep 17 00:00:00 2001
ddf19c
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
ddf19c
Date: Mon, 27 Jan 2020 19:01:31 +0100
ddf19c
Subject: [PATCH 060/116] virtiofsd: Parse flag FUSE_WRITE_KILL_PRIV
ddf19c
MIME-Version: 1.0
ddf19c
Content-Type: text/plain; charset=UTF-8
ddf19c
Content-Transfer-Encoding: 8bit
ddf19c
ddf19c
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
ddf19c
Message-id: <20200127190227.40942-57-dgilbert@redhat.com>
ddf19c
Patchwork-id: 93505
ddf19c
O-Subject: [RHEL-AV-8.2 qemu-kvm PATCH 056/112] virtiofsd: Parse flag FUSE_WRITE_KILL_PRIV
ddf19c
Bugzilla: 1694164
ddf19c
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
ddf19c
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
ddf19c
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
ddf19c
ddf19c
From: Vivek Goyal <vgoyal@redhat.com>
ddf19c
ddf19c
Caller can set FUSE_WRITE_KILL_PRIV in write_flags. Parse it and pass it
ddf19c
to the filesystem.
ddf19c
ddf19c
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
ddf19c
Reviewed-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
ddf19c
Reviewed-by: Sergio Lopez <slp@redhat.com>
ddf19c
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
ddf19c
(cherry picked from commit f779bc5265e7e7abb13a03d4bfbc74151afc15c2)
ddf19c
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
ddf19c
---
ddf19c
 tools/virtiofsd/fuse_common.h   | 6 +++++-
ddf19c
 tools/virtiofsd/fuse_lowlevel.c | 4 +++-
ddf19c
 2 files changed, 8 insertions(+), 2 deletions(-)
ddf19c
ddf19c
diff --git a/tools/virtiofsd/fuse_common.h b/tools/virtiofsd/fuse_common.h
ddf19c
index f8f6433..686c42c 100644
ddf19c
--- a/tools/virtiofsd/fuse_common.h
ddf19c
+++ b/tools/virtiofsd/fuse_common.h
ddf19c
@@ -93,8 +93,12 @@ struct fuse_file_info {
ddf19c
      */
ddf19c
     unsigned int cache_readdir:1;
ddf19c
 
ddf19c
+    /* Indicates that suid/sgid bits should be removed upon write */
ddf19c
+    unsigned int kill_priv:1;
ddf19c
+
ddf19c
+
ddf19c
     /** Padding.  Reserved for future use*/
ddf19c
-    unsigned int padding:25;
ddf19c
+    unsigned int padding:24;
ddf19c
     unsigned int padding2:32;
ddf19c
 
ddf19c
     /*
ddf19c
diff --git a/tools/virtiofsd/fuse_lowlevel.c b/tools/virtiofsd/fuse_lowlevel.c
ddf19c
index 02e1d83..2d6dc5a 100644
ddf19c
--- a/tools/virtiofsd/fuse_lowlevel.c
ddf19c
+++ b/tools/virtiofsd/fuse_lowlevel.c
ddf19c
@@ -1142,6 +1142,7 @@ static void do_write(fuse_req_t req, fuse_ino_t nodeid,
ddf19c
     memset(&fi, 0, sizeof(fi));
ddf19c
     fi.fh = arg->fh;
ddf19c
     fi.writepage = (arg->write_flags & FUSE_WRITE_CACHE) != 0;
ddf19c
+    fi.kill_priv = !!(arg->write_flags & FUSE_WRITE_KILL_PRIV);
ddf19c
 
ddf19c
     fi.lock_owner = arg->lock_owner;
ddf19c
     fi.flags = arg->flags;
ddf19c
@@ -1177,7 +1178,8 @@ static void do_write_buf(fuse_req_t req, fuse_ino_t nodeid,
ddf19c
     fi.lock_owner = arg->lock_owner;
ddf19c
     fi.flags = arg->flags;
ddf19c
     fi.fh = arg->fh;
ddf19c
-    fi.writepage = arg->write_flags & FUSE_WRITE_CACHE;
ddf19c
+    fi.writepage = !!(arg->write_flags & FUSE_WRITE_CACHE);
ddf19c
+    fi.kill_priv = !!(arg->write_flags & FUSE_WRITE_KILL_PRIV);
ddf19c
 
ddf19c
     if (ibufv->count == 1) {
ddf19c
         assert(!(tmpbufv.buf[0].flags & FUSE_BUF_IS_FD));
ddf19c
-- 
ddf19c
1.8.3.1
ddf19c