linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: "chenxiaosong (A)" <chenxiaosong2@huawei.com>
Cc: viro@zeniv.linux.org.uk, stable@vger.kernel.org,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	dhowells@redhat.com, yukuai3@huawei.com, yi.zhang@huawei.com,
	zhangxiaoxu5@huawei.com
Subject: Re: [PATCH 4.19,v2] VFS: Fix fuseblk memory leak caused by mount concurrency
Date: Wed, 20 Oct 2021 14:30:36 +0200	[thread overview]
Message-ID: <YXAL7K88XGWXckWe@kroah.com> (raw)
In-Reply-To: <860c36c4-3668-1388-66d1-a07d463c2ad9@huawei.com>

On Wed, Oct 13, 2021 at 06:49:06PM +0800, chenxiaosong (A) wrote:
> 在 2021/10/13 18:38, chenxiaosong (A) 写道:
> > 在 2021/10/13 18:11, Greg KH 写道:
> > > On Wed, Oct 13, 2021 at 05:51:01PM +0800, ChenXiaoSong wrote:
> > > > If two processes mount same superblock, memory leak occurs:
> > > > 
> > > > CPU0               |  CPU1
> > > > do_new_mount       |  do_new_mount
> > > >    fs_set_subtype   |    fs_set_subtype
> > > >      kstrdup        |
> > > >                     |      kstrdup
> > > >      memrory leak   |
> > > > 
> > > > Fix this by adding a write lock while calling fs_set_subtype.
> > > > 
> > > > Linus's tree already have refactoring patchset [1], one of them
> > > > can fix this bug:
> > > >          c30da2e981a7 (fuse: convert to use the new mount API)
> > > > 
> > > > Since we did not merge the refactoring patchset in this branch,
> > > > I create this patch.
> > > > 
> > > > [1] https://patchwork.kernel.org/project/linux-fsdevel/patch/20190903113640.7984-3-mszeredi@redhat.com/
> > > > 
> > > > 
> > > > Fixes: 79c0b2df79eb (add filesystem subtype support)
> > > > Cc: David Howells <dhowells@redhat.com>
> > > > Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com>
> > > > ---
> > > > v1: Can not mount sshfs ([PATCH linux-4.19.y] VFS: Fix fuseblk
> > > > memory leak caused by mount concurrency)
> > > > v2: Use write lock while writing superblock
> > > > 
> > > >   fs/namespace.c | 9 ++++++---
> > > >   1 file changed, 6 insertions(+), 3 deletions(-)
> > > 
> > > As you are referring to a fuse-only patch above, why are you trying to
> > > resolve this issue in the core namespace code instead?
> > > 
> > > How does fuse have anything to do with this?
> > > 
> > > confused,
> > > 
> > > greg k-h
> > > .
> > > 
> > 
> > Now, only `fuse_fs_type` and `fuseblk_fs_type` has `FS_HAS_SUBTYPE` flag
> > in kernel code, but maybe there is a filesystem module(`struct
> > file_system_type` has `FS_HAS_SUBTYPE` flag). And only mounting fuseblk
> > filesystem(e.g. ntfs) will occur memory leak now.
> 
> How about updating the subject as: VFS: Fix memory leak caused by mounting
> fs with subtype concurrency?

That would be a better idea, but still, this is not obvious that this is
the correct fix at all...

  reply	other threads:[~2021-10-20 12:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-13  9:51 [PATCH 4.19,v2] VFS: Fix fuseblk memory leak caused by mount concurrency ChenXiaoSong
2021-10-13 10:11 ` Greg KH
2021-10-13 10:38   ` chenxiaosong (A)
2021-10-13 10:49     ` chenxiaosong (A)
2021-10-20 12:30       ` Greg KH [this message]
2021-10-26  2:18         ` chenxiaosong (A)
2021-10-26  5:45           ` Greg KH

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=YXAL7K88XGWXckWe@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=chenxiaosong2@huawei.com \
    --cc=dhowells@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai3@huawei.com \
    --cc=zhangxiaoxu5@huawei.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;
as well as URLs for NNTP newsgroup(s).