From: Raphael Pinsonneault-Thibeault <rpthibeault@gmail.com>
To: tytso@mit.edu, adilger.kernel@dilger.ca
Cc: cascardo@igalia.com, linux-ext4@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-kernel-mentees@lists.linux.dev, skhan@linuxfoundation.org,
syzbot+3ee481e21fd75e14c397@syzkaller.appspotmail.com,
Raphael Pinsonneault-Thibeault <rpthibeault@gmail.com>
Subject: [PATCH] ext4: validate xattrs to avoid OOB in ext4_find_inline_entry
Date: Sat, 8 Nov 2025 15:25:46 -0500 [thread overview]
Message-ID: <20251108202545.1524330-2-rpthibeault@gmail.com> (raw)
When looking for an entry in an inlined directory, if e_value_offs is
changed underneath the filesystem by some change in the block device, it
will lead to an out-of-bounds access that KASAN detects as a
use-after-free.
This is a similar problem as fixed by
commit c6b72f5d82b1 ("ext4: avoid OOB when system.data xattr changes underneath the filesystem")
whose fix was to call ext4_xattr_ibody_find() right after reading the
inode with ext4_get_inode_loc() to check the validity of the xattrs.
However, ext4_xattr_ibody_find() only checks xattr names, via
xattr_find_entry(), not e_value_offs.
Fix by calling xattr_check_inode() which performs a full check on the
xattrs in inode.
Reported-by: syzbot+3ee481e21fd75e14c397@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=3ee481e21fd75e14c397
Tested-by: syzbot+3ee481e21fd75e14c397@syzkaller.appspotmail.com
Fixes: c6b72f5d82b10 ("ext4: avoid OOB when system.data xattr changes underneath the filesystem")
Signed-off-by: Raphael Pinsonneault-Thibeault <rpthibeault@gmail.com>
---
fs/ext4/inline.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/fs/ext4/inline.c b/fs/ext4/inline.c
index 1b094a4f3866..7d46e1e16b52 100644
--- a/fs/ext4/inline.c
+++ b/fs/ext4/inline.c
@@ -1593,6 +1593,13 @@ struct buffer_head *ext4_find_inline_entry(struct inode *dir,
down_read(&EXT4_I(dir)->xattr_sem);
+ if (EXT4_INODE_HAS_XATTR_SPACE(dir)) {
+ ret = xattr_check_inode(dir, IHDR(dir, ext4_raw_inode(&is.iloc)),
+ ITAIL(dir, ext4_raw_inode(&is.iloc)));
+ if (ret)
+ goto out;
+ }
+
ret = ext4_xattr_ibody_find(dir, &i, &is);
if (ret)
goto out;
--
2.43.0
next reply other threads:[~2025-11-08 20:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-08 20:25 Raphael Pinsonneault-Thibeault [this message]
2025-11-10 11:55 ` [PATCH] ext4: validate xattrs to avoid OOB in ext4_find_inline_entry Thadeu Lima de Souza Cascardo
2025-11-12 18:57 ` [PATCH v2] " Raphael Pinsonneault-Thibeault
2025-11-12 19:48 ` 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=20251108202545.1524330-2-rpthibeault@gmail.com \
--to=rpthibeault@gmail.com \
--cc=adilger.kernel@dilger.ca \
--cc=cascardo@igalia.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=syzbot+3ee481e21fd75e14c397@syzkaller.appspotmail.com \
--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