linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] fuse: virtiofs: Fix nullptr dereference
@ 2020-04-24  6:25 Chirantan Ekbote
  2020-04-24  6:25 ` [PATCH 2/2] fuse: virtiofs: Add basic multiqueue support Chirantan Ekbote
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Chirantan Ekbote @ 2020-04-24  6:25 UTC (permalink / raw)
  To: Miklos Szeredi
  Cc: Vivek Goyal, Stefan Hajnoczi, linux-fsdevel, virtio-fs,
	Dylan Reid, Suleiman Souhlal, Chirantan Ekbote

virtiofs device implementations are allowed to provide more than one
request queue.  In this case `fsvq->fud` would not be initialized,
leading to a nullptr dereference later during driver initialization.

Make sure that `fsvq->fud` is initialized for all request queues even if
the driver doesn't use them.

Signed-off-by: Chirantan Ekbote <chirantan@chromium.org>
---
 fs/fuse/virtio_fs.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/virtio_fs.c b/fs/fuse/virtio_fs.c
index bade747689033..d3c38222a7e4e 100644
--- a/fs/fuse/virtio_fs.c
+++ b/fs/fuse/virtio_fs.c
@@ -1066,10 +1066,13 @@ static int virtio_fs_fill_super(struct super_block *sb)
 	}
 
 	err = -ENOMEM;
-	/* Allocate fuse_dev for hiprio and notification queues */
-	for (i = 0; i < VQ_REQUEST; i++) {
+	/* Allocate fuse_dev for all queues except the first request queue. */
+	for (i = 0; i < fs->nvqs; i++) {
 		struct virtio_fs_vq *fsvq = &fs->vqs[i];
 
+		if (i == VQ_REQUEST)
+			continue;
+
 		fsvq->fud = fuse_dev_alloc();
 		if (!fsvq->fud)
 			goto err_free_fuse_devs;
-- 
2.26.2.303.gf8c07b1a785-goog


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-06-02  9:29 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-24  6:25 [PATCH 1/2] fuse: virtiofs: Fix nullptr dereference Chirantan Ekbote
2020-04-24  6:25 ` [PATCH 2/2] fuse: virtiofs: Add basic multiqueue support Chirantan Ekbote
2020-04-27 15:19   ` Stefan Hajnoczi
2020-04-27 15:22     ` Stefan Hajnoczi
2020-05-01  7:14     ` Chirantan Ekbote
2020-05-01 15:47       ` Stefan Hajnoczi
2020-05-07  8:10         ` Chirantan Ekbote
2020-06-02  9:29           ` Stefan Hajnoczi
2020-04-27 14:38 ` [PATCH 1/2] fuse: virtiofs: Fix nullptr dereference Stefan Hajnoczi
2020-04-27 17:58 ` Vivek Goyal
2020-04-28  8:53   ` Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).