From: Hangyu Hua Date: Thu, 16 Nov 2023 07:57:26 +0000 (+0800) Subject: fuse: dax: set fc->dax to NULL in fuse_dax_conn_free() X-Git-Tag: v5.15.144~44 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=45f53ca3065bbf200a99d586f71c49c6f10293ac;p=thirdparty%2Fkernel%2Fstable.git fuse: dax: set fc->dax to NULL in fuse_dax_conn_free() commit 7f8ed28d1401320bcb02dda81b3c23ab2dc5a6d8 upstream. 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 Acked-by: Vivek Goyal Reviewed-by: Jingbo Xu Cc: # v5.10 Signed-off-by: Miklos Szeredi Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/fuse/dax.c b/fs/fuse/dax.c index 281d79f8b3d37..3e7aafe2e9533 100644 --- a/fs/fuse/dax.c +++ b/fs/fuse/dax.c @@ -1227,6 +1227,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; } }