[syzbot] [bcachefs?] general protection fault in __copy_super

5 views
Skip to first unread message

syzbot

unread,
Sep 21, 2024, 6:53:23 AMSep 21
to kent.ov...@linux.dev, linux-b...@vger.kernel.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: a430d95c5efa Merge tag 'lsm-pr-20240911' of git://git.kern..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=124e6a77980000
kernel config: https://syzkaller.appspot.com/x/.config?x=1653f803fffa3848
dashboard link: https://syzkaller.appspot.com/bug?extid=18a5c5e8a9c856944876
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=129f68a9980000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1539e29f980000

Downloadable assets:
disk image (non-bootable): https://storage.googleapis.com/syzbot-assets/7bc7510fe41f/non_bootable_disk-a430d95c.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/66a65abf87c4/vmlinux-a430d95c.xz
kernel image: https://storage.googleapis.com/syzbot-assets/09c88015f9aa/bzImage-a430d95c.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/97dbec0f4717/mount_0.gz

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

bcachefs (/dev/loop0): error reading default superblock: checksum error, type crc32c_nonzero: got 151109cf should be 29d2fb78
bcachefs (/dev/loop0): error reading superblock: checksum error, type crc32c_nonzero: got 151109cf should be 29d2fb78
Oops: general protection fault, probably for non-canonical address 0xdffffc0000000002: 0000 [#1] PREEMPT SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000010-0x0000000000000017]
CPU: 0 UID: 0 PID: 5098 Comm: syz-executor282 Not tainted 6.11.0-syzkaller-02574-ga430d95c5efa #0
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2~bpo12+1 04/01/2014
RIP: 0010:__copy_super+0x59/0xe70 fs/bcachefs/super-io.c:552
Code: 44 24 10 80 3c 18 00 74 12 4c 89 f7 e8 90 71 b5 fd 48 ba 00 00 00 00 00 fc ff df 4d 8b 3e 49 8d 5c 24 10 48 89 d8 48 c1 e8 03 <0f> b6 04 10 84 c0 0f 85 2e 0c 00 00 0f b7 2b 49 8d 5f 10 48 89 d8
RSP: 0018:ffffc90002f8f2f0 EFLAGS: 00010202
RAX: 0000000000000002 RBX: 0000000000000010 RCX: ffff888000ebc880
RDX: dffffc0000000000 RSI: 0000000000000000 RDI: ffff888044d807d8
RBP: 0000000000000000 R08: ffffffff84457905 R09: 00000000ffffffff
R10: dffffc0000000000 R11: fffffbfff2845f24 R12: 0000000000000000
R13: ffff888044d80000 R14: ffff888044d807d8 R15: ffff88803fb32800
FS: 00005555893e4380(0000) GS:ffff88801fe00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000555cf75a4000 CR3: 0000000011efe000 CR4: 0000000000350ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
bch2_sb_to_fs+0xab/0x150 fs/bcachefs/super-io.c:610
bch2_fs_alloc+0xd5c/0x20b0 fs/bcachefs/super.c:828
bch2_fs_open+0x8cc/0xdf0 fs/bcachefs/super.c:2115
bch2_fs_get_tree+0x731/0x1700 fs/bcachefs/fs.c:1943
vfs_get_tree+0x90/0x2b0 fs/super.c:1800
do_new_mount+0x2be/0xb40 fs/namespace.c:3507
do_mount fs/namespace.c:3847 [inline]
__do_sys_mount fs/namespace.c:4055 [inline]
__se_sys_mount+0x2d6/0x3c0 fs/namespace.c:4032
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f2b30c1706a
Code: d8 64 89 02 48 c7 c0 ff ff ff ff eb a6 e8 5e 04 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffe211af6b8 EFLAGS: 00000282 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007ffe211af6d0 RCX: 00007f2b30c1706a
RDX: 0000000020000240 RSI: 0000000020005dc0 RDI: 00007ffe211af6d0
RBP: 0000000000000004 R08: 00007ffe211af710 R09: 0000000000005da0
R10: 0000000001000000 R11: 0000000000000282 R12: 0000000001000000
R13: 00007ffe211af710 R14: 0000000000000003 R15: 0000000001000000
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:__copy_super+0x59/0xe70 fs/bcachefs/super-io.c:552
Code: 44 24 10 80 3c 18 00 74 12 4c 89 f7 e8 90 71 b5 fd 48 ba 00 00 00 00 00 fc ff df 4d 8b 3e 49 8d 5c 24 10 48 89 d8 48 c1 e8 03 <0f> b6 04 10 84 c0 0f 85 2e 0c 00 00 0f b7 2b 49 8d 5f 10 48 89 d8
RSP: 0018:ffffc90002f8f2f0 EFLAGS: 00010202
RAX: 0000000000000002 RBX: 0000000000000010 RCX: ffff888000ebc880
RDX: dffffc0000000000 RSI: 0000000000000000 RDI: ffff888044d807d8
RBP: 0000000000000000 R08: ffffffff84457905 R09: 00000000ffffffff
R10: dffffc0000000000 R11: fffffbfff2845f24 R12: 0000000000000000
R13: ffff888044d80000 R14: ffff888044d807d8 R15: ffff88803fb32800
FS: 00005555893e4380(0000) GS:ffff88801fe00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000555cf75a4000 CR3: 0000000011efe000 CR4: 0000000000350ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
0: 44 24 10 rex.R and $0x10,%al
3: 80 3c 18 00 cmpb $0x0,(%rax,%rbx,1)
7: 74 12 je 0x1b
9: 4c 89 f7 mov %r14,%rdi
c: e8 90 71 b5 fd call 0xfdb571a1
11: 48 ba 00 00 00 00 00 movabs $0xdffffc0000000000,%rdx
18: fc ff df
1b: 4d 8b 3e mov (%r14),%r15
1e: 49 8d 5c 24 10 lea 0x10(%r12),%rbx
23: 48 89 d8 mov %rbx,%rax
26: 48 c1 e8 03 shr $0x3,%rax
* 2a: 0f b6 04 10 movzbl (%rax,%rdx,1),%eax <-- trapping instruction
2e: 84 c0 test %al,%al
30: 0f 85 2e 0c 00 00 jne 0xc64
36: 0f b7 2b movzwl (%rbx),%ebp
39: 49 8d 5f 10 lea 0x10(%r15),%rbx
3d: 48 89 d8 mov %rbx,%rax


---
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.

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

Diogo Jahchan Koike

unread,
Sep 23, 2024, 5:06:49 PMSep 23
to syzbot+18a5c5...@syzkaller.appspotmail.com, syzkall...@googlegroups.com, Diogo Jahchan Koike
#syz test

__bch2_read_super may return no error code when a corrupt backup
superblock has matching offsets with default opts, the superblock
is freed and is later dereferenced causing a fault. Assign EINVALID
when checking sb offsets.

Signed-off-by: Diogo Jahchan Koike <djahch...@gmail.com>
---
fs/bcachefs/super-io.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/bcachefs/super-io.c b/fs/bcachefs/super-io.c
index c8c2ccbdfbb5..fbca0bd302db 100644
--- a/fs/bcachefs/super-io.c
+++ b/fs/bcachefs/super-io.c
@@ -796,8 +796,10 @@ static int __bch2_read_super(const char *path, struct bch_opts *opts,
i < layout.sb_offset + layout.nr_superblocks; i++) {
offset = le64_to_cpu(*i);

- if (offset == opt_get(*opts, sb))
+ if (offset == opt_get(*opts, sb)) {
+ ret = -BCH_ERR_invalid;
continue;
+ }

ret = read_one_super(sb, offset, &err);
if (!ret)
--
2.43.0

syzbot

unread,
Sep 23, 2024, 5:46:04 PMSep 23
to djahch...@gmail.com, linux-...@vger.kernel.org, syzkall...@googlegroups.com
Hello,

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

Reported-by: syzbot+18a5c5...@syzkaller.appspotmail.com
Tested-by: syzbot+18a5c5...@syzkaller.appspotmail.com

Tested on:

commit: 18ba6034 Merge tag 'nfsd-6.12' of git://git.kernel.org..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=110d0c80580000
kernel config: https://syzkaller.appspot.com/x/.config?x=a89411f53c579df0
dashboard link: https://syzkaller.appspot.com/bug?extid=18a5c5e8a9c856944876
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=166aca27980000

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

syzbot

unread,
Sep 24, 2024, 2:55:06 AMSep 24
to bfo...@redhat.com, djahch...@gmail.com, kent.ov...@linux.dev, linux-b...@vger.kernel.org, linux-...@vger.kernel.org, syzkall...@googlegroups.com
syzbot has bisected this issue to:

commit 03ef80b469d5d83530ce1ce15be78a40e5300f9b
Author: Kent Overstreet <kent.ov...@linux.dev>
Date: Sat Sep 23 22:41:51 2023 +0000

bcachefs: Ignore unknown mount options

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=1057d107980000
start commit: f8eb5bd9a818 mm: fix build on 32-bit targets without MAX_P..
git tree: upstream
final oops: https://syzkaller.appspot.com/x/report.txt?x=1257d107980000
console output: https://syzkaller.appspot.com/x/log.txt?x=1457d107980000
kernel config: https://syzkaller.appspot.com/x/.config?x=74ffdb3b3fad1a43
dashboard link: https://syzkaller.appspot.com/bug?extid=18a5c5e8a9c856944876
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=174cca27980000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=15a3619f980000

Reported-by: syzbot+18a5c5...@syzkaller.appspotmail.com
Fixes: 03ef80b469d5 ("bcachefs: Ignore unknown mount options")

For information about bisection process see: https://goo.gl/tpsmEJ#bisection
Reply all
Reply to author
Forward
0 new messages