virtiofsd: Fix potential NULL pointer dereference in virtio_send_msg()
PATCH 1/1 virtiofsd: Fix potential NULL pointer dereference in virtio_send_msg()
The 'ch' will be NULL in the following stack:
send_notify_iov()->fuse_send_msg()->virtio_send_msg(), so we should check 'ch' is valid before dereferencing it
--- tools/virtiofsd/fuse_virtio.c | 2 ++ 1 file changed, 2 insertions(+)
tools/virtiofsd/fuse_virtio.c +2 -0
@@ -205,6 +205,8 @@ static void copy_iov(struct iovec *src_iov, int src_count,int virtio_send_msg (struct fuse_session *se,struct fuse_chan *ch,struct iovec *iov,int count) { +assert (ch); +FVRequest *req =container_of (ch, FVRequest, ch);struct fv_QueueInfo *qi = ch->qi;VuDev *dev = &se->virtio_dev->dev;
Signature · 1 line
2.19.1
Quoted 6 lines · * Alex Chen ([email protected]) wrote:
The 'ch' will be NULL in the following stack:
send_notify_iov()->fuse_send_msg()->virtio_send_msg(), so we should check 'ch' is valid before dereferencing itReported-by Euler Robot <[email protected]>Signed-off-by Alex Chen <[email protected]>
Please check, but I don't think we can currently hit this because we never call send_notify_iov - it's currently called by fuse_lowlevel_notify_inval_entry, inval_inode, and fuse_lowlevel_notify_poll -
but I don't think those are called anywhere.
In that case, probably the best fix is to remove those until we put notify back in.
Dave
Quoted 20 lines
--- tools/virtiofsd/fuse_virtio.c | 2 ++ 1 file changed, 2 insertions(+)tools/virtiofsd/fuse_virtio.c +2
-0@@ -205,6 +205,8 @@ static void copy_iov(struct iovec *src_iov, int src_count,int virtio_send_msg (struct fuse_session *se,struct fuse_chan *ch,struct iovec *iov,int count) { +assert (ch); +FVRequest *req =container_of (ch, FVRequest, ch);struct fv_QueueInfo *qi = ch->qi;VuDev *dev = &se->virtio_dev->dev;Signature · 1 line
2.19.1
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Hi Dave,
Quoted 5 lines · Dr. David Alan Gilbert
Quoted 4 lines · * Alex Chen ([email protected]) wrote:
The 'ch' will be NULL in the following stack:
send_notify_iov()->fuse_send_msg()->virtio_send_msg(), so we should check 'ch' is valid before dereferencing it
Quoted 9 lines
Quoted 2 lines
Reported-by Euler Robot <[email protected]>Signed-off-by Alex Chen <[email protected]>Please check, but I don't think we can currently hit this because we never call
send_notify_iov- it's currently called byfuse_lowlevel_notify_inval_entry,inval_inode, andfuse_lowlevel_notify_poll-
but I don't think those are called anywhere.
Thanks for your review.
The send_notify_iov() is really not being called.
Quoted 3 lines
In that case, probably the best fix is to remove those until we put notify back in.
OK, I will remove those temporarily useless code and send patch v2 to fix this problem.
Thanks,
Alex
Quoted 22 lines
Dave
Quoted 20 lines
--- tools/virtiofsd/fuse_virtio.c | 2 ++ 1 file changed, 2 insertions(+)tools/virtiofsd/fuse_virtio.c +2
-0@@ -205,6 +205,8 @@ static void copy_iov(struct iovec *src_iov, int src_count,int virtio_send_msg (struct fuse_session *se,struct fuse_chan *ch,struct iovec *iov,int count) { +assert (ch); +FVRequest *req =container_of (ch, FVRequest, ch);struct fv_QueueInfo *qi = ch->qi;VuDev *dev = &se->virtio_dev->dev;Signature · 1 line
2.19.1