All of lore.kernel.org
 help / color / mirror / Atom feed
* [syzbot] [ocfs2?] kernel BUG in ocfs2_block_group_search
@ 2026-01-03 22:53 syzbot
  2026-01-04  1:15 ` Forwarded: [PATCH] ocfs2: validate allocator type to prevent BUG_ON " syzbot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: syzbot @ 2026-01-03 22:53 UTC (permalink / raw)
  To: jlbec, joseph.qi, linux-kernel, mark, ocfs2-devel, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    dbf8fe85a16a Merge tag 'net-6.19-rc4' of git://git.kernel...
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=16b19792580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=513255d80ab78f2b
dashboard link: https://syzkaller.appspot.com/bug?extid=44c564a3cb08605f34a1
compiler:       Debian clang version 20.1.8 (++20250708063551+0c9f909b7976-1~exp1~20250708183702.136), Debian LLD 20.1.8
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=10ef2422580000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=11b19792580000

Downloadable assets:
disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/d900f083ada3/non_bootable_disk-dbf8fe85.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/86d0a4a4173a/vmlinux-dbf8fe85.xz
kernel image: https://storage.googleapis.com/syzbot-assets/23bd847a572d/bzImage-dbf8fe85.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/97470b986566/mount_0.gz
  fsck result: OK (log: https://syzkaller.appspot.com/x/fsck.log?x=1047329a580000)

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+44c564a3cb08605f34a1@syzkaller.appspotmail.com

=======================================================
JBD2: Ignoring recovery information on journal
ocfs2: Mounting device (7,0) on (node local, slot 0) with ordered data mode.
------------[ cut here ]------------
kernel BUG at fs/ocfs2/suballoc.c:1611!
Oops: invalid opcode: 0000 [#1] SMP KASAN NOPTI
CPU: 0 UID: 0 PID: 5527 Comm: syz.0.17 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
RIP: 0010:ocfs2_block_group_search+0x367/0x490 fs/ocfs2/suballoc.c:1611
Code: d9 80 e1 07 80 c1 03 38 c1 0f 8c c5 fe ff ff 48 89 df e8 0c 40 77 fe e9 b8 fe ff ff e8 92 95 0f fe 90 0f 0b e8 8a 95 0f fe 90 <0f> 0b f3 0f 1e fa 65 44 8b 3d 4f 2e cf 0e bf 07 00 00 00 44 89 fe
RSP: 0018:ffffc90002616bb8 EFLAGS: 00010293
RAX: ffffffff83b171d6 RBX: 000000000000004a RCX: ffff888000b70000
RDX: 0000000000000000 RSI: 000000000000004a RDI: 000000000000004a
RBP: 0000000000000001 R08: 00000000ffffffff R09: ffffc900026171a0
R10: dffffc0000000000 R11: ffffffff83b16e70 R12: ffff8880470b0740
R13: ffff88804453c740 R14: ffff8880230d7000 R15: 000000000000004a
FS:  000055556aa08500(0000) GS:ffff88808d416000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fbdcf97f000 CR3: 00000000113be000 CR4: 0000000000352ef0
Call Trace:
 <TASK>
 ocfs2_search_chain+0x5f3/0x1d60 fs/ocfs2/suballoc.c:1836
 ocfs2_claim_suballoc_bits+0xc1e/0x1f60 fs/ocfs2/suballoc.c:2011
 ocfs2_claim_new_inode+0x332/0x7a0 fs/ocfs2/suballoc.c:2303
 ocfs2_mknod_locked+0x100/0x250 fs/ocfs2/namei.c:638
 ocfs2_mknod+0x10a5/0x2030 fs/ocfs2/namei.c:385
 ocfs2_create+0x195/0x420 fs/ocfs2/namei.c:677
 lookup_open fs/namei.c:4440 [inline]
 open_last_lookups fs/namei.c:4540 [inline]
 path_openat+0x18bb/0x3dd0 fs/namei.c:4784
 do_filp_open+0x1fa/0x410 fs/namei.c:4814
 do_sys_openat2+0x121/0x200 fs/open.c:1430
 do_sys_open fs/open.c:1436 [inline]
 __do_sys_openat fs/open.c:1452 [inline]
 __se_sys_openat fs/open.c:1447 [inline]
 __x64_sys_openat+0x138/0x170 fs/open.c:1447
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xec/0xf80 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fe1e2d8f7c9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 a8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fff02afc7a8 EFLAGS: 00000246 ORIG_RAX: 0000000000000101
RAX: ffffffffffffffda RBX: 00007fe1e2fe5fa0 RCX: 00007fe1e2d8f7c9
RDX: 000000000000275a RSI: 0000200000000040 RDI: ffffffffffffff9c
RBP: 00007fe1e2e13f91 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007fe1e2fe5fa0 R14: 00007fe1e2fe5fa0 R15: 0000000000000004
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:ocfs2_block_group_search+0x367/0x490 fs/ocfs2/suballoc.c:1611
Code: d9 80 e1 07 80 c1 03 38 c1 0f 8c c5 fe ff ff 48 89 df e8 0c 40 77 fe e9 b8 fe ff ff e8 92 95 0f fe 90 0f 0b e8 8a 95 0f fe 90 <0f> 0b f3 0f 1e fa 65 44 8b 3d 4f 2e cf 0e bf 07 00 00 00 44 89 fe
RSP: 0018:ffffc90002616bb8 EFLAGS: 00010293
RAX: ffffffff83b171d6 RBX: 000000000000004a RCX: ffff888000b70000
RDX: 0000000000000000 RSI: 000000000000004a RDI: 000000000000004a
RBP: 0000000000000001 R08: 00000000ffffffff R09: ffffc900026171a0
R10: dffffc0000000000 R11: ffffffff83b16e70 R12: ffff8880470b0740
R13: ffff88804453c740 R14: ffff8880230d7000 R15: 000000000000004a
FS:  000055556aa08500(0000) GS:ffff88808d416000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fd8f777e286 CR3: 00000000113be000 CR4: 0000000000352ef0


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Forwarded: [PATCH] ocfs2: validate allocator type to prevent BUG_ON in ocfs2_block_group_search
  2026-01-03 22:53 [syzbot] [ocfs2?] kernel BUG in ocfs2_block_group_search syzbot
@ 2026-01-04  1:15 ` syzbot
  2026-01-24  2:39 ` Forwarded: [PATCH] ocfs2: validate i_blkno and BITMAP_FL consistency in ocfs2_validate_inode_block syzbot
  2026-01-24  4:14 ` syzbot
  2 siblings, 0 replies; 4+ messages in thread
