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