[PATCH 5.10/5.15 v2 1/4] ocfs2: add suballoc slot check in ocfs2_validate_inode_block()

From: Mikhail Dmitrichenko

Date: Mon Nov 23 2026 - 09:02:41 EST


From: Dmitry Antipov <dmantipov@xxxxxxxxx>

commit fe7a283b39160153b6d1bd7f61b0a9d5d44987a8 upstream.

In 'ocfs2_validate_inode_block()', add suballoc slot check similar to one
in 'ocfs2_get_suballoc_slot_bit()', thus preventing an out-of-bounds
accesses for 'local_system_inodes' in 'get_local_system_inode()'.

Most likely this fixes
https://syzkaller.appspot.com/bug?extid=a77d690840e60bc2ddd8 as well.

Link: https://lkml.kernel.org/r/20250826095106.666980-1-dmantipov@xxxxxxxxx
Signed-off-by: Dmitry Antipov <dmantipov@xxxxxxxxx>
Reported-by: syzbot+900962ac9bf1860033f2@xxxxxxxxxxxxxxxxxxxxxxxxx
Closes: https://syzkaller.appspot.com/bug?extid=900962ac9bf1860033f2
Reviewed-by: Joseph Qi <joseph.qi@xxxxxxxxxxxxxxxxx>
Cc: Mark Fasheh <mark@xxxxxxxxxx>
Cc: Joel Becker <jlbec@xxxxxxxxxxxx>
Cc: Junxiao Bi <junxiao.bi@xxxxxxxxxx>
Cc: Changwei Ge <gechangwei@xxxxxxx>
Cc: Jun Piao <piaojun@xxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
Stable-dep-of: 25bf9e549360 ("ocfs2: restrict OCFS2_INVALID_SLOT suballoc slot to system inodes")
Stable-dep-of: b2d31acbd3b1 ("ocfs2: validate orphan slot during inode read")
[mdmitrichenko: Resolve the overlap with existing dinode checks by
inserting the suballoc slot check before i_mode validation.]
Signed-off-by: Mikhail Dmitrichenko <mdmitrichenko@xxxxxxxxxxxxx>
---
fs/ocfs2/inode.c | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index 2ffa3571d15b..b6fa3c8c6663 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -1452,6 +1452,14 @@ int ocfs2_validate_inode_block(struct super_block *sb,
goto bail;
}

+ if (le16_to_cpu(di->i_suballoc_slot) != (u16)OCFS2_INVALID_SLOT &&
+ (u32)le16_to_cpu(di->i_suballoc_slot) > OCFS2_SB(sb)->max_slots - 1) {
+ rc = ocfs2_error(sb, "Invalid dinode %llu: suballoc slot %u\n",
+ (unsigned long long)bh->b_blocknr,
+ le16_to_cpu(di->i_suballoc_slot));
+ goto bail;
+ }
+
/*
* Reject dinodes whose i_mode does not name one of the seven
* canonical POSIX file types. ocfs2_populate_inode() copies