From: syzbot @ 2026-01-04  1:15 UTC (permalink / raw)
  To: linux-kernel, syzkaller-bugs

For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.

***

Subject: [PATCH] ocfs2: validate allocator type to prevent BUG_ON in ocfs2_block_group_search
Author: kartikey406@gmail.com

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

A corrupted filesystem image can have an inode allocator with the
OCFS2_BITMAP_FL flag incorrectly set, making ocfs2_is_cluster_bitmap()
return true. When the code later calls ocfs2_block_group_search(),
it triggers BUG_ON(ocfs2_is_cluster_bitmap(inode)) causing a kernel panic.

Call trace:
  ocfs2_block_group_search+0x1c7/0x2c0 fs/ocfs2/suballoc.c:1611
  ocfs2_search_chain+0x38a/0x1010 fs/ocfs2/suballoc.c:1764
  ocfs2_claim_suballoc_bits+0x3a4/0x650 fs/ocfs2/suballoc.c:1978
  ocfs2_claim_new_inode+0x95/0x130 fs/ocfs2/suballoc.c:2137
  ocfs2_mknod_locked+0x129/0x510 fs/ocfs2/namei.c:568
  ocfs2_mknod+0x5c7/0x11d0 fs/ocfs2/namei.c:802
  ocfs2_create+0x136/0x170 fs/ocfs2/namei.c:852

