From: Karina Yankevich <k.yankevich@omp.ru>
To: Theodore Ts'o <tytso@mit.edu>
Cc: Karina Yankevich <k.yankevich@omp.ru>,
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: [PATCH] ext4: xattr: fix null pointer deref in ext4_raw_inode()
Date: Wed, 22 Oct 2025 12:32:53 +0300 [thread overview]
Message-ID: <20251022093253.3546296-1-k.yankevich@omp.ru> (raw)
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>
---
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;
}
--
2.34.1
next reply other threads:[~2025-10-22 9:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-22 9:32 Karina Yankevich [this message]
2025-11-05 17:18 ` Markus Elfring
2025-11-08 3:12 ` Baokun Li
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=20251022093253.3546296-1-k.yankevich@omp.ru \
--to=k.yankevich@omp.ru \
--cc=adilger.kernel@dilger.ca \
--cc=bhupesh@igalia.com \
--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®