dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

Blame 0062-virtiofsd-Parse-flag-FUSE_WRITE_KILL_PRIV.patch

1d442b
From: Vivek Goyal <vgoyal@redhat.com>
1d442b
Date: Mon, 27 Jan 2020 19:01:31 +0000
1d442b
Subject: [PATCH] virtiofsd: Parse flag FUSE_WRITE_KILL_PRIV
1d442b
1d442b
Caller can set FUSE_WRITE_KILL_PRIV in write_flags. Parse it and pass it
1d442b
to the filesystem.
1d442b
1d442b
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
1d442b
Reviewed-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
1d442b
Reviewed-by: Sergio Lopez <slp@redhat.com>
1d442b
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
1d442b
(cherry picked from commit f779bc5265e7e7abb13a03d4bfbc74151afc15c2)
1d442b
---
1d442b
 tools/virtiofsd/fuse_common.h   | 6 +++++-
1d442b
 tools/virtiofsd/fuse_lowlevel.c | 4 +++-
1d442b
 2 files changed, 8 insertions(+), 2 deletions(-)
1d442b
1d442b
diff --git a/tools/virtiofsd/fuse_common.h b/tools/virtiofsd/fuse_common.h
1d442b
index f8f6433743..686c42c0a5 100644
1d442b
--- a/tools/virtiofsd/fuse_common.h
1d442b
+++ b/tools/virtiofsd/fuse_common.h
1d442b
@@ -93,8 +93,12 @@ struct fuse_file_info {
1d442b
      */
1d442b
     unsigned int cache_readdir:1;
1d442b
 
1d442b
+    /* Indicates that suid/sgid bits should be removed upon write */
1d442b
+    unsigned int kill_priv:1;
1d442b
+
1d442b
+
1d442b
     /** Padding.  Reserved for future use*/
1d442b
-    unsigned int padding:25;
1d442b
+    unsigned int padding:24;
1d442b
     unsigned int padding2:32;
1d442b
 
1d442b
     /*
1d442b
diff --git a/tools/virtiofsd/fuse_lowlevel.c b/tools/virtiofsd/fuse_lowlevel.c
1d442b
index 02e1d83038..2d6dc5a680 100644
1d442b
--- a/tools/virtiofsd/fuse_lowlevel.c
1d442b
+++ b/tools/virtiofsd/fuse_lowlevel.c
1d442b
@@ -1142,6 +1142,7 @@ static void do_write(fuse_req_t req, fuse_ino_t nodeid,
1d442b
     memset(&fi, 0, sizeof(fi));
1d442b
     fi.fh = arg->fh;
1d442b
     fi.writepage = (arg->write_flags & FUSE_WRITE_CACHE) != 0;
1d442b
+    fi.kill_priv = !!(arg->write_flags & FUSE_WRITE_KILL_PRIV);
1d442b
 
1d442b
     fi.lock_owner = arg->lock_owner;
1d442b
     fi.flags = arg->flags;
1d442b
@@ -1177,7 +1178,8 @@ static void do_write_buf(fuse_req_t req, fuse_ino_t nodeid,
1d442b
     fi.lock_owner = arg->lock_owner;
1d442b
     fi.flags = arg->flags;
1d442b
     fi.fh = arg->fh;
1d442b
-    fi.writepage = arg->write_flags & FUSE_WRITE_CACHE;
1d442b
+    fi.writepage = !!(arg->write_flags & FUSE_WRITE_CACHE);
1d442b
+    fi.kill_priv = !!(arg->write_flags & FUSE_WRITE_KILL_PRIV);
1d442b
 
1d442b
     if (ibufv->count == 1) {
1d442b
         assert(!(tmpbufv.buf[0].flags & FUSE_BUF_IS_FD));