Last active
April 18, 2023 05:32
-
-
Save ZHYfeng/a3e3ff2bdfea5ed5de5475f0b54d55cb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Syzkaller hit 'general protection fault in hci_uart_tty_ioctl' bug. | |
general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] PREEMPT SMP KASAN | |
KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] | |
CPU: 0 PID: 8770 Comm: syz-executor.0 Not tainted 6.2.0 #4 | |
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.13.0-1ubuntu1.1 04/01/2014 | |
RIP: 0010:hci_uart_tty_ioctl+0x244/0xc20 drivers/bluetooth/hci_ldisc.c:774 | |
Code: df 48 89 fa 48 c1 ea 03 80 3c 02 00 0f 85 cf 08 00 00 48 8b 9b b8 00 00 00 48 b8 00 00 00 00 00 fc ff df 48 89 da 48 c1 ea 03 <0f> b6 04 02 84 c0 74 08 3c 03 0f 8e 5f 08 00 00 44 8b 23 e9 14 ff | |
RSP: 0018:ffffc900022a7d10 EFLAGS: 00010246 | |
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff8710057c | |
RDX: 0000000000000000 RSI: ffff888046df8000 RDI: ffff88801cf510b8 | |
RBP: 0000000000000001 R08: 0000000000000001 R09: ffffed10039ea204 | |
R10: ffff88801cf5101f R11: ffffed10039ea203 R12: ffff8880204eb000 | |
R13: 0000000000000000 R14: ffffffffffffffe7 R15: 00000000800401c0 | |
FS: 00007f203e7dd700(0000) GS:ffff88802ca00000(0000) knlGS:0000000000000000 | |
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 | |
CR2: 00005587ec7f32d8 CR3: 000000004629e000 CR4: 0000000000350ef0 | |
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 | |
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 | |
Call Trace: | |
<TASK> | |
tty_ioctl+0xac0/0x1420 drivers/tty/tty_io.c:2784 | |
vfs_ioctl fs/ioctl.c:51 [inline] | |
__do_sys_ioctl fs/ioctl.c:870 [inline] | |
__se_sys_ioctl fs/ioctl.c:856 [inline] | |
__x64_sys_ioctl+0x198/0x210 fs/ioctl.c:856 | |
do_syscall_x64 arch/x86/entry/common.c:50 [inline] | |
do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 | |
entry_SYSCALL_64_after_hwframe+0x63/0xcd | |
RIP: 0033:0x7f203f0902fd | |
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:00007f203e7dcc58 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 | |
RAX: ffffffffffffffda RBX: 00007f203f1bc020 RCX: 00007f203f0902fd | |
RDX: 0000000000000000 RSI: 00000000800455c9 RDI: 0000000000000003 | |
RBP: 00007f203f0fec89 R08: 0000000000000000 R09: 0000000000000000 | |
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000 | |
R13: 00007ffee4615aef R14: 00007ffee4615ca0 R15: 00007f203e7dcdc0 | |
</TASK> | |
Modules linked in: | |
---[ end trace 0000000000000000 ]--- | |
RIP: 0010:hci_uart_tty_ioctl+0x244/0xc20 drivers/bluetooth/hci_ldisc.c:774 | |
Code: df 48 89 fa 48 c1 ea 03 80 3c 02 00 0f 85 cf 08 00 00 48 8b 9b b8 00 00 00 48 b8 00 00 00 00 00 fc ff df 48 89 da 48 c1 ea 03 <0f> b6 04 02 84 c0 74 08 3c 03 0f 8e 5f 08 00 00 44 8b 23 e9 14 ff | |
RSP: 0018:ffffc900022a7d10 EFLAGS: 00010246 | |
RAX: dffffc0000000000 RBX: 0000000000000000 RCX: ffffffff8710057c | |
RDX: 0000000000000000 RSI: ffff888046df8000 RDI: ffff88801cf510b8 | |
RBP: 0000000000000001 R08: 0000000000000001 R09: ffffed10039ea204 | |
R10: ffff88801cf5101f R11: ffffed10039ea203 R12: ffff8880204eb000 | |
R13: 0000000000000000 R14: ffffffffffffffe7 R15: 00000000800401c0 | |
FS: 00007f203e7dd700(0000) GS:ffff88807ec00000(0000) knlGS:0000000000000000 | |
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 | |
CR2: 00007fae9539b740 CR3: 000000004629e000 CR4: 0000000000350ee0 | |
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 | |
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 | |
---------------- | |
Code disassembly (best guess): | |
0: df 48 89 fisttps -0x77(%rax) | |
3: fa cli | |
4: 48 c1 ea 03 shr $0x3,%rdx | |
8: 80 3c 02 00 cmpb $0x0,(%rdx,%rax,1) | |
c: 0f 85 cf 08 00 00 jne 0x8e1 | |
12: 48 8b 9b b8 00 00 00 mov 0xb8(%rbx),%rbx | |
19: 48 b8 00 00 00 00 00 movabs $0xdffffc0000000000,%rax | |
20: fc ff df | |
23: 48 89 da mov %rbx,%rdx | |
26: 48 c1 ea 03 shr $0x3,%rdx | |
* 2a: 0f b6 04 02 movzbl (%rdx,%rax,1),%eax <-- trapping instruction | |
2e: 84 c0 test %al,%al | |
30: 74 08 je 0x3a | |
32: 3c 03 cmp $0x3,%al | |
34: 0f 8e 5f 08 00 00 jle 0x899 | |
3a: 44 8b 23 mov (%rbx),%r12d | |
3d: e9 .byte 0xe9 | |
3e: 14 ff adc $0xff,%al | |
Syzkaller reproducer: | |
# {Threaded:true Collide:true Repeat:true RepeatTimes:0 Procs:1 Slowdown:1 Sandbox:none Leak:false NetInjection:true NetDevices:true NetReset:true Cgroups:true BinfmtMisc:true CloseFDs:true KCSAN:false DevlinkPCI:false USB:true VhciInjection:true Wifi:true IEEE802154:true Sysctl:true UseTmpDir:true HandleSegv:true Repro:false Trace:false LegacyOptions:{Fault:false FaultCall:0 FaultNth:0} InitResource:false} | |
ioctl$cec0_Groupc05c6104_25(0xffffffffffffffff, 0xc05c6104, 0x0) | |
r0 = openat$ptmx_syzgen(0xffffffffffffff9c, &(0x7f0000000000), 0x0, 0x0) | |
ioctl$ptmx_Group5423_1(r0, 0x5423, &(0x7f0000000000)=0xf) | |
r1 = openat$ttyprintk_syzgen(0xffffffffffffff9c, 0x0, 0x200, 0x0) | |
ioctl$ptmx_Group5407_2(r1, 0x5407, 0x0) | |
ioctl$ptmx_Group5402_3(r0, 0x400455c8, 0x0) | |
ioctl$ptmx_Group5402_3(r0, 0x800455c9, 0x0) | |
C reproducer: Note that I inserted a prink in the source code so that the C producer can easily trigger the bug. | |
// autogenerated by syzkaller (https://github.com/google/syzkaller) | |
#define _GNU_SOURCE | |
#include <endian.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <sys/syscall.h> | |
#include <sys/types.h> | |
#include <unistd.h> | |
#include <pthread.h> | |
uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff}; | |
void *thr0(void *arg) { | |
syscall(__NR_ioctl, r[0], 0x400455c8, 0ul); | |
} | |
void *thr1(void *arg) { | |
syscall(__NR_ioctl, r[0], 0x800455c9, 0ul); | |
} | |
int main(void) | |
{ | |
pthread_t th[4]; | |
int i = 0; | |
syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); | |
syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul); | |
syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); | |
intptr_t res = 0; | |
syscall(__NR_ioctl, -1, 0xc05c6104, 0ul); | |
memcpy((void*)0x20000000, "/dev/pts/ptmx\000", 14); | |
*(uint32_t*)0x20001000 = 0xf; | |
for (i = 0;; i++) { | |
res = syscall(__NR_openat, 0xffffffffffffff9cul, 0x20000000ul, 0ul, 0ul); | |
if (res != -1) | |
r[0] = res; | |
else | |
continue; | |
syscall(__NR_ioctl, r[0], 0x5423, 0x20001000ul); | |
pthread_create(&th[0], 0, thr0, 0); | |
pthread_create(&th[1], 0, thr1, 0); | |
pthread_join(th[0], 0); | |
pthread_join(th[1], 0); | |
close(r[0]); | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment