From: syzbot <syzbot+3ee481e21fd75e14c397@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Forwarded: [PATCH] ext4: fix use-after-free in ext4_search_dir via corrupted inline xattr
Date: Wed, 01 Oct 2025 22:09:13 -0700 [thread overview]
Message-ID: <68de08f9.a00a0220.102ee.007a.GAE@google.com> (raw)
In-Reply-To: <68ddc2f9.a00a0220.102ee.006d.GAE@google.com>
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH] ext4: fix use-after-free in ext4_search_dir via corrupted inline xattr
Author: kartikey406@gmail.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
Add bounds validation for inline directory xattr data to prevent
use-after-free when accessing corrupted filesystems.
ext4_find_inline_entry() performs two directory searches: first in
the i_block area, then in the extended attribute (xattr) area of the
inode. When calculating inline_start for the xattr area via
ext4_get_inline_xattr_pos(), the function trusts the e_value_offs
field from disk without validating the resulting pointer stays within
the inode's boundaries.
A corrupted filesystem can craft a malicious e_value_offs value that
causes inline_start to point outside the inode's allocated space,
potentially into freed memory. When ext4_search_dir() attempts to
access this invalid pointer, it results in a KASAN use-after-free.
Fix this by validating that inline_start and inline_start + inline_size
remain within the inode's boundaries before calling ext4_search_dir().
Return -EFSCORRUPTED if the bounds check fails.
Reported-by: syzbot+3ee481e21fd75e14c397@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=3ee481e21fd75e14c397
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
fs/ext4/inline.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index 1b094a4f3866..28ac90a8d5a2 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -1617,7 +1617,15 @@ struct buffer_head *ext4_find_inline_entry(struct inode *dir,
inline_start = ext4_get_inline_xattr_pos(dir, &is.iloc);
inline_size = ext4_get_inline_size(dir) - EXT4_MIN_INLINE_DATA_SIZE;
-
+ void *inode_start = ext4_raw_inode(&is.iloc);
+ void *inode_end = inode_start + EXT4_INODE_SIZE(dir->i_sb);
+
+ if (inline_start < inode_start ||
+ inline_start >= inode_end ||
+ inline_start + inline_size > inode_end) {
+ ret = -EFSCORRUPTED;
+ goto out;
+ }
ret = ext4_search_dir(is.iloc.bh, inline_start, inline_size,
dir, fname, 0, res_dir);
if (ret == 1)
--
2.43.0
next prev parent reply other threads:[~2025-10-02 5:09 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-02 0:10 [syzbot] [ext4?] KASAN: slab-out-of-bounds Read in ext4_search_dir syzbot
2025-10-02 5:09 ` syzbot [this message]
2025-10-02 6:18 ` Forwarded: [PATCH] ext4: reject system.data xattr with external inode storage syzbot
2025-10-02 6:28 ` syzbot
2025-10-02 9:38 ` syzbot
2025-10-02 10:01 ` Forwarded: [PATCH] ext4: reject inline data flag when i_extra_isize is zero syzbot
2025-10-02 22:57 ` syzbot
2025-10-02 23:54 ` Forwarded: [PATCH] ext4: reject system.data xattr with external inode storage syzbot
2025-10-03 0:23 ` Forwarded: [PATCH] ext4: fix use-after-free in ext4_search_dir via corrupted inline xattr syzbot
2025-10-03 1:07 ` Forwarded: [PATCH] ext4: reject inline data flag when i_extra_isize is zero syzbot
2025-10-03 1:40 ` syzbot
2025-10-03 2:02 ` syzbot
2025-10-03 3:02 ` syzbot
2025-10-03 3:16 ` syzbot
2025-10-03 4:02 ` Forwarded: [PATCH] ext4: reject inline data flag when i_extra_size " syzbot
2025-10-03 6:17 ` Forwarded: [PATCH] ext4: reject inline data flag when i_extra_isize " syzbot
2025-10-03 8:14 ` Forwarded: [PATCH] ext4: reject system.data xattr with external inode storage syzbot
2025-10-03 8:36 ` Forwarded: [PATCH] ext4: reject inline data flag when i_extra_isize is zero syzbot
2025-10-03 9:09 ` syzbot
2025-10-14 13:41 ` kerne test robot
2025-11-08 5:34 ` Forwarded: potential fix syzbot
2025-11-08 17:54 ` Forwarded: test fix syzbot
2025-11-13 22:29 ` syzbot
2025-11-14 0:13 ` syzbot
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=68de08f9.a00a0220.102ee.007a.GAE@google.com \
--to=syzbot+3ee481e21fd75e14c397@syzkaller.appspotmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=syzkaller-bugs@googlegroups.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.