Skip to contentSkip to conversation

virtiofsd: fix double fuse_mbuf_iter_advance when do_removemapping

PATCH In review Catherine Ho 3 participants 5 messages Dec 5, 2019 Arm/actions semi architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtiofsd: fix double fuse_mbuf_iter_advance when do_removemapping

Commit 8e92b1fc98f7 ("DAX: virtiofsd: make FUSE_REMOVEMAPPING support multiple entries") forgot to remove one fuse_mbuf_iter_advance in do_removemapping.

Without this patch, virtiofsd will report:
[ID: 00000123] do_removemapping: invalid in, expected 1 * 16, has 60 - 60
[ID: 00000123] unique: 232, error: -22 (Invalid argument), outsize: 16

Fixes 8e92b1fc98f7 ("DAX: virtiofsd: make FUSE_REMOVEMAPPING support multiple entries")
Cc Peng Tao <[email protected]>
---
 contrib/virtiofsd/fuse_lowlevel.c | 8 --------
 1 file changed, 8 deletions(-)
contrib/virtiofsd/fuse_lowlevel.c +0 -8
index bde66c72c3..752e7d97b9 100644
@@ -1894,14 +1894,6 @@ static void do_removemapping(fuse_req_t req, fuse_ino_t nodeid,
 		return;
 	}
 
-	one = fuse_mbuf_iter_advance(iter, sizeof(*one));
-	if (!one) {
-		fuse_log(FUSE_LOG_ERR, "do_removemapping: invalid in, expected %d * %ld, has %ld - %ld\n",
-			 arg->count, sizeof(*one), iter->size, iter->pos);
-		fuse_reply_err(req, EINVAL);
-		return;
-	}
-
 	if (req->se->op.removemapping)
 		req->se->op.removemapping(req, req->se, nodeid, arg->count, one);
 	else
Signature · 1 line
2.17.1
#1 lore raw
Quoted 3 lines · Catherine Ho

Commit 8e92b1fc98f7 ("DAX: virtiofsd: make FUSE_REMOVEMAPPING support multiple entries") forgot to remove one fuse_mbuf_iter_advance in do_removemapping.

No, we do need to advance twice. One for fuse_removemapping_in, another for an array of fuse_removemapping_one.

Quoted 5 lines

Without this patch, virtiofsd will report:
[ID: 00000123] do_removemapping: invalid in, expected 1 * 16, has 60 - 60
[ID: 00000123] unique: 232, error: -22 (Invalid argument), outsize: 16

What kernel version are you using? It appears that the remove mapping request does not container a proper fuse_removemapping_one struct.

Quoted 15 lines
Fixes 8e92b1fc98f7 ("DAX: virtiofsd: make FUSE_REMOVEMAPPING support multiple entries")
Cc Peng Tao <[email protected]>
---
  contrib/virtiofsd/fuse_lowlevel.c | 8 --------
  1 file changed, 8 deletions(-)
contrib/virtiofsd/fuse_lowlevel.c +0 -0
index bde66c72c3..752e7d97b9 100644
@@ -1894,14 +1894,6 @@ static void do_removemapping(fuse_req_t req, fuse_ino_t nodeid,
  		return;
  	}
 

