mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: Zhan Xusheng <zhanxusheng1024@gmail.com>, jaegeuk@kernel.org
Cc: chao@kernel.org, lihongbo22@huawei.com, sandeen@redhat.com,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, zhanxusheng@xiaomi.com,
	syzbot+6c000dea1a93b4f5905c@syzkaller.appspotmail.com,
	stable@vger.kernel.org
Subject: Re: [PATCH 2/2] f2fs: free the quota file name that remount drops
Date: Mon, 2 Nov 2026 09:56:41 +0800	[thread overview]
Message-ID: <a096053d-3f01-42aa-a933-50145abb874d@kernel.org> (raw)
In-Reply-To: <20261030072423.197883-2-zhanxusheng1024@gmail.com>

On 10/30/26 15:24, Zhan Xusheng wrote:
> From: Zhan Xusheng <zhanxusheng@xiaomi.com>
> 
> Remounting with an empty journalled quota option such as "usrjquota="
> clears the name, but f2fs_apply_quota_options() overwrites the old
> string without freeing it, so every such remount leaks it.
> 
> Free it after a grace period, as f2fs_show_options() may still be
> reading it.
> 
> Fixes: d18535132523 ("f2fs: separate the options parsing and options checking")

BTW, shouldn't it be:

Fixes: ff11d8701b77 ("f2fs: fix to allow removing qf_name")

Thanks,

> Reported-by: syzbot+6c000dea1a93b4f5905c@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=6c000dea1a93b4f5905c
> Cc: stable@vger.kernel.org
> Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
> ---
> Tested in QEMU with KASAN and kmemleak, remounting with "usrjquota="
> and "usrjquota=f2fs" in a loop while reading /proc/mounts: nothing is
> reported.  A plain kfree() here trips KASAN in f2fs_show_options().
> 
>   fs/f2fs/super.c | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
> index 510df7998c18..d86ab25fbcc5 100644
> --- a/fs/f2fs/super.c
> +++ b/fs/f2fs/super.c
> @@ -1646,7 +1646,7 @@ static void f2fs_apply_quota_options(struct fs_context *fc,
>   	struct f2fs_fs_context *ctx = fc->fs_private;
>   	struct f2fs_sb_info *sbi = F2FS_SB(sb);
>   	bool quota_feature = f2fs_sb_has_quota_ino(sbi);
> -	char *qname;
> +	char *qname, *old;
>   	int i;
>   
>   	if (quota_feature)
> @@ -1662,7 +1662,10 @@ static void f2fs_apply_quota_options(struct fs_context *fc,
>   					GFP_KERNEL | __GFP_NOFAIL);
>   			set_opt(sbi, QUOTA);
>   		}
> -		F2FS_OPTION(sbi).s_qf_names[i] = qname;
> +		old = F2FS_OPTION(sbi).s_qf_names[i];
> +		/* Pairs with READ_ONCE() in f2fs_show_quota_options() */
> +		smp_store_release(&F2FS_OPTION(sbi).s_qf_names[i], qname);
> +		kfree_rcu_mightsleep(old);
>   	}
>   
>   	if (ctx->spec_mask & F2FS_SPEC_jqfmt)


  parent reply	other threads:[~2026-11-02  1:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-30  7:24 [PATCH 1/2] f2fs: fix use-after-free of quota file names on failed remount Zhan Xusheng
2026-10-30  7:24 ` [PATCH 2/2] f2fs: free the quota file name that remount drops Zhan Xusheng
2026-11-02  1:38   ` Chao Yu
2026-11-02  1:56   ` Chao Yu [this message]
2026-11-02  1:34 ` [PATCH 1/2] f2fs: fix use-after-free of quota file names on failed remount Chao Yu

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=a096053d-3f01-42aa-a933-50145abb874d@kernel.org \
    --to=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=lihongbo22@huawei.com \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sandeen@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+6c000dea1a93b4f5905c@syzkaller.appspotmail.com \
    --cc=zhanxusheng1024@gmail.com \
    --cc=zhanxusheng@xiaomi.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

all inboxes | Powered by JetHome®