linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs: fuse: dax: set fc->dax to NULL in fuse_dax_conn_free()
@ 2023-11-16  7:57 Hangyu Hua
  2023-11-16  8:52 ` Jingbo Xu
  2023-11-30 10:54 ` Miklos Szeredi
  0 siblings, 2 replies; 6+ messages in thread
From: Hangyu Hua @ 2023-11-16  7:57 UTC (permalink / raw)
  To: miklos, vgoyal; +Cc: linux-fsdevel, linux-kernel, Hangyu Hua

fuse_dax_conn_free() will be called when fuse_fill_super_common() fails
after fuse_dax_conn_alloc(). Then deactivate_locked_super() in
virtio_fs_get_tree() will call virtio_kill_sb() to release the discarded
superblock. This will call fuse_dax_conn_free() again in fuse_conn_put(),
resulting in a possible double free.

Fixes: 1dd539577c42 ("virtiofs: add a mount option to enable dax")
Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
---
 fs/fuse/dax.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/fuse/dax.c b/fs/fuse/dax.c
index 23904a6a9a96..12ef91d170bb 100644
--- a/fs/fuse/dax.c
+++ b/fs/fuse/dax.c
@@ -1222,6 +1222,7 @@ void fuse_dax_conn_free(struct fuse_conn *fc)
 	if (fc->dax) {
 		fuse_free_dax_mem_ranges(&fc->dax->free_ranges);
 		kfree(fc->dax);
+		fc->dax = NULL;
 	}
 }
 
-- 
2.34.1


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

end of thread, other threads:[~2023-12-04  9:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-16  7:57 [PATCH] fs: fuse: dax: set fc->dax to NULL in fuse_dax_conn_free() Hangyu Hua
2023-11-16  8:52 ` Jingbo Xu
2023-11-30 10:54 ` Miklos Szeredi
2023-12-01  2:42   ` Hangyu Hua
2023-12-01 19:08     ` Vivek Goyal
2023-12-04  9:18       ` Miklos Szeredi

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).