From: "Zhou, Yun" <yun.zhou@windriver.com>
To: Jan Kara <jack@suse.cz>
Cc: tytso@mit.edu, adilger.kernel@dilger.ca,
libaokun@linux.alibaba.com, ojaswin@linux.ibm.com,
ritesh.list@gmail.com, yi.zhang@huawei.com, ebiggers@google.com,
linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] ext4: validate EA inode i_nlink in ext4_xattr_inode_iget
Date: Thu, 18 Jun 2026 09:02:10 +0800 [thread overview]
Message-ID: <ee05e46d-6ec8-4291-a61e-213812934da3@windriver.com> (raw)
In-Reply-To: <xzd6pbxhxxwf3ngj5v5pz2ilhykh7vsegohe6iwfkfytfuuv4o@5obqeoc5wocr>
On 6/18/26 04:25, Jan Kara wrote:
> On Mon 15-06-26 13:35:12, Yun Zhou wrote:
>
> --- a/fs/ext4/xattr.c
> +++ b/fs/ext4/xattr.c
> @@ -464,6 +464,33 @@ static int ext4_xattr_inode_iget(struct inode *parent, unsigned long ea_ino,
> inode_unlock(inode);
> }
>
> + /*
> + * Since this function resolves references from active xattr entries,
> + * the EA inode must be in active state (i_nlink=1, ref_count>0).
> + * i_nlink > 1, i_nlink == 0 (dangling reference), or ref_count == 0
> + * (inconsistent with an active entry) all indicate corruption or
> + * a concurrent last-reference drop.
> + */
> + if (inode->i_nlink != 1 || !ext4_xattr_inode_get_ref(inode)) {
> + ext4_error(parent->i_sb,
> + "EA inode %lu has unexpected i_nlink=%u ref_count=%llu",
> + ea_ino, inode->i_nlink,
> + ext4_xattr_inode_get_ref(inode));
> Hum, given motivation of this is syzbot corrupted fs image, I'd just put
> check in ext4_iget() verifying ext4_xattr_inode_get_ref() is > 0 and be
> done with it. Much simpler and catches at least the obvious cases. The
> consistency of xattr refcount and i_nlink is otherwise guarded by
> ext4_xattr_inode_update_ref() and it can never be perfect as in the kernel
> we don't have the full view of the filesystem and so cannot ascertain that
> xattr ref count matches reality...
>
Thanks very much for your review and suggestions, The issue should be easily
fixed after "introduce ext4_put_ea_inode() for safe deferred iput"
merged. Just
need to defer iput() and no longer to make inode bad.
next prev parent reply other threads:[~2026-06-18 1:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-15 5:35 [PATCH v4] ext4: validate EA inode i_nlink in ext4_xattr_inode_iget Yun Zhou
2026-06-17 20:25 ` Jan Kara
2026-06-18 1:02 ` Zhou, Yun [this message]
2026-06-18 7:21 ` Jan Kara
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=ee05e46d-6ec8-4291-a61e-213812934da3@windriver.com \
--to=yun.zhou@windriver.com \
--cc=adilger.kernel@dilger.ca \
--cc=ebiggers@google.com \
--cc=jack@suse.cz \
--cc=libaokun@linux.alibaba.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ojaswin@linux.ibm.com \
--cc=ritesh.list@gmail.com \
--cc=tytso@mit.edu \
--cc=yi.zhang@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