From: Baokun Li <libaokun1@huawei.com>
To: Karina Yankevich <k.yankevich@omp.ru>
Cc: Theodore Ts'o <tytso@mit.edu>,
Andreas Dilger <adilger.kernel@dilger.ca>,
Bhupesh <bhupesh@igalia.com>, <linux-ext4@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <lvc-patches@linuxtesting.org>,
Sergey Shtylyov <s.shtylyov@omp.ru>
Subject: Re: [PATCH] ext4: xattr: fix null pointer deref in ext4_raw_inode()
Date: Sat, 8 Nov 2025 11:12:44 +0800 [thread overview]
Message-ID: <0fa6cee3-c25e-4649-8f85-8645cacab00e@huawei.com> (raw)
In-Reply-To: <20251022093253.3546296-1-k.yankevich@omp.ru>
On 2025-10-22 17:32, Karina Yankevich wrote:
> If ext4_get_inode_loc() fails (e.g. if it returns -EFSCORRUPTED),
> iloc.bh will remain set to NULL. Since ext4_xattr_inode_dec_ref_all()
> lacks error checking, this will lead to a null pointer dereference
> in ext4_raw_inode(), called right after ext4_get_inode_loc().
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: c8e008b60492 ("ext4: ignore xattrs past end")
> Signed-off-by: Karina Yankevich <k.yankevich@omp.ru>
> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
An error return at this point may lead to an inconsistent ea_inode
reference count. However, since the caller ext4_xattr_delete_inode()
has already loaded iloc.bh via ext4_get_inode_loc(), this almost never
fails.
Reviewed-by: Baokun Li <libaokun1@huawei.com>
> ---
> fs/ext4/xattr.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
> index ce7253b3f549..2e02efbddaac 100644
> --- a/fs/ext4/xattr.c
> +++ b/fs/ext4/xattr.c
> @@ -1174,7 +1174,11 @@ ext4_xattr_inode_dec_ref_all(handle_t *handle, struct inode *parent,
> if (block_csum)
> end = (void *)bh->b_data + bh->b_size;
> else {
> - ext4_get_inode_loc(parent, &iloc);
> + err = ext4_get_inode_loc(parent, &iloc);
> + if (err) {
> + EXT4_ERROR_INODE(parent, "parent inode loc (error %d)", err);
> + return;
> + }
> end = (void *)ext4_raw_inode(&iloc) + EXT4_SB(parent->i_sb)->s_inode_size;
> }
>
next prev parent reply other threads:[~2025-11-08 3:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-22 9:32 Karina Yankevich
2025-11-05 17:18 ` Markus Elfring
2025-11-08 3:12 ` Baokun Li [this message]
2025-11-17 19:13 ` Theodore Ts'o
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=0fa6cee3-c25e-4649-8f85-8645cacab00e@huawei.com \
--to=libaokun1@huawei.com \
--cc=adilger.kernel@dilger.ca \
--cc=bhupesh@igalia.com \
--cc=k.yankevich@omp.ru \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-patches@linuxtesting.org \
--cc=s.shtylyov@omp.ru \
--cc=tytso@mit.edu \
/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®