From: Chao Yu <chao@kernel.org>
To: Taerang Kim <kth5965@gmail.com>, jaegeuk@kernel.org
Cc: chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org,
syzbot+fc026e87558558f75c00@syzkaller.appspotmail.com
Subject: Re: [PATCH v2] f2fs: evict: truncate page cache before clear_inode
Date: Mon, 9 Mar 2026 15:44:34 +0800 [thread overview]
Message-ID: <9df7bc57-f0e1-4c7b-9ce1-0017eab62c2a@kernel.org> (raw)
In-Reply-To: <20260224165408.450957-1-kth5965@gmail.com>
On 2/25/26 00:54, Taerang Kim wrote:
> syzbot reports a BUG_ON(inode->i_data.nrpages) in clear_inode() when
> mounting a corrupted f2fs image.
>
> I agree with Dmitry's RFC that dropping page #0 in f2fs_truncate()
> can address this reproducer, since f2fs_convert_inline_inode() may
> grab page #0 via f2fs_grab_cache_folio() and leave it cached on the
> clear_out success path.
I suspect that we may miss some corner cases in f2fs_evict_inode() ->
f2fs_truncate(), can we figure out the root cause of this issue first
rather than just truncating all page cache before clear_inode()?
Otherwise, current fix may cover potential bug.
Thanks,
>
> However, clear_inode() requires the inode mapping to be empty, and it is
> hard to guarantee that the page cache can only be populated from this
> truncate/inline-conversion path. Make f2fs_evict_inode() defensively
> truncate any remaining page cache before calling clear_inode(), so
> nrpages is guaranteed to be 0 regardless of how the cache was populated.
>
> Link: https://lore.kernel.org/linux-f2fs-devel/20260206092958.578191-1-dmantipov@yandex.ru/
> Reported-by: syzbot+fc026e87558558f75c00@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=fc026e87558558f75c00
> Signed-off-by: Taerang Kim <kth5965@gmail.com>
> ---
> v2: rebase onto torvalds/master (fsverity_cleanup_inode() not present);
> fix patch context, no functional change.
>
> fs/f2fs/inode.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c
> index e0f850b3f0c3..e7942e6e312c 100644
> --- a/fs/f2fs/inode.c
> +++ b/fs/f2fs/inode.c
> @@ -1006,6 +1006,13 @@ void f2fs_evict_inode(struct inode *inode)
> }
> out_clear:
> fscrypt_put_encryption_info(inode);
> + /*
> + * Defensively truncate any remaining page cache, e.g.
> + * f2fs_convert_inline_inode() called from f2fs_truncate()
> + * may leave page #0 behind in the page cache when the
> + * inline conversion takes the clear_out success path.
> + */
> + truncate_inode_pages_final(&inode->i_data);
> clear_inode(inode);
> }
>
next prev parent reply other threads:[~2026-03-09 7:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-24 16:06 [PATCH] " Taerang Kim
2026-02-24 16:54 ` [PATCH v2] " Taerang Kim
2026-03-09 7:44 ` Chao Yu [this message]
2026-03-09 14:25 ` [f2fs-dev] " kth5965
2026-03-13 7:45 ` Chao Yu
2026-03-17 15:28 ` kth5965
2026-03-18 3:40 ` Chao Yu
2026-03-19 15:11 ` kth5965
2026-03-23 3:14 ` Chao Yu
2026-03-31 15:24 ` kth5965
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=9df7bc57-f0e1-4c7b-9ce1-0017eab62c2a@kernel.org \
--to=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=kth5965@gmail.com \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+fc026e87558558f75c00@syzkaller.appspotmail.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®