public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Hangyu Hua <hbh25y@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: vgoyal@redhat.com, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, jefflexu@linux.alibaba.com
Subject: Re: [PATCH] fs: fuse: dax: set fc->dax to NULL in fuse_dax_conn_free()
Date: Fri, 1 Dec 2023 10:42:53 +0800	[thread overview]
Message-ID: <27ad4e0d-ba00-449b-84b9-90f3ba7e4232@gmail.com> (raw)
In-Reply-To: <CAJfpegvN5Rzy1_2v3oaf1Rp_LP_t3w6W_-Ozn1ADoCLGSKBk+Q@mail.gmail.com>

On 30/11/2023 18:54, Miklos Szeredi wrote:
> On Thu, 16 Nov 2023 at 08:57, Hangyu Hua <hbh25y@gmail.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@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;
> 
> 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
>>

  reply	other threads:[~2023-12-01  2:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2023-12-01 19:08     ` Vivek Goyal
2023-12-04  9:18       ` Miklos Szeredi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=27ad4e0d-ba00-449b-84b9-90f3ba7e4232@gmail.com \
    --to=hbh25y@gmail.com \
    --cc=jefflexu@linux.alibaba.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=vgoyal@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox