cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-virtiofsd-check-input-buffer-size-in-fuse_lowlevel.c.patch

902636
From d6a0067e6c08523a8f605f775be980eaf0a23690 Mon Sep 17 00:00:00 2001
902636
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
902636
Date: Mon, 27 Jan 2020 19:01:23 +0100
902636
Subject: [PATCH 052/116] virtiofsd: check input buffer size in fuse_lowlevel.c
902636
 ops
902636
MIME-Version: 1.0
902636
Content-Type: text/plain; charset=UTF-8
902636
Content-Transfer-Encoding: 8bit
902636
902636
RH-Author: Dr. David Alan Gilbert <dgilbert@redhat.com>
902636
Message-id: <20200127190227.40942-49-dgilbert@redhat.com>
902636
Patchwork-id: 93503
902636
O-Subject: [RHEL-AV-8.2 qemu-kvm PATCH 048/112] virtiofsd: check input buffer size in fuse_lowlevel.c ops
902636
Bugzilla: 1694164
902636
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
902636
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
902636
RH-Acked-by: Sergio Lopez Pascual <slp@redhat.com>
902636
902636
From: Stefan Hajnoczi <stefanha@redhat.com>
902636
902636
Each FUSE operation involves parsing the input buffer.  Currently the
902636
code assumes the input buffer is large enough for the expected
902636
arguments.  This patch uses fuse_mbuf_iter to check the size.
902636
902636
Most operations are simple to convert.  Some are more complicated due to
902636
variable-length inputs or different sizes depending on the protocol
902636
version.
902636
902636
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
902636
Reviewed-by: Sergio Lopez <slp@redhat.com>
902636
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
902636
(cherry picked from commit 70995754416eb4491c31607fe380a83cfd25a087)
902636
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
902636
---
902636
 tools/virtiofsd/fuse_lowlevel.c | 581 +++++++++++++++++++++++++++++++---------
902636
 1 file changed, 456 insertions(+), 125 deletions(-)
902636
902636
diff --git a/tools/virtiofsd/fuse_lowlevel.c b/tools/virtiofsd/fuse_lowlevel.c
902636
index 611e8b0..02e1d83 100644
902636
--- a/tools/virtiofsd/fuse_lowlevel.c
902636
+++ b/tools/virtiofsd/fuse_lowlevel.c
902636
@@ -19,6 +19,7 @@
902636
 #include <assert.h>
902636
 #include <errno.h>
902636
 #include <limits.h>
902636
+#include <stdbool.h>
902636
 #include <stddef.h>
902636
 #include <stdio.h>
902636
 #include <stdlib.h>
902636
@@ -27,7 +28,6 @@
902636
 #include <unistd.h>
902636
 
902636
 
902636
-#define PARAM(inarg) (((char *)(inarg)) + sizeof(*(inarg)))
902636
 #define OFFSET_MAX 0x7fffffffffffffffLL
902636
 
902636
 struct fuse_pollhandle {
902636
@@ -706,9 +706,14 @@ int fuse_reply_lseek(fuse_req_t req, off_t off)
902636
     return send_reply_ok(req, &arg, sizeof(arg));
902636
 }
902636
 
