fs/ocfs2/suballoc.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
#syz test git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 36c254515dc6592c44db77b84908358979dd6b50
Signed-off-by: Prithvi Tambewagh <activprithvi@gmail.com>
---
fs/ocfs2/suballoc.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index f7b483f0de2a..7ea63e9cc4f8 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -671,6 +671,21 @@ static int ocfs2_block_group_alloc(struct ocfs2_super *osb,
BUG_ON(ocfs2_is_cluster_bitmap(alloc_inode));
cl = &fe->id2.i_chain;
+ unsigned int block_size = osb->sb->s_blocksize;
+ unsigned int max_cl_count =
+ (block_size - offsetof(struct ocfs2_chain_list, cl_recs)) /
+ sizeof(struct ocfs2_chain_rec);
+
+ if (!le16_to_cpu(cl->cl_count) ||
+ le16_to_cpu(cl->cl_count) > max_cl_count) {
+ ocfs2_error(osb->sb,
+ "Invalid chain list: cl_count %u "
+ "exceeds max %u",
+ le16_to_cpu(cl->cl_count), max_cl_count);
+ status = -EIO;
+ goto bail;
+ }
+
status = ocfs2_reserve_clusters_with_limit(osb,
le16_to_cpu(cl->cl_cpg),
max_block, flags, &ac);
base-commit: 36c254515dc6592c44db77b84908358979dd6b50
--
2.34.1
Hello, syzbot has tested the proposed patch and the reproducer did not trigger any issue: Reported-by: syzbot+af14efe17dfa46173239@syzkaller.appspotmail.com Tested-by: syzbot+af14efe17dfa46173239@syzkaller.appspotmail.com Tested on: commit: 36c25451 Merge tag 'powerpc-6.12-4' of git://git.kerne.. git tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git console output: https://syzkaller.appspot.com/x/log.txt?x=152cd984580000 kernel config: https://syzkaller.appspot.com/x/.config?x=cb22c32016cc7ad7 dashboard link: https://syzkaller.appspot.com/bug?extid=af14efe17dfa46173239 compiler: Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8 patch: https://syzkaller.appspot.com/x/patch.diff?x=169e1b1a580000 Note: testing is done by a robot and is best-effort only.
© 2016 - 2026 Red Hat, Inc.