kernel BUG in page_try_dup_anon_rmap

From: Wei Chen
Date: Mon Oct 10 2022 - 08:26:41 EST


Dear Linux Developer,

Recently when using our tool to fuzz kernel, the following crash was triggered:

HEAD commit: 03c765b0e3b4 Linux 5.19-rc4
git tree: upstream
compiler: clang 12.0.0
console output:
https://drive.google.com/file/d/16ht-2pDp_nU_nXhobMfHaQraVt4qfzBK/view?usp=sharing
kernel config: https://drive.google.com/file/d/1lNGU17X6Ui1NDLE4XCRu3I6f9lzhCBcH/view?usp=sharing

Unfortunately, I don't have any reproducer for this crash yet.

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: Wei Chen <harperchen1110@xxxxxxxxx>

kernel BUG at include/linux/mm.h:1585!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN
CPU: 0 PID: 20332 Comm: syz-executor Not tainted 5.19.0-rc4 #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
1.13.0-1ubuntu1.1 04/01/2014
RIP: 0010:page_try_dup_anon_rmap+0x927/0x1120
Code: e6 ff 0f 00 00 31 ff e8 87 75 b2 ff 4c 89 e0 48 25 ff 0f 00 00
0f 84 0e 01 00 00 e8 c3 70 b2 ff e9 43 03 00 00 e8 b9 70 b2 ff <0f> 0b
e8 b2 70 b2 ff 4c 89 e7 48 c7 c6 80 96 9e 8a e8 03 91 ee ff
RSP: 0018:ffffc900088e7368 EFLAGS: 00010287
RAX: ffffffff81d29967 RBX: 0000000000000000 RCX: 0000000000040000
RDX: ffffc900084b9000 RSI: 00000000000023c4 RDI: 00000000000023c5
RBP: ffff88802e3a0670 R08: ffffffff81d29420 R09: fffff9400011d001
R10: fffff9400011d001 R11: 0000000000000000 R12: ffffea00008e8000
R13: dffffc0000000000 R14: ffff88802e3a0670 R15: 1ffff11005c740ce
FS: 00007fa374806700(0000) GS:ffff888063c00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fa3737b8000 CR3: 000000002f26f000 CR4: 0000000000750ef0
DR0: 0000000020000080 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
PKRU: 55555554
Call Trace:
<TASK>
copy_hugetlb_page_range+0xc9d/0x1cc0
copy_page_range+0x424/0x1b40
dup_mmap+0xa72/0xf80
dup_mm+0x8c/0x310
copy_process+0x2b3b/0x60d0
kernel_clone+0x21a/0x7d0
__do_sys_fork+0x9e/0xf0
do_syscall_64+0x3d/0x90
entry_SYSCALL_64_after_hwframe+0x46/0xb0
RIP: 0033:0x7fa373695c4d
Code: 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 f3 0f 1e fa 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 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fa374805c58 EFLAGS: 00000246 ORIG_RAX: 0000000000000039
RAX: ffffffffffffffda RBX: 00007fa3737bc0a0 RCX: 00007fa373695c4d
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
RBP: 00007fa37370ed80 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fa3737bc0a0
R13: 00007ffc0a3c127f R14: 00007ffc0a3c1420 R15: 00007fa374805dc0
</TASK>
Modules linked in:
Dumping ftrace buffer:
(ftrace buffer empty)
---[ end trace 0000000000000000 ]---
RIP: 0010:page_try_dup_anon_rmap+0x927/0x1120
Code: e6 ff 0f 00 00 31 ff e8 87 75 b2 ff 4c 89 e0 48 25 ff 0f 00 00
0f 84 0e 01 00 00 e8 c3 70 b2 ff e9 43 03 00 00 e8 b9 70 b2 ff <0f> 0b
e8 b2 70 b2 ff 4c 89 e7 48 c7 c6 80 96 9e 8a e8 03 91 ee ff
RSP: 0018:ffffc900088e7368 EFLAGS: 00010287
RAX: ffffffff81d29967 RBX: 0000000000000000 RCX: 0000000000040000
RDX: ffffc900084b9000 RSI: 00000000000023c4 RDI: 00000000000023c5
RBP: ffff88802e3a0670 R08: ffffffff81d29420 R09: fffff9400011d001
R10: fffff9400011d001 R11: 0000000000000000 R12: ffffea00008e8000
R13: dffffc0000000000 R14: ffff88802e3a0670 R15: 1ffff11005c740ce
FS: 00007fa374806700(0000) GS:ffff888063c00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007fa3737b8000 CR3: 000000002f26f000 CR4: 0000000000750ef0
DR0: 0000000020000080 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
PKRU: 55555554

Best,
Wei