Skip to contentSkip to conversation

virtiofsd: Fix fuse_reply_create() to determine correct length of buffer

PATCH In review Vivek Goyal 2 participants 2 messages Jul 3, 2019 – Jul 8, 2019 Arm/actions semi architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtiofsd: Fix fuse_reply_create() to determine correct length of buffer

Hi Dave,

Following patch needs to be applied on virtio-fs-dev branch to make it work with latest kernel. Otherwise file creation reply returns error.

Thanks
Vivek

Put conditional express in brackets. Otherwise expression being evaluated becomes (entrysize + sizeof(struct fuse_open_out) + shared) instead and which obviously results in wrong size calculation.

---
 contrib/virtiofsd/fuse_lowlevel.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/virtiofsd/fuse_lowlevel.c +1 -1
Index: qemu/contrib/virtiofsd/fuse_lowlevel.c
===================================================================
@@ -413,7 +413,7 @@ int fuse_reply_create(fuse_req_t req, co
 	ever->version_index = e->version_offset;
 	return send_reply_ok(req, buf,
 			     entrysize + sizeof(struct fuse_open_out) +
-                             shared ? sizeof(struct fuse_entryver_out) : 0);
+                             (shared ? sizeof(struct fuse_entryver_out) : 0));
 }
 
 int fuse_reply_attr(fuse_req_t req, const struct stat *attr,
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · * Vivek Goyal ([email protected]) wrote:

Hi Dave,

Following patch needs to be applied on virtio-fs-dev branch to make it work with latest kernel. Otherwise file creation reply returns error.

Quoted 8 lines

Thanks
Vivek

Put conditional express in brackets. Otherwise expression being evaluated becomes (entrysize + sizeof(struct fuse_open_out) + shared) instead and which obviously results in wrong size calculation.

Ouch, that's a nasty one to find; thanks!

Quoted 9 lines
---
 contrib/virtiofsd/fuse_lowlevel.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: qemu/contrib/virtiofsd/fuse_lowlevel.c
===================================================================

contrib/virtiofsd/fuse_lowlevel.c int fuse_reply_create(fuse_req_t req, co · line 419

Quoted 8 lines
contrib/virtiofsd/fuse_lowlevel.c +1 -1
@@ -413,7 +413,7 @@ int fuse_reply_create(fuse_req_t req, co
 	ever->version_index = e->version_offset;
 	return send_reply_ok(req, buf,
 			     entrysize + sizeof(struct fuse_open_out) +
-                             shared ? sizeof(struct fuse_entryver_out) : 0);
+                             (shared ? sizeof(struct fuse_entryver_out) : 0));
 }
 
 int fuse_reply_attr(fuse_req_t req, const struct stat *attr,

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