Hello.
We are Ubisectech Sirius Team, the vulnerability lab of China ValiantSec. Recently, our team has discovered a issue in Linux kernel 6.7. Attached to the email were a PoC file of the issue.
Stack dump:
bcachefs (loop0): error validating btree node on loop0 at btree extents level 0/0
u64s 11 type btree_ptr_v2 SPOS_MAX len 0 ver 0: seq 83426fcb67886cbe written 16 min_key POS_MIN durability: 1 ptr: 0:27:0 gen 0
node offset 0 bset u64s 0: unknown checksum type 4, fixing
general protection fault, probably for non-canonical address 0xdffffc0000000004: 0000 [#1] PREEMPT SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000020-0x0000000000000027]
CPU: 0 PID: 25892 Comm: syz-executor.0 Not tainted 6.7.0 #2
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
RIP: 0010:crypto_skcipher_alg include/crypto/skcipher.h:387 [inline]
RIP: 0010:crypto_skcipher_encrypt+0x48/0x170 crypto/skcipher.c:656
Code: 48 89 fa 48 c1 ea 03 80 3c 02 00 0f 85 17 01 00 00 48 b8 00 00 00 00 00 fc ff df 48 8b 5d 40 48 8d 7b 18 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 08 01 00 00 48 8d 7b 04 4c 8b 63 18 48 b8 00 00
RSP: 0018:ffffc90002d46388 EFLAGS: 00010202
RAX: dffffc0000000000 RBX: 0000000000000008 RCX: ffffc9000e04a000
RDX: 0000000000000004 RSI: ffffffff84162b50 RDI: 0000000000000020
RBP: ffffc90002d463f8 R08: 0000000000000020 R09: 0000000000000001
R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000008
R13: 0000000000000020 R14: ffff88801133d600 R15: ffffc90002d467d8
FS: 00007fdd0174b640(0000) GS:ffff88802c600000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000001b2df21000 CR3: 0000000057314000 CR4: 0000000000750ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
PKRU: 55555554
Call Trace:
<TASK>
do_encrypt_sg+0xbc/0x150 fs/bcachefs/checksum.c:107
do_encrypt+0x27d/0x430 fs/bcachefs/checksum.c:149
gen_poly_key.isra.0+0x144/0x310 fs/bcachefs/checksum.c:190
bch2_checksum+0x1bc/0x2b0 fs/bcachefs/checksum.c:226
bch2_btree_node_read_done+0x75b/0x45a0 fs/bcachefs/btree_io.c:1003
btree_node_read_work+0x77f/0x10e0 fs/bcachefs/btree_io.c:1262
bch2_btree_node_read+0xef3/0x1460 fs/bcachefs/btree_io.c:1641
__bch2_btree_root_read fs/bcachefs/btree_io.c:1680 [inline]
bch2_btree_root_read+0x2bc/0x670 fs/bcachefs/btree_io.c:1704
read_btree_roots fs/bcachefs/recovery.c:384 [inline]
bch2_fs_recovery+0x28b0/0x52d0 fs/bcachefs/recovery.c:914
bch2_fs_start+0x365/0x5e0 fs/bcachefs/super.c:978
bch2_fs_open+0x1ac9/0x3890 fs/bcachefs/super.c:1968
bch2_mount+0x538/0x13c0 fs/bcachefs/fs.c:1863
legacy_get_tree+0x109/0x220 fs/fs_context.c:662
vfs_get_tree+0x93/0x380 fs/super.c:1771
do_new_mount fs/namespace.c:3337 [inline]
path_mount+0x679/0x1e40 fs/namespace.c:3664
do_mount fs/namespace.c:3677 [inline]
__do_sys_mount fs/namespace.c:3886 [inline]
__se_sys_mount fs/namespace.c:3863 [inline]
__x64_sys_mount+0x287/0x310 fs/namespace.c:3863
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0x43/0x120 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x6f/0x77
RIP: 0033:0x7fdd00a91b3e
Code: 48 c7 c0 ff ff ff ff eb aa e8 be 0d 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 f3 0f 1e fa 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fdd0174ae38 EFLAGS: 00000202 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00000000000119fc RCX: 00007fdd00a91b3e
RDX: 0000000020011a00 RSI: 0000000020000040 RDI: 00007fdd0174ae90
RBP: 00007fdd0174aed0 R08: 00007fdd0174aed0 R09: 0000000000000001
R10: 0000000000000001 R11: 0000000000000202 R12: 0000000020011a00
R13: 0000000020000040 R14: 00007fdd0174ae90 R15: 0000000020000100
</TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:crypto_skcipher_alg include/crypto/skcipher.h:387 [inline]
RIP: 0010:crypto_skcipher_encrypt+0x48/0x170 crypto/skcipher.c:656
Code: 48 89 fa 48 c1 ea 03 80 3c 02 00 0f 85 17 01 00 00 48 b8 00 00 00 00 00 fc ff df 48 8b 5d 40 48 8d 7b 18 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 08 01 00 00 48 8d 7b 04 4c 8b 63 18 48 b8 00 00
RSP: 0018:ffffc90002d46388 EFLAGS: 00010202
RAX: dffffc0000000000 RBX: 0000000000000008 RCX: ffffc9000e04a000
RDX: 0000000000000004 RSI: ffffffff84162b50 RDI: 0000000000000020
RBP: ffffc90002d463f8 R08: 0000000000000020 R09: 0000000000000001
R10: 0000000000000001 R11: 0000000000000000 R12: 0000000000000008
R13: 0000000000000020 R14: ffff88801133d600 R15: ffffc90002d467d8
FS: 00007fdd0174b640(0000) GS:ffff88802c600000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055e4cd278120 CR3: 0000000057314000 CR4: 0000000000750ef0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
PKRU: 55555554
----------------
Code disassembly (best guess):
0: 48 89 fa mov %rdi,%rdx
3: 48 c1 ea 03 shr $0x3,%rdx
7: 80 3c 02 00 cmpb $0x0,(%rdx,%rax,1)
b: 0f 85 17 01 00 00 jne 0x128
11: 48 b8 00 00 00 00 00 movabs $0xdffffc0000000000,%rax
18: fc ff df
1b: 48 8b 5d 40 mov 0x40(%rbp),%rbx
1f: 48 8d 7b 18 lea 0x18(%rbx),%rdi
23: 48 89 fa mov %rdi,%rdx
26: 48 c1 ea 03 shr $0x3,%rdx
* 2a: 80 3c 02 00 cmpb $0x0,(%rdx,%rax,1) <-- trapping instruction
2e: 0f 85 08 01 00 00 jne 0x13c
34: 48 8d 7b 04 lea 0x4(%rbx),%rdi
38: 4c 8b 63 18 mov 0x18(%rbx),%r12
3c: 48 rex.W
3d: b8 .byte 0xb8
Thank you for taking the time to read this email and we look forward to working with you further.