kernel BUG in ext4_mb_load_buddy_gfp

9 views
Skip to first unread message

syzbot

unread,
Nov 27, 2022, 1:38:41 AM11/27/22
to syzkaller-a...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 4ec71a9ec769 ANDROID: cpu/hotplug: call perf event through..
git tree: android13-5.15-lts
console+strace: https://syzkaller.appspot.com/x/log.txt?x=167f9175880000
kernel config: https://syzkaller.appspot.com/x/.config?x=5f64a7340a9acccc
dashboard link: https://syzkaller.appspot.com/bug?extid=6be2b977c89f79b6b153
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=1000b3c5880000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15500403880000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/93b972e96678/disk-4ec71a9e.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/10d3ac64bada/vmlinux-4ec71a9e.xz
kernel image: https://storage.googleapis.com/syzbot-assets/70ae0159c6d1/bzImage-4ec71a9e.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/054e958b80a1/mount_0.gz

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

kernel BUG at fs/ext4/ext4.h:3354!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN
CPU: 0 PID: 422 Comm: syz-executor339 Not tainted 5.15.74-syzkaller-00001-g4ec71a9ec769 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
RIP: 0010:ext4_get_group_info fs/ext4/ext4.h:3354 [inline]
RIP: 0010:ext4_mb_load_buddy_gfp+0xe9d/0xeb0 fs/ext4/mballoc.c:1498
Code: 99 ed c1 ff e9 47 f4 ff ff e8 5f a0 7f ff 48 c7 c7 c0 c3 a9 86 48 89 de 4c 89 ea e8 ad 8e 92 00 e9 a1 f2 ff ff e8 43 a0 7f ff <0f> 0b e8 3c a0 7f ff 0f 0b e8 35 a0 7f ff 0f 0b 0f 1f 00 55 48 89
RSP: 0018:ffffc9000044f320 EFLAGS: 00010293
RAX: ffffffff81f1f14d RBX: 0000000000000001 RCX: ffff888106194f00
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000001
RBP: ffffc9000044f3b0 R08: ffffffff81f1e3a4 R09: ffffc9000044f440
R10: fffff52000089e8f R11: 1ffff92000089e88 R12: ffff888100a553c8
R13: dffffc0000000000 R14: 0000000000000001 R15: ffff888105f9a000
FS: 000055555675b300(0000) GS:ffff8881f7000000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055c4f7cde3e8 CR3: 000000011c064000 CR4: 00000000003506b0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
ext4_mb_load_buddy fs/ext4/mballoc.c:1620 [inline]
ext4_mballoc_query_range+0xb8/0x7b0 fs/ext4/mballoc.c:6560
ext4_getfsmap_datadev+0x1c8a/0x28c0 fs/ext4/fsmap.c:537
ext4_getfsmap+0xcff/0x1040 fs/ext4/fsmap.c:708
ext4_ioc_getfsmap fs/ext4/ioctl.c:660 [inline]
__ext4_ioctl fs/ext4/ioctl.c:862 [inline]
ext4_ioctl+0x3020/0x50e0 fs/ext4/ioctl.c:1276
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:874 [inline]
__se_sys_ioctl+0x115/0x190 fs/ioctl.c:860
__x64_sys_ioctl+0x7b/0x90 fs/ioctl.c:860
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x44/0xd0 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x61/0xcb
RIP: 0033:0x7f8d2372e3e9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 e1 14 00 00 90 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 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffcae7c2578 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00000000000f4240 RCX: 00007f8d2372e3e9
RDX: 0000000020000200 RSI: 00000000c0c0583b RDI: 0000000000000004
RBP: 0000000000000000 R08: 000000000000000d R09: 000000000000000d
R10: 00000000000003f1 R11: 0000000000000246 R12: 00007f8d236ed5c0
R13: 00007ffcae7c25a0 R14: 00007ffcae7c258c R15: 00007ffcae7c2590
</TASK>
Modules linked in:
---[ end trace 8787224b2c022cc2 ]---
RIP: 0010:ext4_get_group_info fs/ext4/ext4.h:3354 [inline]
RIP: 0010:ext4_mb_load_buddy_gfp+0xe9d/0xeb0 fs/ext4/mballoc.c:1498
Code: 99 ed c1 ff e9 47 f4 ff ff e8 5f a0 7f ff 48 c7 c7 c0 c3 a9 86 48 89 de 4c 89 ea e8 ad 8e 92 00 e9 a1 f2 ff ff e8 43 a0 7f ff <0f> 0b e8 3c a0 7f ff 0f 0b e8 35 a0 7f ff 0f 0b 0f 1f 00 55 48 89
RSP: 0018:ffffc9000044f320 EFLAGS: 00010293