Add validation in ocfs2_reserve_suballoc_bits() to check that the
allocator inode type matches the expected type:
- Global bitmap allocator must have OCFS2_BITMAP_FL flag set
- Other allocators (inode, extent) must NOT have OCFS2_BITMAP_FL set

This follows the existing pattern of validating OCFS2_CHAIN_FL in the
same function and uses ocfs2_error() for graceful error handling.

Reported-by: syzbot+44c564a3cb08605f34a1@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=44c564a3cb08605f34a1
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
 fs/ocfs2/suballoc.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
index 8e6e5235b30c..fb72c062a8d5 100644
--- a/fs/ocfs2/suballoc.c
+++ b/fs/ocfs2/suballoc.c
@@ -813,6 +813,26 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
 		goto bail;
 	}
 
+	/*
+	 * Validate allocator type matches expected bitmap type.
+	 * Global bitmap must have BITMAP flag, other allocators must not.
+	 * This prevents a corrupted filesystem from triggering BUG_ON
+	 * in ocfs2_block_group_search() or ocfs2_cluster_group_search().
+	 */
+	if (type == GLOBAL_BITMAP_SYSTEM_INODE) {
+		if (!ocfs2_is_cluster_bitmap(alloc_inode)) {
+			status = ocfs2_error(alloc_inode->i_sb,
+					     "Global bitmap %llu missing bitmap flag\n",
+					     (unsigned long long)le64_to_cpu(fe->i_blkno));
+			goto bail;
+		}
+	} else if (ocfs2_is_cluster_bitmap(alloc_inode)) {
+		status = ocfs2_error(alloc_inode->i_sb,
+				     "Allocator %llu has invalid bitmap flag\n",
+				     (unsigned long long)le64_to_cpu(fe->i_blkno));
+		goto bail;
+	}
+
 	free_bits = le32_to_cpu(fe->id1.bitmap1.i_total) -
 		le32_to_cpu(fe->id1.bitmap1.i_used);
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Forwarded: [PATCH] ocfs2: validate i_blkno and BITMAP_FL consistency in ocfs2_validate_inode_block
  2026-01-03 22:53 [syzbot] [ocfs2?] kernel BUG in ocfs2_block_group_search syzbot
  2026-01-04  1:15 ` Forwarded: [PATCH] ocfs2: validate allocator type to prevent BUG_ON " syzbot
@ 2026-01-24  2:39 ` syzbot
  2026-01-24  4:14 ` syzbot
  2 siblings, 0 replies; 4+ messages in thread
From: syzbot @ 2026-01-24  2:39 UTC (permalink / raw)
  To: linux-kernel, syzkaller-bugs

For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.

***

Subject: [PATCH] ocfs2: validate i_blkno and BITMAP_FL consistency in ocfs2_validate_inode_block
Author: kartikey406@gmail.com

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

ocfs2_is_cluster_bitmap() checks whether an inode is the global bitmap
by comparing ip_blkno with osb->bitmap_blkno. A corrupted filesystem
can have an inode with i_blkno and OCFS2_BITMAP_FL flag inconsistent:
- i_blkno matches bitmap_blkno but BITMAP_FL is not set, or
- BITMAP_FL is set but i_blkno does not match bitmap_blkno

In either case, ocfs2_is_cluster_bitmap() returns incorrect results,
triggering BUG_ON in ocfs2_block_group_search() or
ocfs2_cluster_group_search() causing a kernel panic.

Call trace:
  ocfs2_block_group_search+0x1c7/0x2c0 fs/ocfs2/suballoc.c:1611
  ocfs2_search_chain+0x38a/0x1010 fs/ocfs2/suballoc.c:1764
  ocfs2_claim_suballoc_bits+0x3a4/0x650 fs/ocfs2/suballoc.c:1978
  ocfs2_claim_new_inode+0x95/0x130 fs/ocfs2/suballoc.c:2137
  ocfs2_mknod_locked+0x129/0x510 fs/ocfs2/namei.c:568
  ocfs2_mknod+0x5c7/0x11d0 fs/ocfs2/namei.c:802
  ocfs2_create+0x136/0x170 fs/ocfs2/namei.c:852

Add validation in ocfs2_validate_inode_block() to check that i_blkno
and OCFS2_BITMAP_FL are consistent:
- If i_blkno matches bitmap_blkno, BITMAP_FL must be set
- If BITMAP_FL is set, i_blkno must match bitmap_blkno

This catches corrupted inodes early when reading from disk.

Reported-by: syzbot+44c564a3cb08605f34a1@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=44c564a3cb08605f34a1
Tested-by: syzbot+44c564a3cb08605f34a1@syzkaller.appspotmail.com
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
v3:
  - Move validation to ocfs2_validate_inode_block() to catch corruption
    early when inode is read from disk (Joseph Qi)
  - Add check for both directions of inconsistency

v2:
  - Fix commit message - ocfs2_is_cluster_bitmap() checks ip_blkno
    against bitmap_blkno, not a flag (Joseph Qi)
---
 fs/ocfs2/inode.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index b5fcc2725a29..2d80934d14b4 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -1529,6 +1529,27 @@ int ocfs2_validate_inode_block(struct super_block *sb,
 		}
 	}
 
+	/*
+	 * Validate bitmap flag consistency with bitmap_blkno.
+	 * A corrupted inode with mismatched i_blkno and BITMAP_FL would
+	 * cause ocfs2_is_cluster_bitmap() to return incorrect results,
+	 * triggering BUG_ON in ocfs2_block_group_search() or
+	 * ocfs2_cluster_group_search().
+	 */
+	if (le64_to_cpu(di->i_blkno) == OCFS2_SB(sb)->bitmap_blkno &&
+	    !(di->i_flags & cpu_to_le32(OCFS2_BITMAP_FL))) {
+		rc = ocfs2_error(sb,
+				 "Invalid dinode #%llu: i_blkno matches bitmap but BITMAP flag not set\n",
+				 (unsigned long long)bh->b_blocknr);
+		goto bail;
+	} else if (di->i_flags & cpu_to_le32(OCFS2_BITMAP_FL) &&
+		   le64_to_cpu(di->i_blkno) != OCFS2_SB(sb)->bitmap_blkno) {
+		rc = ocfs2_error(sb,
+				 "Invalid dinode #%llu: BITMAP flag set but i_blkno does not match bitmap\n",
+				 (unsigned long long)bh->b_blocknr);
+		goto bail;
+	}
+
 	rc = 0;
 
 bail:
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Forwarded: [PATCH] ocfs2: validate i_blkno and BITMAP_FL consistency in ocfs2_validate_inode_block
  2026-01-03 22:53 [syzbot] [ocfs2?] kernel BUG in ocfs2_block_group_search syzbot
  2026-01-04  1:15 ` Forwarded: [PATCH] ocfs2: validate allocator type to prevent BUG_ON " syzbot
  2026-01-24  2:39 ` Forwarded: [PATCH] ocfs2: validate i_blkno and BITMAP_FL consistency in ocfs2_validate_inode_block syzbot
@ 2026-01-24  4:14 ` syzbot
  2 siblings, 0 replies; 4+ messages in thread
