* [PATCH] ext4: xattr: fix null pointer deref in ext4_raw_inode()
@ 2025-10-22 9:32 Karina Yankevich
2025-11-05 17:18 ` Markus Elfring
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Karina Yankevich @ 2025-10-22 9:32 UTC (permalink / raw)
To: Theodore Ts'o
Cc: Karina Yankevich, Andreas Dilger, Bhupesh, linux-ext4,
linux-kernel, lvc-patches, Sergey Shtylyov
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ext4: xattr: fix null pointer deref in ext4_raw_inode()
2025-10-22 9:32 [PATCH] ext4: xattr: fix null pointer deref in ext4_raw_inode() Karina Yankevich
@ 2025-11-05 17:18 ` Markus Elfring
2025-11-08 3:12 ` Baokun Li
2025-11-17 19:13 ` Theodore Ts'o
2 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2025-11-05 17:18 UTC (permalink / raw)
To: Karina Yankevich, linux-ext4, lvc-patches, Sergey Shtylyov,
Theodore Ts'o
Cc: LKML, Andreas Dilger, Bhupesh Sharma
> If ext4_get_inode_loc() fails (e.g. if it returns -EFSCORRUPTED),
…
Corresponding error detection seems to be missing so far.
Would another imperative wording become helpful for an improved change description?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.18-rc4#n94
Regards,
Markus
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ext4: xattr: fix null pointer deref in ext4_raw_inode()
2025-10-22 9:32 [PATCH] ext4: xattr: fix null pointer deref in ext4_raw_inode() Karina Yankevich
2025-11-05 17:18 ` Markus Elfring
@ 2025-11-08 3:12 ` Baokun Li
2025-11-17 19:13 ` Theodore Ts'o
2 siblings, 0 replies; 4+ messages in thread
From: Baokun Li @ 2025-11-08 3:12 UTC (permalink / raw)
To: Karina Yankevich
Cc: Theodore Ts'o, Andreas Dilger, Bhupesh, linux-ext4,
linux-kernel, lvc-patches, Sergey Shtylyov
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;
> }
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ext4: xattr: fix null pointer deref in ext4_raw_inode()
2025-10-22 9:32 [PATCH] ext4: xattr: fix null pointer deref in ext4_raw_inode() Karina Yankevich
2025-11-05 17:18 ` Markus Elfring
2025-11-08 3:12 ` Baokun Li
@ 2025-11-17 19:13 ` Theodore Ts'o
2 siblings, 0 replies; 4+ messages in thread
From: Theodore Ts'o @ 2025-11-17 19:13 UTC (permalink / raw)
To: Karina Yankevich
Cc: Theodore Ts'o, Andreas Dilger, Bhupesh, linux-ext4,
linux-kernel, lvc-patches, Sergey Shtylyov
On Wed, 22 Oct 2025 12:32:53 +0300, 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.
>
> [...]
Applied, thanks!
[1/1] ext4: xattr: fix null pointer deref in ext4_raw_inode()
commit: b97cb7d6a051aa6ebd57906df0e26e9e36c26d14
Best regards,
--
Theodore Ts'o <tytso@mit.edu>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-11-17 19:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-22 9:32 [PATCH] ext4: xattr: fix null pointer deref in ext4_raw_inode() Karina Yankevich
2025-11-05 17:18 ` Markus Elfring
2025-11-08 3:12 ` Baokun Li
2025-11-17 19:13 ` Theodore Ts'o
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®