RAX: ffffffff81f1f14d RBX: 0000000000000001 RCX: ffff888106194f00
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000001
RBP: ffffc9000044f3b0 R08: ffffffff81f1e3a4 R09: ffffc9000044f440
R10: fffff52000089e8f R11: 1ffff92000089e88 R12: ffff888100a553c8
R13: dffffc0000000000 R14: 0000000000000001 R15: ffff888105f9a000
FS: 000055555675b300(0000) GS:ffff8881f7000000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055c4f7cde3e8 CR3: 000000011c064000 CR4: 00000000003506b0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400


---
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 syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches

Jun Nie

unread,
Dec 21, 2022, 4:47:00 AM12/21/22
to syzkaller-android-bugs
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
index 8ff4b9192a9f..177ef6bd635a 100644
--- a/fs/ext4/balloc.c
+++ b/fs/ext4/balloc.c
@@ -56,7 +56,8 @@ void ext4_get_group_no_and_offset(struct super_block *sb, ext4_fsblk_t blocknr,
        struct ext4_super_block *es = EXT4_SB(sb)->s_es;
        ext4_grpblk_t offset;
 
-       blocknr = blocknr - le32_to_cpu(es->s_first_data_block);
+       blocknr = blocknr > le32_to_cpu(es->s_first_data_block) ?
+               blocknr - le32_to_cpu(es->s_first_data_block) : 0;
        offset = do_div(blocknr, EXT4_BLOCKS_PER_GROUP(sb)) >>
                EXT4_SB(sb)->s_cluster_bits;
        if (offsetp)

syzbot

unread,
Dec 21, 2022, 9:42:17 AM12/21/22
to jun...@linaro.org, syzkaller-a...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+6be2b9...@syzkaller.appspotmail.com

Tested on:

commit: b6bb9676 Merge tag 'm68knommu-for-v6.2' of git://git.k..
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=15a3fd8b880000
kernel config: https://syzkaller.appspot.com/x/.config?x=50ae10bbe87733d7
dashboard link: https://syzkaller.appspot.com/bug?extid=6be2b977c89f79b6b153
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=11e4da37880000

Note: testing is done by a robot and is best-effort only.

Jun Nie

unread,
Dec 27, 2022, 4:02:01 AM12/27/22
to syzbot, syzkaller-a...@googlegroups.com
0001-ext4-reject-1k-block-filesystem-on-the-first-block-o.patch

syzbot

unread,
Dec 27, 2022, 9:18:21 AM12/27/22
to jun...@linaro.org, syzkaller-a...@googlegroups.com
Hello,

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

------------[ cut here ]------------
kernel BUG at fs/ext4/ext4.h:3331!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN
CPU: 1 PID: 414 Comm: syz-executor.5 Not tainted 6.2.0-rc1-syzkaller-dirty #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
RIP: 0010:ext4_get_group_info fs/ext4/ext4.h:3331 [inline]
RIP: 0010:ext4_mb_load_buddy_gfp+0xe9d/0xeb0 fs/ext4/mballoc.c:1448
Code: 69 0d c6 ff e9 47 f4 ff ff e8 0f 32 7e ff 48 c7 c7 a0 e1 6a 86 48 89 de 4c 89 ea e8 9d 6f b6 00 e9 a1 f2 ff ff e8 f3 31 7e ff <0f> 0b e8 ec 31 7e ff 0f 0b e8 e5 31 7e ff 0f 0b 0f 1f 00 55 48 89
RSP: 0018:ffffc90002fff260 EFLAGS: 00010293
RAX: ffffffff81f7f48d RBX: 0000000000000001 RCX: ffff88811344f000
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000001
RBP: ffffc90002fff2f0 R08: ffffffff81f7e6e4 R09: ffffc90002fff380
R10: fffff520005ffe77 R11: 1ffff920005ffe70 R12: ffff888118491398
R13: dffffc0000000000 R14: 0000000000000001 R15: ffff888118024000
FS: 00007f9d868c1700(0000) GS:ffff8881f7100000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007ffcb7801ec8 CR3: 00000001236e1000 CR4: 00000000003506a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
ext4_mb_load_buddy fs/ext4/mballoc.c:1570 [inline]
ext4_mballoc_query_range+0xb8/0x7a0 fs/ext4/mballoc.c:6573
ext4_getfsmap_datadev+0x1c8a/0x28c0 fs/ext4/fsmap.c:537
ext4_getfsmap+0xd9e/0x1110 fs/ext4/fsmap.c:710
ext4_ioc_getfsmap fs/ext4/ioctl.c:902 [inline]
__ext4_ioctl fs/ext4/ioctl.c:1226 [inline]
ext4_ioctl+0x35eb/0x5140 fs/ext4/ioctl.c:1610
vfs_ioctl fs/ioctl.c:51 [inline]
__do_sys_ioctl fs/ioctl.c:870 [inline]
__se_sys_ioctl+0x115/0x190 fs/ioctl.c:856
__x64_sys_ioctl+0x7b/0x90 fs/ioctl.c:856
do_syscall_x64 arch/x86/entry/common.c:50 [inline]
do_syscall_64+0x2f/0x50 arch/x86/entry/common.c:80
entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f9d85a8c0d9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 f1 19 00 00 90 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f9d868c1168 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 00007f9d85babf80 RCX: 00007f9d85a8c0d9
RDX: 0000000020000200 RSI: 00000000c0c0583b RDI: 0000000000000004
RBP: 00007f9d85ae7ae9 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffee411c46f R14: 00007f9d868c1300 R15: 0000000000022000
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:ext4_get_group_info fs/ext4/ext4.h:3331 [inline]
RIP: 0010:ext4_mb_load_buddy_gfp+0xe9d/0xeb0 fs/ext4/mballoc.c:1448
Code: 69 0d c6 ff e9 47 f4 ff ff e8 0f 32 7e ff 48 c7 c7 a0 e1 6a 86 48 89 de 4c 89 ea e8 9d 6f b6 00 e9 a1 f2 ff ff e8 f3 31 7e ff <0f> 0b e8 ec 31 7e ff 0f 0b e8 e5 31 7e ff 0f 0b 0f 1f 00 55 48 89
RSP: 0018:ffffc90002fff260 EFLAGS: 00010293
RAX: ffffffff81f7f48d RBX: 0000000000000001 RCX: ffff88811344f000
RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000001
RBP: ffffc90002fff2f0 R08: ffffffff81f7e6e4 R09: ffffc90002fff380
R10: fffff520005ffe77 R11: 1ffff920005ffe70 R12: ffff888118491398
R13: dffffc0000000000 R14: 0000000000000001 R15: ffff888118024000
FS: 00007f9d868c1700(0000) GS:ffff8881f7100000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007ffcb78036e8 CR3: 00000001236e1000 CR4: 00000000003506a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400


Tested on:

commit: 1b929c02 Linux 6.2-rc1
console output: https://syzkaller.appspot.com/x/log.txt?x=13c2544c480000
kernel config: https://syzkaller.appspot.com/x/.config?x=727ecac914cdec33
dashboard link: https://syzkaller.appspot.com/bug?extid=6be2b977c89f79b6b153
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=134a05f8480000

Jun Nie

unread,
Dec 27, 2022, 10:14:00 PM12/27/22
to syzbot, syzkaller-a...@googlegroups.com
0001-ext4-reject-1k-block-filesystem-on-the-first-block-o.patch

syzbot

unread,
Dec 28, 2022, 4:11:20 AM12/28/22
to jun...@linaro.org, syzkaller-a...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+6be2b9...@syzkaller.appspotmail.com

Tested on:

commit: 1b929c02 Linux 6.2-rc1
git tree: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=15507974480000
kernel config: https://syzkaller.appspot.com/x/.config?x=727ecac914cdec33
dashboard link: https://syzkaller.appspot.com/bug?extid=6be2b977c89f79b6b153
compiler: Debian clang version 13.0.1-++20220126092033+75e33f71c2da-1~exp1~20220126212112.63, GNU ld (GNU Binutils for Debian) 2.35.2
patch: https://syzkaller.appspot.com/x/patch.diff?x=126cdc54480000
Reply all
Reply to author
Forward
0 new messages