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

Mikhail Dmitrichenko mdmitrichenko at astralinux.ru
Mon Nov 23 16:59:34 MSK 2026


From: Dmitry Antipov <dmantipov at yandex.ru>

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@yandex.ru
Signed-off-by: Dmitry Antipov <dmantipov at yandex.ru>
Reported-by: syzbot+900962ac9bf1860033f2 at syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=900962ac9bf1860033f2
Reviewed-by: Joseph Qi <joseph.qi at linux.alibaba.com>
Cc: Mark Fasheh <mark at fasheh.com>
Cc: Joel Becker <jlbec at evilplan.org>
Cc: Junxiao Bi <junxiao.bi at oracle.com>
Cc: Changwei Ge <gechangwei at live.cn>
Cc: Jun Piao <piaojun at huawei.com>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
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 at astralinux.ru>
---
 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



More information about the lvc-project mailing list