From: syzbot @ 2026-01-24  4:14 UTC (permalink / raw)
  To: linux-kernel, syzkaller-bugs

For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.

***

Subject: [PATCH] ocfs2: validate i_blkno and BITMAP_FL consistency in ocfs2_validate_inode_block
Author: kartikey406@gmail.com

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

ocfs2_is_cluster_bitmap() checks whether an inode is the global bitmap
by comparing ip_blkno with osb->bitmap_blkno. A corrupted filesystem
can have an inode with i_blkno and OCFS2_BITMAP_FL flag inconsistent:
- i_blkno matches bitmap_blkno but BITMAP_FL is not set, or
- BITMAP_FL is set but i_blkno does not match bitmap_blkno

In either case, ocfs2_is_cluster_bitmap() returns incorrect results,
triggering BUG_ON in ocfs2_block_group_search() or
ocfs2_cluster_group_search() causing a kernel panic.

Call trace:
  ocfs2_block_group_search+0x1c7/0x2c0 fs/ocfs2/suballoc.c:1611
  ocfs2_search_chain+0x38a/0x1010 fs/ocfs2/suballoc.c:1764
  ocfs2_claim_suballoc_bits+0x3a4/0x650 fs/ocfs2/suballoc.c:1978
  ocfs2_claim_new_inode+0x95/0x130 fs/ocfs2/suballoc.c:2137
  ocfs2_mknod_locked+0x129/0x510 fs/ocfs2/namei.c:568
  ocfs2_mknod+0x5c7/0x11d0 fs/ocfs2/namei.c:802
  ocfs2_create+0x136/0x170 fs/ocfs2/namei.c:852

Add validation in ocfs2_validate_inode_block() to check that i_blkno
and OCFS2_BITMAP_FL are consistent:
- If i_blkno matches bitmap_blkno, BITMAP_FL must be set
- If BITMAP_FL is set, i_blkno must match bitmap_blkno

This catches corrupted inodes early when reading from disk.

Reported-by: syzbot+44c564a3cb08605f34a1@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=44c564a3cb08605f34a1
Tested-by: syzbot+44c564a3cb08605f34a1@syzkaller.appspotmail.com
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
---
v3:
  - Move validation to ocfs2_validate_inode_block() to catch corruption
    early when inode is read from disk (Joseph Qi)
  - Add check for both directions of inconsistency

v2:
  - Fix commit message - ocfs2_is_cluster_bitmap() checks ip_blkno
    against bitmap_blkno, not a flag (Joseph Qi)
---
 fs/ocfs2/inode.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index b5fcc2725a29..2d80934d14b4 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -1529,6 +1529,27 @@ int ocfs2_validate_inode_block(struct super_block *sb,
 		}
 	}
 
+	/*
+	 * Validate bitmap flag consistency with bitmap_blkno.
+	 * A corrupted inode with mismatched i_blkno and BITMAP_FL would
+	 * cause ocfs2_is_cluster_bitmap() to return incorrect results,
+	 * triggering BUG_ON in ocfs2_block_group_search() or
+	 * ocfs2_cluster_group_search().
+	 */
+	if (le64_to_cpu(di->i_blkno) == OCFS2_SB(sb)->bitmap_blkno &&
+	    !(di->i_flags & cpu_to_le32(OCFS2_BITMAP_FL))) {
+		rc = ocfs2_error(sb,
+				 "Invalid dinode #%llu: i_blkno matches bitmap but BITMAP flag not set\n",
+				 (unsigned long long)bh->b_blocknr);
+		goto bail;
+	} else if (di->i_flags & cpu_to_le32(OCFS2_BITMAP_FL) &&
+		   le64_to_cpu(di->i_blkno) != OCFS2_SB(sb)->bitmap_blkno) {
+		rc = ocfs2_error(sb,
+				 "Invalid dinode #%llu: BITMAP flag set but i_blkno does not match bitmap\n",
+				 (unsigned long long)bh->b_blocknr);
+		goto bail;
+	}
+
 	rc = 0;
 
 bail:
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-01-24  4:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-03 22:53 [syzbot] [ocfs2?] kernel BUG in ocfs2_block_group_search syzbot
2026-01-04  1:15 ` Forwarded: [PATCH] ocfs2: validate allocator type to prevent BUG_ON " syzbot
2026-01-24  2:39 ` Forwarded: [PATCH] ocfs2: validate i_blkno and BITMAP_FL consistency in ocfs2_validate_inode_block syzbot
2026-01-24  4:14 ` syzbot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.