aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorVivek Goyal <vgoyal@redhat.com>2021-06-22 11:08:46 -0400
committerDr. David Alan Gilbert <dgilbert@redhat.com>2021-07-05 10:51:26 +0100
commit061624455fc3e4a19caeba321b284548127d858e (patch)
tree733fbe499dcfe63f1427c5c5c731d4968f7cb37b /tools
parent1d03e5660711c40f79917054328e0dc6bcb879a3 (diff)
downloadqemu-061624455fc3e4a19caeba321b284548127d858e.zip
qemu-061624455fc3e4a19caeba321b284548127d858e.tar.gz
qemu-061624455fc3e4a19caeba321b284548127d858e.tar.bz2
virtiofsd: Fix fuse setxattr() API change issue
With kernel header updates fuse_setxattr_in struct has grown in size. But this new struct size only takes affect if user has opted in for fuse feature FUSE_SETXATTR_EXT otherwise fuse continues to send "fuse_setxattr_in" of older size. Older size is determined by FUSE_COMPAT_SETXATTR_IN_SIZE. Fix this. If we have not opted in for FUSE_SETXATTR_EXT, then expect that we will get fuse_setxattr_in of size FUSE_COMPAT_SETXATTR_IN_SIZE and not sizeof(struct fuse_sexattr_in). Fixes: 278f064e4524 ("Update Linux headers to 5.13-rc4") Signed-off-by: Vivek Goyal <vgoyal@redhat.com> Message-Id: <20210622150852.1507204-2-vgoyal@redhat.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Reviewed-by: Greg Kurz <groug@kaod.org> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/virtiofsd/fuse_common.h5
-rw-r--r--tools/virtiofsd/fuse_lowlevel.c7
2 files changed, 11 insertions, 1 deletions
diff --git a/tools/virtiofsd/fuse_common.h b/tools/virtiofsd/fuse_common.h
index fa96718..0c2665b 100644
--- a/tools/virtiofsd/fuse_common.h
+++ b/tools/virtiofsd/fuse_common.h
@@ -373,6 +373,11 @@ struct fuse_file_info {
#define FUSE_CAP_HANDLE_KILLPRIV_V2 (1 << 28)
/**
+ * Indicates that file server supports extended struct fuse_setxattr_in
+ */
+#define FUSE_CAP_SETXATTR_EXT (1 << 29)
+
+/**
* Ioctl flags
*
* FUSE_IOCTL_COMPAT: 32bit compat ioctl on 64bit machine
diff --git a/tools/virtiofsd/fuse_lowlevel.c b/tools/virtiofsd/fuse_lowlevel.c
index 3d725bc..2028677 100644
--- a/tools/virtiofsd/fuse_lowlevel.c
+++ b/tools/virtiofsd/fuse_lowlevel.c
@@ -1425,8 +1425,13 @@ static void do_setxattr(fuse_req_t req, fuse_ino_t nodeid,
struct fuse_setxattr_in *arg;
const char *name;
const char *value;
+ bool setxattr_ext = req->se->conn.want & FUSE_CAP_SETXATTR_EXT;
- arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
+ if (setxattr_ext) {
+ arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
+ } else {
+ arg = fuse_mbuf_iter_advance(iter, FUSE_COMPAT_SETXATTR_IN_SIZE);
+ }
name = fuse_mbuf_iter_advance_str(iter);
if (!arg || !name) {
fuse_reply_err(req, EINVAL);