Syzbot testing for ocfs2: Fix kernel BUG in ocfs2_write_block

Prithvi Tambewagh posted 1 patch 1 week, 5 days ago
There is a newer version of this series
fs/ocfs2/slot_map.c | 10 ++++++++++
1 file changed, 10 insertions(+)
Syzbot testing for ocfs2: Fix kernel BUG in ocfs2_write_block
Posted by Prithvi Tambewagh 1 week, 5 days ago
#syz test git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 24172e0d79900908cf5ebf366600616d29c9b417

Signed-off-by: Prithvi Tambewagh <activprithvi@gmail.com>
---
 fs/ocfs2/slot_map.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/fs/ocfs2/slot_map.c b/fs/ocfs2/slot_map.c
index e544c704b583..de793a83555c 100644
--- a/fs/ocfs2/slot_map.c
+++ b/fs/ocfs2/slot_map.c
@@ -193,6 +193,16 @@ static int ocfs2_update_disk_slot(struct ocfs2_super *osb,
 	else
 		ocfs2_update_disk_slot_old(si, slot_num, &bh);
 	spin_unlock(&osb->osb_lock);
+	if (bh->b_blocknr < OCFS2_SUPER_BLOCK_BLKNO) {
+		status = ocfs2_error(osb->sb,
+				     "Invalid Buffer Head Block Number : %llu, "
+				     "Should be >= %d",
+				     le16_to_cpu(bh->b_blocknr),
+				     le16_to_cpu((int)OCFS2_SUPER_BLOCK_BLKNO));
+		if(!status) {
+			return -EIO;
+		}
+	}
 
 	status = ocfs2_write_block(osb, bh, INODE_CACHE(si->si_inode));
 	if (status < 0)

base-commit: 24172e0d79900908cf5ebf366600616d29c9b417
-- 
2.43.0
Re: [syzbot] [ocfs2?] kernel BUG in ocfs2_write_block
Posted by syzbot 1 week, 5 days ago
Hello,

syzbot has tested the proposed patch but the reproducer is still triggering an issue:
kernel BUG in ocfs2_write_block

WARNING: The mand mount option has been deprecated and
         and is ignored by this kernel. Remove the mand
         option from the mount to silence this warning.
=======================================================
On-disk corruption discovered. Please run fsck.ocfs2 once the filesystem is unmounted.
OCFS2: File system is now read-only.
------------[ cut here ]------------
kernel BUG at fs/ocfs2/buffer_head_io.c:45!
Oops: invalid opcode: 0000 [#1] SMP KASAN PTI
CPU: 0 UID: 0 PID: 6601 Comm: syz.0.17 Not tainted syzkaller #0 PREEMPT_{RT,(full)} 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/25/2025
RIP: 0010:ocfs2_write_block+0x5d2/0x640 fs/ocfs2/buffer_head_io.c:45
Code: 00 00 fc ff df 80 3c 08 00 74 08 4c 89 ff e8 45 37 8b fe 49 8b 3f 4c 89 ee 48 8b 14 24 e8 36 88 0f 00 eb 1f e8 8f 78 29 fe 90 <0f> 0b e8 87 78 29 fe 90 0f 0b e8 7f 78 29 fe e9 ce fa ff ff e8 75
RSP: 0018:ffffc90004e4ee20 EFLAGS: 00010293
RAX: ffffffff839534d1 RBX: 1ffff1100444ea03 RCX: ffff888024ae8000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: ffffc90004e4eef0 R08: 0000000000000000 R09: 0000000000000000
R10: dffffc0000000000 R11: fffffbfff1dac76f R12: 0000000000000000
R13: dffffc0000000000 R14: ffff888022275000 R15: 0000000000000001
FS:  00007fbd0a5066c0(0000) GS:ffff888126df7000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fbd0ae829e0 CR3: 0000000020b78000 CR4: 00000000003526f0
Call Trace:
 <TASK>
 ocfs2_update_disk_slot+0x6f8/0x9d0 fs/ocfs2/slot_map.c:207
 ocfs2_find_slot+0x6bb/0xc30 fs/ocfs2/slot_map.c:492
 ocfs2_mount_volume fs/ocfs2/super.c:1749 [inline]
 ocfs2_fill_super+0x3833/0x65f0 fs/ocfs2/super.c:1083
 get_tree_bdev_flags+0x40e/0x4d0 fs/super.c:1691
 vfs_get_tree+0x92/0x2b0 fs/super.c:1751
 fc_mount fs/namespace.c:1208 [inline]
 do_new_mount_fc fs/namespace.c:3651 [inline]
 do_new_mount+0x302/0xa10 fs/namespace.c:3727
 do_mount fs/namespace.c:4050 [inline]
 __do_sys_mount fs/namespace.c:4238 [inline]
 __se_sys_mount+0x313/0x410 fs/namespace.c:4215
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0xfa/0xfa0 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fbd0aea0e6a
Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 de 1a 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 49 89 ca b8 a5 00 00 00 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:00007fbd0a505e68 EFLAGS: 00000246 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007fbd0a505ef0 RCX: 00007fbd0aea0e6a
RDX: 0000200000004440 RSI: 0000200000000040 RDI: 00007fbd0a505eb0
RBP: 0000200000004440 R08: 00007fbd0a505ef0 R09: 00000000000008c0
R10: 00000000000008c0 R11: 0000000000000246 R12: 0000200000000040
R13: 00007fbd0a505eb0 R14: 0000000000004440 R15: 0000200000000280
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:ocfs2_write_block+0x5d2/0x640 fs/ocfs2/buffer_head_io.c:45
Code: 00 00 fc ff df 80 3c 08 00 74 08 4c 89 ff e8 45 37 8b fe 49 8b 3f 4c 89 ee 48 8b 14 24 e8 36 88 0f 00 eb 1f e8 8f 78 29 fe 90 <0f> 0b e8 87 78 29 fe 90 0f 0b e8 7f 78 29 fe e9 ce fa ff ff e8 75
RSP: 0018:ffffc90004e4ee20 EFLAGS: 00010293
RAX: ffffffff839534d1 RBX: 1ffff1100444ea03 RCX: ffff888024ae8000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: ffffc90004e4eef0 R08: 0000000000000000 R09: 0000000000000000
R10: dffffc0000000000 R11: fffffbfff1dac76f R12: 0000000000000000
R13: dffffc0000000000 R14: ffff888022275000 R15: 0000000000000001
FS:  00007fbd0a5066c0(0000) GS:ffff888126df7000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fbd0ae829e0 CR3: 0000000020b78000 CR4: 00000000003526f0


Tested on:

commit:         24172e0d Merge tag 'arm64-fixes' of git://git.kernel.o..
git tree:       git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=11510eb4580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=41ad820f608cb833
dashboard link: https://syzkaller.appspot.com/bug?extid=c818e5c4559444f88aa0
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=13d2421a580000