contrib/virtiofsd/fuse_lowlevel.c static void do_removemapping(fuse_req_t req, fuse_ino_t nodeid, · line 1898

Quoted 10 lines
contrib/virtiofsd/fuse_lowlevel.c +0 -8
-	one = fuse_mbuf_iter_advance(iter, sizeof(*one));
-	if (!one) {
-		fuse_log(FUSE_LOG_ERR, "do_removemapping: invalid in, expected %d * %ld, has %ld - %ld\n",
-			 arg->count, sizeof(*one), iter->size, iter->pos);
-		fuse_reply_err(req, EINVAL);
-		return;
-	}
-
  	if (req->se->op.removemapping)
  		req->se->op.removemapping(req, req->se, nodeid, arg->count, one);

The patch is wrong itself, as one is not assigned here.

Cheers,
Tao

Signature · 1 line
Into something rich and strange.
#2 lore raw

Hi Peng

Quoted 8 lines · Peng Tao
Quoted 3 lines · Catherine Ho

Commit 8e92b1fc98f7 ("DAX: virtiofsd: make FUSE_REMOVEMAPPING support multiple entries") forgot to remove one fuse_mbuf_iter_advance in do_removemapping.

No, we do need to advance twice. One for fuse_removemapping_in, another for an array of fuse_removemapping_one.

But seems it advances for 3 times. What I mean is the 2nd advance of *one*
is pointless.
Please see [1] [2] [1]https://gitlab.com/virtio-fs/qemu/blob/virtio-fs-dev/contrib/virtiofsd/fuse_lowlevel.c#L1888 [2]https://gitlab.com/virtio-fs/qemu/blob/virtio-fs-dev/contrib/virtiofsd/fuse_lowlevel.c#L1896

Best Regards
Catherine

Quoted 35 lines
Quoted 5 lines

Without this patch, virtiofsd will report:
[ID: 00000123] do_removemapping: invalid in, expected 1 * 16, has 60 - 60
[ID: 00000123] unique: 232, error: -22 (Invalid argument), outsize: 16

What kernel version are you using? It appears that the remove mapping request does not container a proper fuse_removemapping_one struct.

Quoted 15 lines
Fixes 8e92b1fc98f7 ("DAX: virtiofsd: make FUSE_REMOVEMAPPING support multiple entries")
Cc Peng Tao <[email protected]>
---
  contrib/virtiofsd/fuse_lowlevel.c | 8 --------
  1 file changed, 8 deletions(-)
contrib/virtiofsd/fuse_lowlevel.c +0 -0
index bde66c72c3..752e7d97b9 100644
@@ -1894,14 +1894,6 @@ static void do_removemapping(fuse_req_t req, fuse_ino_t nodeid,
              return;
      }
 

contrib/virtiofsd/fuse_lowlevel.c static void do_removemapping(fuse_req_t req, fuse_ino_t nodeid, · line 1898

Quoted 10 lines
contrib/virtiofsd/fuse_lowlevel.c +0 -8
-     one = fuse_mbuf_iter_advance(iter, sizeof(*one));
-     if (!one) {
-             fuse_log(FUSE_LOG_ERR, "do_removemapping: invalid in, expected %d * %ld, has %ld - %ld\n",
-                      arg->count, sizeof(*one), iter->size, iter->pos);
-             fuse_reply_err(req, EINVAL);
-             return;
-     }
-
      if (req->se->op.removemapping)
              req->se->op.removemapping(req, req->se, nodeid, arg->count, one);

The patch is wrong itself, as one is not assigned here.

Reviewed-by
#3 lore raw
Quoted 8 lines · Catherine Ho

Hi Peng

Quoted 5 lines · Peng Tao
Quoted 3 lines · Catherine Ho

Commit 8e92b1fc98f7 ("DAX: virtiofsd: make FUSE_REMOVEMAPPING support multiple entries") forgot to remove one fuse_mbuf_iter_advance in do_removemapping.

Quoted 9 lines
Quoted 3 lines

No, we do need to advance twice. One for fuse_removemapping_in, another for an array of fuse_removemapping_one.

But seems it advances for 3 times. What I mean is the 2nd advance of *one*
is pointless.
Please see [1] [2] [1]https://gitlab.com/virtio-fs/qemu/blob/virtio-fs-dev/contrib/virtiofsd/fuse_lowlevel.c#L1888 [2]https://gitlab.com/virtio-fs/qemu/blob/virtio-fs-dev/contrib/virtiofsd/fuse_lowlevel.c#L1896

oops, that does look like a merge hunk. I don't have it in my local branch. After pulling the latest code I can see it too. And there was a branch reset at some point.

From https://gitlab.com/virtio-fs/qemu
+ 42db960...5a356e6 virtio-fs-dev -> virtiofs/virtio-fs-dev (forced
update)

Now your patch looks good to me. Thanks!

Cheers,
Tao

Quoted 13 lines

Best Regards
Catherine

Quoted 11 lines
Quoted 5 lines

Without this patch, virtiofsd will report:
[ID: 00000123] do_removemapping: invalid in, expected 1 * 16, has 60 - 60
[ID: 00000123] unique: 232, error: -22 (Invalid argument), outsize: 16

What kernel version are you using? It appears that the remove mapping request does not container a proper fuse_removemapping_one struct.

Quoted 3 lines
Fixes 8e92b1fc98f7 ("DAX: virtiofsd: make FUSE_REMOVEMAPPING support multiple entries")
Cc Peng Tao <[email protected]>
Quoted 24 lines
Quoted 24 lines
Quoted 12 lines
---
   contrib/virtiofsd/fuse_lowlevel.c | 8 --------
   1 file changed, 8 deletions(-)
contrib/virtiofsd/fuse_lowlevel.c +0 -0
index bde66c72c3..752e7d97b9 100644
@@ -1894,14 +1894,6 @@ static void do_removemapping(fuse_req_t req, fuse_ino_t nodeid,
               return;
       }
 

contrib/virtiofsd/fuse_lowlevel.c static void do_removemapping(fuse_req_t req, fuse_ino_t nodeid, · line 1898

Quoted 10 lines
contrib/virtiofsd/fuse_lowlevel.c +0 -8
-     one = fuse_mbuf_iter_advance(iter, sizeof(*one));
-     if (!one) {
-             fuse_log(FUSE_LOG_ERR, "do_removemapping: invalid in, expected %d * %ld, has %ld - %ld\n",
-                      arg->count, sizeof(*one), iter->size, iter->pos);
-             fuse_reply_err(req, EINVAL);
-             return;
-     }
-
       if (req->se->op.removemapping)
               req->se->op.removemapping(req, req->se, nodeid, arg->count, one);

The patch is wrong itself, as one is not assigned here.

Signature · 1 line
Into something rich and strange.
#4 lore raw
Quoted 24 lines · * Peng Tao ([email protected]) wrote:
Quoted 8 lines · Catherine Ho

Hi Peng

Quoted 5 lines · Peng Tao
Quoted 3 lines · Catherine Ho

Commit 8e92b1fc98f7 ("DAX: virtiofsd: make FUSE_REMOVEMAPPING support multiple entries") forgot to remove one fuse_mbuf_iter_advance in do_removemapping.

Quoted 9 lines
Quoted 3 lines

No, we do need to advance twice. One for fuse_removemapping_in, another for an array of fuse_removemapping_one.

But seems it advances for 3 times. What I mean is the 2nd advance of *one*
is pointless.
Please see [1] [2] [1]https://gitlab.com/virtio-fs/qemu/blob/virtio-fs-dev/contrib/virtiofsd/fuse_lowlevel.c#L1888 [2]https://gitlab.com/virtio-fs/qemu/blob/virtio-fs-dev/contrib/virtiofsd/fuse_lowlevel.c#L1896

oops, that does look like a merge hunk. I don't have it in my local branch. After pulling the latest code I can see it too. And there was a branch reset at some point.

Quoted 5 lines

From https://gitlab.com/virtio-fs/qemu
+ 42db960...5a356e6 virtio-fs-dev -> virtiofs/virtio-fs-dev (forced
update)

Now your patch looks good to me. Thanks!

That's probably my screwup sometime during a rebase.

Catherine: Thanks; I'll find the right place to merge your fix in.

Dave

Quoted 29 lines

Cheers,
Tao

Quoted 13 lines

Best Regards
Catherine

Quoted 11 lines
Quoted 5 lines

Without this patch, virtiofsd will report:
[ID: 00000123] do_removemapping: invalid in, expected 1 * 16, has 60 - 60
[ID: 00000123] unique: 232, error: -22 (Invalid argument), outsize: 16

What kernel version are you using? It appears that the remove mapping request does not container a proper fuse_removemapping_one struct.

Quoted 3 lines
Fixes 8e92b1fc98f7 ("DAX: virtiofsd: make FUSE_REMOVEMAPPING support multiple entries")
Cc Peng Tao <[email protected]>
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
---
   contrib/virtiofsd/fuse_lowlevel.c | 8 --------
   1 file changed, 8 deletions(-)
contrib/virtiofsd/fuse_lowlevel.c +0 -0
index bde66c72c3..752e7d97b9 100644
@@ -1894,14 +1894,6 @@ static void do_removemapping(fuse_req_t req, fuse_ino_t nodeid,
               return;
       }
 
Quoted 16 lines
Quoted 12 lines
Quoted 12 lines

contrib/virtiofsd/fuse_lowlevel.c static void do_removemapping(fuse_req_t req, fuse_ino_t nodeid, · line 1898

Quoted 10 lines
contrib/virtiofsd/fuse_lowlevel.c +0 -8
-     one = fuse_mbuf_iter_advance(iter, sizeof(*one));
-     if (!one) {
-             fuse_log(FUSE_LOG_ERR, "do_removemapping: invalid in, expected %d * %ld, has %ld - %ld\n",
-                      arg->count, sizeof(*one), iter->size, iter->pos);
-             fuse_reply_err(req, EINVAL);
-             return;
-     }
-
       if (req->se->op.removemapping)
               req->se->op.removemapping(req, req->se, nodeid, arg->count, one);

The patch is wrong itself, as one is not assigned here.

Signature · 1 line
Into something rich and strange.

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK