From: Guikun Yang <yangguikun19@qq.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Chao Yu <chao@kernel.org>,
linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org
Subject: f2fs: a same-name dirent whose target inode has no NAT entry hits WARN_ON(1) in recover_dentry() at mount - kernel panic with panic_on_warn
Date: Fri, 20 Nov 2026 22:00:00 +0800 [thread overview]
Message-ID: <tencent_BB8EEFED1178A776D3B5A8151FED28F55407@qq.com> (raw)
In-Reply-To: <f2fs-recover-dentry-warn-20261120@qq.com>
(Resending to the list: my previous mail used a nonexistent
list address linux-f2fs-devel@lists.linux.dev and was rejected;
the correct address from MAINTAINERS is lists.sourceforge.net.
The report below is unchanged.)
Hi Jaegeuk, Chao,
Mounting a crafted f2fs image with fsync data to recover ends in a
WARN_ON(1) during mount-time recovery, before any syscall beyond
mount(); with panic_on_warn the box panics at boot.
F2FS-fs (vda): f2fs_recover_fsync_data: recovery fsync data, check_only: 0
F2FS-fs (vda): recover_dentry: inode with [ino:xxx] has invalid encrypted name
------------[ cut here ]------------
WARNING: fs/f2fs/recovery.c:223 at f2fs_recover_fsync_data+...
Kernel panic - not syncing: kernel: panic_on_warn set ...
## The path
fs/f2fs/recovery.c, recover_dentry():
de = __f2fs_find_entry(dir, &fname, &dentry_blk);
if (de && inode->i_ino == le32_to_cpu(de->ino))
goto out_put;
if (de) {
einode = f2fs_iget_retry(inode->i_sb, le32_to_cpu(de->ino));
if (IS_ERR(einode)) {
WARN_ON(1); /* :223 */
err = PTR_ERR(einode);
if (err == -ENOENT)
err = -EEXIST;
goto out_put;
}
The recovered inode's filename is looked up in the parent directory.
When a same-name dirent exists but points at a different ino whose NAT
entry is missing (blk_addr == NULL_ADDR), f2fs_iget() returns -ENOENT
and the function hits WARN_ON(1). Nothing on the way to the assertion
checks that the dirent target exists: the name lookup and the inode
lookup read two independent on-disk structures, and a corrupted or
fuzzed image can leave them inconsistent.
The mount is enough: no post-mount syscall is needed, the recovery
walk reaches the entry as soon as the last checkpoint carries fsync
data for the crafted dentry.
## Related but distinct reports
This is a third independent spot in the same recovery walk:
- recover_orphan_inode() had f2fs_bug_on(PTR_ERR(inode) == -ENOENT)
for an orphan whose NAT entry is missing; fixed by treating the
missing inode as fs corruption (downgrade to f2fs_err +
SBI_NEED_FSCK) - that fix does not touch recover_dentry().
- do_recover_data() cross-checks ni.ino against the node footer and
hits f2fs_bug_on at recovery.c:698 - reported separately.
Same family: an ino read from one on-disk structure does not resolve
through the NAT, and the recovery code asserts instead of treating it
as corruption.
## Reproducer
A crafted image where the fsync dentry entry to recover names a file
whose dirent in the parent block points at an ino with no NAT entry;
mounting the image reproduces the WARNING (3/3 runs with
panic_on_warn=0, panic at boot with panic_on_warn=1). A control image
identical except that the dirent points at an existing inode mounts
and recovers normally.
The image builder and the run script are available on request.
## Versions
Reproduced on 7.3.0 (self-built, panic_on_warn=1 for the panic
demonstration). The WARN_ON(1) at recovery.c:223 is unchanged in
current mainline. No report found on the syzbot dashboard for
recover_dentry/f2fs_iget_retry, and no list thread found for this
assertion.
## Possible fix direction
Treat the missing dirent target like the orphan case: log f2fs_err,
set SBI_NEED_FSCK, skip the dentry (the recovered inode keeps its
name from the fsync entry) or fall back to -EEXIST handling, instead
of WARN_ON(1).
Thanks,
Guikun Yang
next parent reply other threads:[~2026-11-21 8:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <f2fs-recover-dentry-warn-20261120@qq.com>
2026-11-20 14:00 ` Guikun Yang [this message]
2026-11-20 14:00 Guikun Yang
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=tencent_BB8EEFED1178A776D3B5A8151FED28F55407@qq.com \
--to=yangguikun19@qq.com \
--cc=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/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®