[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <27ad4e0d-ba00-449b-84b9-90f3ba7e4232@gmail.com>
Date: Fri, 1 Dec 2023 10:42:53 +0800
From: Hangyu Hua <hbh25y@...il.com>
To: Miklos Szeredi <miklos@...redi.hu>
Cc: vgoyal@...hat.com, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org, jefflexu@...ux.alibaba.com
Subject: Re: [PATCH] fs: fuse: dax: set fc->dax to NULL in
fuse_dax_conn_free()
On 30/11/2023 18:54, Miklos Szeredi wrote:
> On Thu, 16 Nov 2023 at 08:57, Hangyu Hua <hbh25y@...il.com> wrote:
>>
>> 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@...il.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;
>
> Is there a reason not to simply remove the fuse_dax_conn_free() call
> from the cleanup path in fuse_fill_super_common()?
I think setting fc->dax to NULL keeps the memory allocation and release
functions together in fuse_fill_super_common more readable. What do you
think?
Thanks,
Hangyu
>
> Thanks,
> Miklos
>
>
>> }
>> }
>>
>> --
>> 2.34.1
>>
Powered by blists - more mailing lists