902636
-static void do_lookup(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_lookup(fuse_req_t req, fuse_ino_t nodeid,
902636
+                      struct fuse_mbuf_iter *iter)
902636
 {
902636
-    char *name = (char *)inarg;
902636
+    const char *name = fuse_mbuf_iter_advance_str(iter);
902636
+    if (!name) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
 
902636
     if (req->se->op.lookup) {
902636
         req->se->op.lookup(req, nodeid, name);
902636
@@ -717,9 +722,16 @@ static void do_lookup(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_forget(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_forget(fuse_req_t req, fuse_ino_t nodeid,
902636
+                      struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_forget_in *arg = (struct fuse_forget_in *)inarg;
902636
+    struct fuse_forget_in *arg;
902636
+
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    if (!arg) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
 
902636
     if (req->se->op.forget) {
902636
         req->se->op.forget(req, nodeid, arg->nlookup);
902636
@@ -729,20 +741,48 @@ static void do_forget(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
 }
902636
 
902636
 static void do_batch_forget(fuse_req_t req, fuse_ino_t nodeid,
902636
-                            const void *inarg)
902636
+                            struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_batch_forget_in *arg = (void *)inarg;
902636
-    struct fuse_forget_one *param = (void *)PARAM(arg);
902636
-    unsigned int i;
902636
+    struct fuse_batch_forget_in *arg;
902636
+    struct fuse_forget_data *forgets;
902636
+    size_t scount;
902636
 
902636
     (void)nodeid;
902636
 
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    if (!arg) {
902636
+        fuse_reply_none(req);
902636
+        return;
902636
+    }
902636
+
902636
+    /*
902636
+     * Prevent integer overflow.  The compiler emits the following warning
902636
+     * unless we use the scount local variable:
902636
+     *
902636
+     * error: comparison is always false due to limited range of data type
902636
+     * [-Werror=type-limits]
902636
+     *
902636
+     * This may be true on 64-bit hosts but we need this check for 32-bit
902636
+     * hosts.
902636
+     */
902636
+    scount = arg->count;
902636
+    if (scount > SIZE_MAX / sizeof(forgets[0])) {
902636
+        fuse_reply_none(req);
902636
+        return;
902636
+    }
902636
+
902636
+    forgets = fuse_mbuf_iter_advance(iter, arg->count * sizeof(forgets[0]));
902636
+    if (!forgets) {
902636
+        fuse_reply_none(req);
902636
+        return;
902636
+    }
902636
+
902636
     if (req->se->op.forget_multi) {
902636
-        req->se->op.forget_multi(req, arg->count,
902636
-                                 (struct fuse_forget_data *)param);
902636
+        req->se->op.forget_multi(req, arg->count, forgets);
902636
     } else if (req->se->op.forget) {
902636
+        unsigned int i;
902636
+
902636
         for (i = 0; i < arg->count; i++) {
902636
-            struct fuse_forget_one *forget = &param[i];
902636
             struct fuse_req *dummy_req;
902636
 
902636
             dummy_req = fuse_ll_alloc_req(req->se);
902636
@@ -754,7 +794,7 @@ static void do_batch_forget(fuse_req_t req, fuse_ino_t nodeid,
902636
             dummy_req->ctx = req->ctx;
902636
             dummy_req->ch = NULL;
902636
 
902636
-            req->se->op.forget(dummy_req, forget->nodeid, forget->nlookup);
902636
+            req->se->op.forget(dummy_req, forgets[i].ino, forgets[i].nlookup);
902636
         }
902636
         fuse_reply_none(req);
902636
     } else {
902636
@@ -762,12 +802,19 @@ static void do_batch_forget(fuse_req_t req, fuse_ino_t nodeid,
902636
     }
902636
 }
902636
 
902636
-static void do_getattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_getattr(fuse_req_t req, fuse_ino_t nodeid,
902636
+                       struct fuse_mbuf_iter *iter)
902636
 {
902636
     struct fuse_file_info *fip = NULL;
902636
     struct fuse_file_info fi;
902636
 
902636
-    struct fuse_getattr_in *arg = (struct fuse_getattr_in *)inarg;
902636
+    struct fuse_getattr_in *arg;
902636
+
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    if (!arg) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
 
902636
     if (arg->getattr_flags & FUSE_GETATTR_FH) {
902636
         memset(&fi, 0, sizeof(fi));
902636
@@ -782,14 +829,21 @@ static void do_getattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_setattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_setattr(fuse_req_t req, fuse_ino_t nodeid,
902636
+                       struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_setattr_in *arg = (struct fuse_setattr_in *)inarg;
902636
-
902636
     if (req->se->op.setattr) {
902636
+        struct fuse_setattr_in *arg;
902636
         struct fuse_file_info *fi = NULL;
902636
         struct fuse_file_info fi_store;
902636
         struct stat stbuf;
902636
+
902636
+        arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+        if (!arg) {
902636
+            fuse_reply_err(req, EINVAL);
902636
+            return;
902636
+        }
902636
+
902636
         memset(&stbuf, 0, sizeof(stbuf));
902636
         convert_attr(arg, &stbuf);
902636
         if (arg->valid & FATTR_FH) {
902636
@@ -810,9 +864,16 @@ static void do_setattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_access(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_access(fuse_req_t req, fuse_ino_t nodeid,
902636
+                      struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_access_in *arg = (struct fuse_access_in *)inarg;
902636
+    struct fuse_access_in *arg;
902636
+
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    if (!arg) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
 
902636
     if (req->se->op.access) {
902636
         req->se->op.access(req, nodeid, arg->mask);
902636
@@ -821,9 +882,10 @@ static void do_access(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_readlink(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_readlink(fuse_req_t req, fuse_ino_t nodeid,
902636
+                        struct fuse_mbuf_iter *iter)
902636
 {
902636
-    (void)inarg;
902636
+    (void)iter;
902636
 
902636
     if (req->se->op.readlink) {
902636
         req->se->op.readlink(req, nodeid);
902636
@@ -832,10 +894,18 @@ static void do_readlink(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_mknod(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_mknod(fuse_req_t req, fuse_ino_t nodeid,
902636
+                     struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_mknod_in *arg = (struct fuse_mknod_in *)inarg;
902636
-    char *name = PARAM(arg);
902636
+    struct fuse_mknod_in *arg;
902636
+    const char *name;
902636
+
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    name = fuse_mbuf_iter_advance_str(iter);
902636
+    if (!arg || !name) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
 
902636
     req->ctx.umask = arg->umask;
902636
 
902636
@@ -846,22 +916,37 @@ static void do_mknod(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_mkdir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_mkdir(fuse_req_t req, fuse_ino_t nodeid,
902636
+                     struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_mkdir_in *arg = (struct fuse_mkdir_in *)inarg;
902636
+    struct fuse_mkdir_in *arg;
902636
+    const char *name;
902636
+
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    name = fuse_mbuf_iter_advance_str(iter);
902636
+    if (!arg || !name) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
 
902636
     req->ctx.umask = arg->umask;
902636
 
902636
     if (req->se->op.mkdir) {
902636
-        req->se->op.mkdir(req, nodeid, PARAM(arg), arg->mode);
902636
+        req->se->op.mkdir(req, nodeid, name, arg->mode);
902636
     } else {
902636
         fuse_reply_err(req, ENOSYS);
902636
     }
902636
 }
902636
 
902636
-static void do_unlink(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_unlink(fuse_req_t req, fuse_ino_t nodeid,
902636
+                      struct fuse_mbuf_iter *iter)
902636
 {
902636
-    char *name = (char *)inarg;
902636
+    const char *name = fuse_mbuf_iter_advance_str(iter);
902636
+
902636
+    if (!name) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
 
902636
     if (req->se->op.unlink) {
902636
         req->se->op.unlink(req, nodeid, name);
902636
@@ -870,9 +955,15 @@ static void do_unlink(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_rmdir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_rmdir(fuse_req_t req, fuse_ino_t nodeid,
902636
+                     struct fuse_mbuf_iter *iter)
902636
 {
902636
-    char *name = (char *)inarg;
902636
+    const char *name = fuse_mbuf_iter_advance_str(iter);
902636
+
902636
+    if (!name) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
 
902636
     if (req->se->op.rmdir) {
902636
         req->se->op.rmdir(req, nodeid, name);
902636
@@ -881,10 +972,16 @@ static void do_rmdir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_symlink(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_symlink(fuse_req_t req, fuse_ino_t nodeid,
902636
+                       struct fuse_mbuf_iter *iter)
902636
 {
902636
-    char *name = (char *)inarg;
902636
-    char *linkname = ((char *)inarg) + strlen((char *)inarg) + 1;
902636
+    const char *name = fuse_mbuf_iter_advance_str(iter);
902636
+    const char *linkname = fuse_mbuf_iter_advance_str(iter);
902636
+
902636
+    if (!name || !linkname) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
 
902636
     if (req->se->op.symlink) {
902636
         req->se->op.symlink(req, linkname, nodeid, name);
902636
@@ -893,11 +990,20 @@ static void do_symlink(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_rename(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_rename(fuse_req_t req, fuse_ino_t nodeid,
902636
+                      struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_rename_in *arg = (struct fuse_rename_in *)inarg;
902636
-    char *oldname = PARAM(arg);
902636
-    char *newname = oldname + strlen(oldname) + 1;
902636
+    struct fuse_rename_in *arg;
902636
+    const char *oldname;
902636
+    const char *newname;
902636
+
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    oldname = fuse_mbuf_iter_advance_str(iter);
902636
+    newname = fuse_mbuf_iter_advance_str(iter);
902636
+    if (!arg || !oldname || !newname) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
 
902636
     if (req->se->op.rename) {
902636
         req->se->op.rename(req, nodeid, oldname, arg->newdir, newname, 0);
902636
@@ -906,11 +1012,20 @@ static void do_rename(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_rename2(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_rename2(fuse_req_t req, fuse_ino_t nodeid,
902636
+                       struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_rename2_in *arg = (struct fuse_rename2_in *)inarg;
902636
-    char *oldname = PARAM(arg);
902636
-    char *newname = oldname + strlen(oldname) + 1;
902636
+    struct fuse_rename2_in *arg;
902636
+    const char *oldname;
902636
+    const char *newname;
902636
+
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    oldname = fuse_mbuf_iter_advance_str(iter);
902636
+    newname = fuse_mbuf_iter_advance_str(iter);
902636
+    if (!arg || !oldname || !newname) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
 
902636
     if (req->se->op.rename) {
902636
         req->se->op.rename(req, nodeid, oldname, arg->newdir, newname,
902636
@@ -920,24 +1035,38 @@ static void do_rename2(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_link(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_link(fuse_req_t req, fuse_ino_t nodeid,
902636
+                    struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_link_in *arg = (struct fuse_link_in *)inarg;
902636
+    struct fuse_link_in *arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    const char *name = fuse_mbuf_iter_advance_str(iter);
902636
+
902636
+    if (!arg || !name) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
 
902636
     if (req->se->op.link) {
902636
-        req->se->op.link(req, arg->oldnodeid, nodeid, PARAM(arg));
902636
+        req->se->op.link(req, arg->oldnodeid, nodeid, name);
902636
     } else {
902636
         fuse_reply_err(req, ENOSYS);
902636
     }
902636
 }
902636
 
902636
-static void do_create(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_create(fuse_req_t req, fuse_ino_t nodeid,
902636
+                      struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_create_in *arg = (struct fuse_create_in *)inarg;
902636
-
902636
     if (req->se->op.create) {
902636
+        struct fuse_create_in *arg;
902636
         struct fuse_file_info fi;
902636
-        char *name = PARAM(arg);
902636
+        const char *name;
902636
+
902636
+        arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+        name = fuse_mbuf_iter_advance_str(iter);
902636
+        if (!arg || !name) {
902636
+            fuse_reply_err(req, EINVAL);
902636
+            return;
902636
+        }
902636
 
902636
         memset(&fi, 0, sizeof(fi));
902636
         fi.flags = arg->flags;
902636
@@ -950,11 +1079,18 @@ static void do_create(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_open(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_open(fuse_req_t req, fuse_ino_t nodeid,
902636
+                    struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_open_in *arg = (struct fuse_open_in *)inarg;
902636
+    struct fuse_open_in *arg;
902636
     struct fuse_file_info fi;
902636
 
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    if (!arg) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
+
902636
     memset(&fi, 0, sizeof(fi));
902636
     fi.flags = arg->flags;
902636
 
902636
@@ -965,13 +1101,15 @@ static void do_open(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_read(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_read(fuse_req_t req, fuse_ino_t nodeid,
902636
+                    struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_read_in *arg = (struct fuse_read_in *)inarg;
902636
-
902636
     if (req->se->op.read) {
902636
+        struct fuse_read_in *arg;
902636
         struct fuse_file_info fi;
902636
 
902636
+        arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+
902636
         memset(&fi, 0, sizeof(fi));
902636
         fi.fh = arg->fh;
902636
         fi.lock_owner = arg->lock_owner;
902636
@@ -982,11 +1120,24 @@ static void do_read(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_write(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_write(fuse_req_t req, fuse_ino_t nodeid,
902636
+                     struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_write_in *arg = (struct fuse_write_in *)inarg;
902636
+    struct fuse_write_in *arg;
902636
     struct fuse_file_info fi;
902636
-    char *param;
902636
+    const char *param;
902636
+
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    if (!arg) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
+
902636
+    param = fuse_mbuf_iter_advance(iter, arg->size);
902636
+    if (!param) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
 
902636
     memset(&fi, 0, sizeof(fi));
902636
     fi.fh = arg->fh;
902636
@@ -994,7 +1145,6 @@ static void do_write(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
 
902636
     fi.lock_owner = arg->lock_owner;
902636
     fi.flags = arg->flags;
902636
-    param = PARAM(arg);
902636
 
902636
     if (req->se->op.write) {
902636
         req->se->op.write(req, nodeid, param, arg->size, arg->offset, &fi);
902636
@@ -1052,11 +1202,18 @@ static void do_write_buf(fuse_req_t req, fuse_ino_t nodeid,
902636
     se->op.write_buf(req, nodeid, pbufv, arg->offset, &fi);
902636
 }
902636
 
902636
-static void do_flush(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_flush(fuse_req_t req, fuse_ino_t nodeid,
902636
+                     struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_flush_in *arg = (struct fuse_flush_in *)inarg;
902636
+    struct fuse_flush_in *arg;
902636
     struct fuse_file_info fi;
902636
 
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    if (!arg) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
+
902636
     memset(&fi, 0, sizeof(fi));
902636
     fi.fh = arg->fh;
902636
     fi.flush = 1;
902636
@@ -1069,19 +1226,26 @@ static void do_flush(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_release(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_release(fuse_req_t req, fuse_ino_t nodeid,
902636
+                       struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_release_in *arg = (struct fuse_release_in *)inarg;
902636
+    struct fuse_release_in *arg;
902636
     struct fuse_file_info fi;
902636
 
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    if (!arg) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
+
902636
     memset(&fi, 0, sizeof(fi));
902636
     fi.flags = arg->flags;
902636
     fi.fh = arg->fh;
902636
     fi.flush = (arg->release_flags & FUSE_RELEASE_FLUSH) ? 1 : 0;
902636
     fi.lock_owner = arg->lock_owner;
902636
+
902636
     if (arg->release_flags & FUSE_RELEASE_FLOCK_UNLOCK) {
902636
         fi.flock_release = 1;
902636
-        fi.lock_owner = arg->lock_owner;
902636
     }
902636
 
902636
     if (req->se->op.release) {
902636
@@ -1091,11 +1255,19 @@ static void do_release(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_fsync(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_fsync(fuse_req_t req, fuse_ino_t nodeid,
902636
+                     struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_fsync_in *arg = (struct fuse_fsync_in *)inarg;
902636
+    struct fuse_fsync_in *arg;
902636
     struct fuse_file_info fi;
902636
-    int datasync = arg->fsync_flags & 1;
902636
+    int datasync;
902636
+
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    if (!arg) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
+    datasync = arg->fsync_flags & 1;
902636
 
902636
     memset(&fi, 0, sizeof(fi));
902636
     fi.fh = arg->fh;
902636
@@ -1111,11 +1283,18 @@ static void do_fsync(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_opendir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_opendir(fuse_req_t req, fuse_ino_t nodeid,
902636
+                       struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_open_in *arg = (struct fuse_open_in *)inarg;
902636
+    struct fuse_open_in *arg;
902636
     struct fuse_file_info fi;
902636
 
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    if (!arg) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
+
902636
     memset(&fi, 0, sizeof(fi));
902636
     fi.flags = arg->flags;
902636
 
902636
@@ -1126,11 +1305,18 @@ static void do_opendir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_readdir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_readdir(fuse_req_t req, fuse_ino_t nodeid,
902636
+                       struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_read_in *arg = (struct fuse_read_in *)inarg;
902636
+    struct fuse_read_in *arg;
902636
     struct fuse_file_info fi;
902636
 
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    if (!arg) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
+
902636
     memset(&fi, 0, sizeof(fi));
902636
     fi.fh = arg->fh;
902636
 
902636
@@ -1141,11 +1327,18 @@ static void do_readdir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_readdirplus(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_readdirplus(fuse_req_t req, fuse_ino_t nodeid,
902636
+                           struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_read_in *arg = (struct fuse_read_in *)inarg;
902636
+    struct fuse_read_in *arg;
902636
     struct fuse_file_info fi;
902636
 
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    if (!arg) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
+
902636
     memset(&fi, 0, sizeof(fi));
902636
     fi.fh = arg->fh;
902636
 
902636
@@ -1156,11 +1349,18 @@ static void do_readdirplus(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_releasedir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_releasedir(fuse_req_t req, fuse_ino_t nodeid,
902636
+                          struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_release_in *arg = (struct fuse_release_in *)inarg;
902636
+    struct fuse_release_in *arg;
902636
     struct fuse_file_info fi;
902636
 
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    if (!arg) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
+
902636
     memset(&fi, 0, sizeof(fi));
902636
     fi.flags = arg->flags;
902636
     fi.fh = arg->fh;
902636
@@ -1172,11 +1372,19 @@ static void do_releasedir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_fsyncdir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_fsyncdir(fuse_req_t req, fuse_ino_t nodeid,
902636
+                        struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_fsync_in *arg = (struct fuse_fsync_in *)inarg;
902636
+    struct fuse_fsync_in *arg;
902636
     struct fuse_file_info fi;
902636
-    int datasync = arg->fsync_flags & 1;
902636
+    int datasync;
902636
+
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    if (!arg) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
+    datasync = arg->fsync_flags & 1;
902636
 
902636
     memset(&fi, 0, sizeof(fi));
902636
     fi.fh = arg->fh;
902636
@@ -1188,10 +1396,11 @@ static void do_fsyncdir(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_statfs(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_statfs(fuse_req_t req, fuse_ino_t nodeid,
902636
+                      struct fuse_mbuf_iter *iter)
902636
 {
902636
     (void)nodeid;
902636
-    (void)inarg;
902636
+    (void)iter;
902636
 
902636
     if (req->se->op.statfs) {
902636
         req->se->op.statfs(req, nodeid);
902636
@@ -1204,11 +1413,25 @@ static void do_statfs(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_setxattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_setxattr(fuse_req_t req, fuse_ino_t nodeid,
902636
+                        struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_setxattr_in *arg = (struct fuse_setxattr_in *)inarg;
902636
-    char *name = PARAM(arg);
902636
-    char *value = name + strlen(name) + 1;
902636
+    struct fuse_setxattr_in *arg;
902636
+    const char *name;
902636
+    const char *value;
902636
+
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    name = fuse_mbuf_iter_advance_str(iter);
902636
+    if (!arg || !name) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
+
902636
+    value = fuse_mbuf_iter_advance(iter, arg->size);
902636
+    if (!value) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
 
902636
     if (req->se->op.setxattr) {
902636
         req->se->op.setxattr(req, nodeid, name, value, arg->size, arg->flags);
902636
@@ -1217,20 +1440,36 @@ static void do_setxattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_getxattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_getxattr(fuse_req_t req, fuse_ino_t nodeid,
902636
+                        struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_getxattr_in *arg = (struct fuse_getxattr_in *)inarg;
902636
+    struct fuse_getxattr_in *arg;
902636
+    const char *name;
902636
+
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    name = fuse_mbuf_iter_advance_str(iter);
902636
+    if (!arg || !name) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
 
902636
     if (req->se->op.getxattr) {
902636
-        req->se->op.getxattr(req, nodeid, PARAM(arg), arg->size);
902636
+        req->se->op.getxattr(req, nodeid, name, arg->size);
902636
     } else {
902636
         fuse_reply_err(req, ENOSYS);
902636
     }
902636
 }
902636
 
902636
-static void do_listxattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_listxattr(fuse_req_t req, fuse_ino_t nodeid,
902636
+                         struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_getxattr_in *arg = (struct fuse_getxattr_in *)inarg;
902636
+    struct fuse_getxattr_in *arg;
902636
+
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    if (!arg) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
 
902636
     if (req->se->op.listxattr) {
902636
         req->se->op.listxattr(req, nodeid, arg->size);
902636
@@ -1239,9 +1478,15 @@ static void do_listxattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_removexattr(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_removexattr(fuse_req_t req, fuse_ino_t nodeid,
902636
+                           struct fuse_mbuf_iter *iter)
902636
 {
902636
-    char *name = (char *)inarg;
902636
+    const char *name = fuse_mbuf_iter_advance_str(iter);
902636
+
902636
+    if (!name) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
 
902636
     if (req->se->op.removexattr) {
902636
         req->se->op.removexattr(req, nodeid, name);
902636
@@ -1265,12 +1510,19 @@ static void convert_fuse_file_lock(struct fuse_file_lock *fl,
902636
     flock->l_pid = fl->pid;
902636
 }
902636
 
902636
-static void do_getlk(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_getlk(fuse_req_t req, fuse_ino_t nodeid,
902636
+                     struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_lk_in *arg = (struct fuse_lk_in *)inarg;
902636
+    struct fuse_lk_in *arg;
902636
     struct fuse_file_info fi;
902636
     struct flock flock;
902636
 
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    if (!arg) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
+
902636
     memset(&fi, 0, sizeof(fi));
902636
     fi.fh = arg->fh;
902636
     fi.lock_owner = arg->owner;
902636
@@ -1284,12 +1536,18 @@ static void do_getlk(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
 }
902636
 
902636
 static void do_setlk_common(fuse_req_t req, fuse_ino_t nodeid,
902636
-                            const void *inarg, int sleep)
902636
+                            struct fuse_mbuf_iter *iter, int sleep)
902636
 {
902636
-    struct fuse_lk_in *arg = (struct fuse_lk_in *)inarg;
902636
+    struct fuse_lk_in *arg;
902636
     struct fuse_file_info fi;
902636
     struct flock flock;
902636
 
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    if (!arg) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
+
902636
     memset(&fi, 0, sizeof(fi));
902636
     fi.fh = arg->fh;
902636
     fi.lock_owner = arg->owner;
902636
@@ -1327,14 +1585,16 @@ static void do_setlk_common(fuse_req_t req, fuse_ino_t nodeid,
902636
     }
902636
 }
902636
 
902636
-static void do_setlk(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_setlk(fuse_req_t req, fuse_ino_t nodeid,
902636
+                     struct fuse_mbuf_iter *iter)
902636
 {
902636
-    do_setlk_common(req, nodeid, inarg, 0);
902636
+    do_setlk_common(req, nodeid, iter, 0);
902636
 }
902636
 
902636
-static void do_setlkw(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_setlkw(fuse_req_t req, fuse_ino_t nodeid,
902636
+                      struct fuse_mbuf_iter *iter)
902636
 {
902636
-    do_setlk_common(req, nodeid, inarg, 1);
902636
+    do_setlk_common(req, nodeid, iter, 1);
902636
 }
902636
 
902636
 static int find_interrupted(struct fuse_session *se, struct fuse_req *req)
902636
@@ -1379,12 +1639,20 @@ static int find_interrupted(struct fuse_session *se, struct fuse_req *req)
902636
     return 0;
902636
 }
902636
 
902636
-static void do_interrupt(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_interrupt(fuse_req_t req, fuse_ino_t nodeid,
902636
+                         struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_interrupt_in *arg = (struct fuse_interrupt_in *)inarg;
902636
+    struct fuse_interrupt_in *arg;
902636
     struct fuse_session *se = req->se;
902636
 
902636
     (void)nodeid;
902636
+
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    if (!arg) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
+
902636
     if (se->debug) {
902636
         fuse_log(FUSE_LOG_DEBUG, "INTERRUPT: %llu\n",
902636
                  (unsigned long long)arg->unique);
902636
@@ -1425,9 +1693,15 @@ static struct fuse_req *check_interrupt(struct fuse_session *se,
902636
     }
902636
 }
902636
 
902636
-static void do_bmap(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_bmap(fuse_req_t req, fuse_ino_t nodeid,
902636
+                    struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_bmap_in *arg = (struct fuse_bmap_in *)inarg;
902636
+    struct fuse_bmap_in *arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+
902636
+    if (!arg) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
 
902636
     if (req->se->op.bmap) {
902636
         req->se->op.bmap(req, nodeid, arg->blocksize, arg->block);
902636
@@ -1436,18 +1710,34 @@ static void do_bmap(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_ioctl(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_ioctl(fuse_req_t req, fuse_ino_t nodeid,
902636
+                     struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_ioctl_in *arg = (struct fuse_ioctl_in *)inarg;
902636
-    unsigned int flags = arg->flags;
902636
-    void *in_buf = arg->in_size ? PARAM(arg) : NULL;
902636
+    struct fuse_ioctl_in *arg;
902636
+    unsigned int flags;
902636
+    void *in_buf = NULL;
902636
     struct fuse_file_info fi;
902636
 
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    if (!arg) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
+
902636
+    flags = arg->flags;
902636
     if (flags & FUSE_IOCTL_DIR && !(req->se->conn.want & FUSE_CAP_IOCTL_DIR)) {
902636
         fuse_reply_err(req, ENOTTY);
902636
         return;
902636
     }
902636
 
902636
+    if (arg->in_size) {
902636
+        in_buf = fuse_mbuf_iter_advance(iter, arg->in_size);
902636
+        if (!in_buf) {
902636
+            fuse_reply_err(req, EINVAL);
902636
+            return;
902636
+        }
902636
+    }
902636
+
902636
     memset(&fi, 0, sizeof(fi));
902636
     fi.fh = arg->fh;
902636
 
902636
@@ -1468,11 +1758,18 @@ void fuse_pollhandle_destroy(struct fuse_pollhandle *ph)
902636
     free(ph);
902636
 }
902636
 
902636
-static void do_poll(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_poll(fuse_req_t req, fuse_ino_t nodeid,
902636
+                    struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_poll_in *arg = (struct fuse_poll_in *)inarg;
902636
+    struct fuse_poll_in *arg;
902636
     struct fuse_file_info fi;
902636
 
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    if (!arg) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
+
902636
     memset(&fi, 0, sizeof(fi));
902636
     fi.fh = arg->fh;
902636
     fi.poll_events = arg->events;
902636
@@ -1496,11 +1793,18 @@ static void do_poll(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_fallocate(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_fallocate(fuse_req_t req, fuse_ino_t nodeid,
902636
+                         struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_fallocate_in *arg = (struct fuse_fallocate_in *)inarg;
902636
+    struct fuse_fallocate_in *arg;
902636
     struct fuse_file_info fi;
902636
 
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    if (!arg) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
+
902636
     memset(&fi, 0, sizeof(fi));
902636
     fi.fh = arg->fh;
902636
 
902636
@@ -1513,12 +1817,17 @@ static void do_fallocate(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
 }
902636
 
902636
 static void do_copy_file_range(fuse_req_t req, fuse_ino_t nodeid_in,
902636
-                               const void *inarg)
902636
+                               struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_copy_file_range_in *arg =
902636
-        (struct fuse_copy_file_range_in *)inarg;
902636
+    struct fuse_copy_file_range_in *arg;
902636
     struct fuse_file_info fi_in, fi_out;
902636
 
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    if (!arg) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
+
902636
     memset(&fi_in, 0, sizeof(fi_in));
902636
     fi_in.fh = arg->fh_in;
902636
 
902636
@@ -1535,11 +1844,17 @@ static void do_copy_file_range(fuse_req_t req, fuse_ino_t nodeid_in,
902636
     }
902636
 }
902636
 
902636
-static void do_lseek(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_lseek(fuse_req_t req, fuse_ino_t nodeid,
902636
+                     struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_lseek_in *arg = (struct fuse_lseek_in *)inarg;
902636
+    struct fuse_lseek_in *arg;
902636
     struct fuse_file_info fi;
902636
 
902636
+    arg = fuse_mbuf_iter_advance(iter, sizeof(*arg));
902636
+    if (!arg) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
     memset(&fi, 0, sizeof(fi));
902636
     fi.fh = arg->fh;
902636
 
902636
@@ -1550,15 +1865,33 @@ static void do_lseek(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     }
902636
 }
902636
 
902636
-static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_init(fuse_req_t req, fuse_ino_t nodeid,
902636
+                    struct fuse_mbuf_iter *iter)
902636
 {
902636
-    struct fuse_init_in *arg = (struct fuse_init_in *)inarg;
902636
+    size_t compat_size = offsetof(struct fuse_init_in, max_readahead);
902636
+    struct fuse_init_in *arg;
902636
     struct fuse_init_out outarg;
902636
     struct fuse_session *se = req->se;
902636
     size_t bufsize = se->bufsize;
902636
     size_t outargsize = sizeof(outarg);
902636
 
902636
     (void)nodeid;
902636
+
902636
+    /* First consume the old fields... */
902636
+    arg = fuse_mbuf_iter_advance(iter, compat_size);
902636
+    if (!arg) {
902636
+        fuse_reply_err(req, EINVAL);
902636
+        return;
902636
+    }
902636
+
902636
+    /* ...and now consume the new fields. */
902636
+    if (arg->major == 7 && arg->minor >= 6) {
902636
+        if (!fuse_mbuf_iter_advance(iter, sizeof(*arg) - compat_size)) {
902636
+            fuse_reply_err(req, EINVAL);
902636
+            return;
902636
+        }
902636
+    }
902636
+
902636
     if (se->debug) {
902636
         fuse_log(FUSE_LOG_DEBUG, "INIT: %u.%u\n", arg->major, arg->minor);
902636
         if (arg->major == 7 && arg->minor >= 6) {
902636
@@ -1791,12 +2124,13 @@ static void do_init(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
     send_reply_ok(req, &outarg, outargsize);
902636
 }
902636
 
902636
-static void do_destroy(fuse_req_t req, fuse_ino_t nodeid, const void *inarg)
902636
+static void do_destroy(fuse_req_t req, fuse_ino_t nodeid,
902636
+                       struct fuse_mbuf_iter *iter)
902636
 {
902636
     struct fuse_session *se = req->se;
902636
 
902636
     (void)nodeid;
902636
-    (void)inarg;
902636
+    (void)iter;
902636
 
902636
     se->got_destroy = 1;
902636
     if (se->op.destroy) {
902636
@@ -1976,7 +2310,7 @@ int fuse_req_interrupted(fuse_req_t req)
902636
 }
902636
 
902636
 static struct {
902636
-    void (*func)(fuse_req_t, fuse_ino_t, const void *);
902636
+    void (*func)(fuse_req_t, fuse_ino_t, struct fuse_mbuf_iter *);
902636
     const char *name;
902636
 } fuse_ll_ops[] = {
902636
     [FUSE_LOOKUP] = { do_lookup, "LOOKUP" },
902636
@@ -2060,7 +2394,6 @@ void fuse_session_process_buf_int(struct fuse_session *se,
902636
     const struct fuse_buf *buf = bufv->buf;
902636
     struct fuse_mbuf_iter iter = FUSE_MBUF_ITER_INIT(buf);
902636
     struct fuse_in_header *in;
902636
-    const void *inarg;
902636
     struct fuse_req *req;
902636
     int err;
902636
 
902636
@@ -2138,13 +2471,11 @@ void fuse_session_process_buf_int(struct fuse_session *se,
902636
         }
902636
     }
902636
 
902636
-    inarg = (void *)&in[1];
902636
     if (in->opcode == FUSE_WRITE && se->op.write_buf) {
902636
         do_write_buf(req, in->nodeid, &iter, bufv);
902636
     } else {
902636
-        fuse_ll_ops[in->opcode].func(req, in->nodeid, inarg);
902636
+        fuse_ll_ops[in->opcode].func(req, in->nodeid, &iter);
902636
     }
902636
-
902636
     return;
902636
 
902636
 reply_err:
902636
-- 
902636
1.8.3.1
902636