From: syzbot <syzbot+ab0ad25088673470d2d9@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Forwarded: [PATCH] ocfs2: validate xattr header in ocfs2_validate_inode_block
Date: Mon, 10 Nov 2025 20:40:08 -0800 [thread overview]
Message-ID: <6912be28.a70a0220.22f260.0125.GAE@google.com> (raw)
In-Reply-To: <69122a59.a70a0220.22f260.00fc.GAE@google.com>
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.
***
Subject: [PATCH] ocfs2: validate xattr header in ocfs2_validate_inode_block
Author: kartikey406@gmail.com
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci
Add validation of inline xattr header fields when validating inode
blocks to catch corruption early before the inode is used by the
system. This prevents corrupted xattr counts from causing out-of-bounds
access and use-after-free bugs in xattr processing code.
The validation checks:
1. xattr_inline_size does not exceed block size
2. xattr_inline_size is large enough for header structure
3. xattr entry count does not exceed available space
This moves validation to the inode block validation stage, providing
comprehensive protection for all code paths that access inline xattrs.
Reported-by: syzbot+ab0ad25088673470d2d9@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=ab0ad25088673470d2d9
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
fs/ocfs2/inode.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index fcc89856ab95..9d5342b8dbc6 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -1458,6 +1458,47 @@ int ocfs2_validate_inode_block(struct super_block *sb,
(unsigned long long)bh->b_blocknr);
goto bail;
}
+ if (di->i_dyn_features & cpu_to_le16(OCFS2_INLINE_XATTR_FL)) {
+ struct ocfs2_xattr_header *header;
+ u16 xattr_inline_size;
+ u16 xattr_count;
+ size_t max_entries;
+
+ xattr_inline_size = le16_to_cpu(di->i_xattr_inline_size);
+
+ /* Validate inline size is within block bounds */
+ if (xattr_inline_size > sb->s_blocksize) {
+ mlog(ML_ERROR,
+ "xattr inline size %u exceeds block size %lu in inode %llu\n",
+ xattr_inline_size, sb->s_blocksize,
+ (unsigned long long)bh->b_blocknr);
+ goto bail;
+ }
+ /* If there's xattr data, validate it */
+ if (xattr_inline_size > 0) {
+ /* Must be at least big enough for header */
+ if (xattr_inline_size < sizeof(struct ocfs2_xattr_header)) {
+ mlog(ML_ERROR,
+ "xattr inline size %u too small for header in inode %llu\n",
+ xattr_inline_size,
+ (unsigned long long)bh->b_blocknr);
+ goto bail;
+ }
+ header = (struct ocfs2_xattr_header *)
+ ((void *)di + sb->s_blocksize - xattr_inline_size);
+ xattr_count = le16_to_cpu(header->xh_count);
+ max_entries = (xattr_inline_size -
+ sizeof(struct ocfs2_xattr_header)) /
+ sizeof(struct ocfs2_xattr_entry);
+ if (xattr_count > max_entries) {
+ mlog(ML_ERROR,
+ "xattr count %u exceeds maximum %zu in inode %llu\n",
+ xattr_count, max_entries,
+ (unsigned long long)bh->b_blocknr);
+ goto bail;
+ }
+ }
+ }
/*
* Errors after here are fatal.
--
2.43.0
next prev parent reply other threads:[~2025-11-11 4:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-10 18:09 [syzbot] [ocfs2?] KASAN: use-after-free Read in ocfs2_listxattr syzbot
2025-11-11 1:31 ` Forwarded: [PATCH] ocfs2: validate xattr entry count to prevent use-after-free syzbot
2025-11-11 4:29 ` Forwarded: [PATCH] ocfs2: validate xattr header in ocfs2_validate_inode_block syzbot
2025-11-11 4:40 ` syzbot [this message]
2025-11-11 6:06 ` Forwarded: [PATCH] ocfs2: validate xattr entry count in ocfs2_validate_xattr_block syzbot
2025-11-17 9:17 ` Forwarded: [PATCH v3] ocfs2: validate xattr entry count in ocfs2_xattr_ibody_list 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=6912be28.a70a0220.22f260.0125.GAE@google.com \
--to=syzbot+ab0ad25088673470d2d9@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox