// https://syzkaller.appspot.com/bug?id=28bc35dd6f026b2878e30804670f6f0c39932f16 // autogenerated by syzkaller (http://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include static uintptr_t syz_open_pts(uintptr_t a0, uintptr_t a1) { int ptyno = 0; if (ioctl(a0, TIOCGPTN, &ptyno)) return -1; char buf[128]; sprintf(buf, "/dev/pts/%d", ptyno); return open(buf, a1, 0); } struct thread_t { int created, running, call; pthread_t th; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { while (!__atomic_load_n(&th->running, __ATOMIC_ACQUIRE)) syscall(SYS_futex, &th->running, FUTEX_WAIT, 0, 0); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); __atomic_store_n(&th->running, 0, __ATOMIC_RELEASE); syscall(SYS_futex, &th->running, FUTEX_WAKE); } return 0; } static void execute(int num_calls) { int call, thread; running = 0; for (call = 0; call < num_calls; call++) { for (thread = 0; thread < sizeof(threads) / sizeof(threads[0]); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); pthread_create(&th->th, &attr, thr, th); } if (!__atomic_load_n(&th->running, __ATOMIC_ACQUIRE)) { th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); __atomic_store_n(&th->running, 1, __ATOMIC_RELEASE); syscall(SYS_futex, &th->running, FUTEX_WAKE); struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = 20 * 1000 * 1000; syscall(SYS_futex, &th->running, FUTEX_WAIT, 1, &ts); if (running) usleep((call == num_calls - 1) ? 10000 : 1000); break; } } } } long r[2]; void execute_call(int call) { switch (call) { case 0: *(uint32_t*)0x20000040 = 0xf0a9; syscall(__NR_setsockopt, -1, 0x107, 0, 0x20000040, 4); break; case 1: memcpy((void*)0x200000c0, "/dev/sequencer", 15); r[0] = syscall(__NR_openat, 0xffffffffffffff9c, 0x200000c0, 0x82002, 0); break; case 2: syscall(__NR_ioctl, r[0], 0x541b, 0x20000100); break; case 3: r[1] = syz_open_pts(-1, 0); break; case 4: *(uint64_t*)0x200005c0 = 0x200004c0; *(uint64_t*)0x200005c8 = 0xce; syscall(__NR_ptrace, 0x4204, 0, 4, 0x200005c0); break; case 5: *(uint32_t*)0x20000780 = 0; *(uint16_t*)0x20000784 = 2; *(uint16_t*)0x20000786 = htobe16(0x4e20); *(uint32_t*)0x20000788 = htobe32(0xe0000001); *(uint8_t*)0x2000078c = 0; *(uint8_t*)0x2000078d = 0; *(uint8_t*)0x2000078e = 0; *(uint8_t*)0x2000078f = 0; *(uint8_t*)0x20000790 = 0; *(uint8_t*)0x20000791 = 0; *(uint8_t*)0x20000792 = 0; *(uint8_t*)0x20000793 = 0; *(uint64_t*)0x20000794 = 0; *(uint64_t*)0x2000079c = 0; *(uint64_t*)0x200007a4 = 0; *(uint64_t*)0x200007ac = 0; *(uint64_t*)0x200007b4 = 0; *(uint64_t*)0x200007bc = 0; *(uint64_t*)0x200007c4 = 0; *(uint64_t*)0x200007cc = 0; *(uint64_t*)0x200007d4 = 0; *(uint64_t*)0x200007dc = 0; *(uint64_t*)0x200007e4 = 0; *(uint64_t*)0x200007ec = 0; *(uint64_t*)0x200007f4 = 0; *(uint64_t*)0x200007fc = 0; *(uint64_t*)0x20000804 = 0; syscall(__NR_setsockopt, r[0], 0x84, 6, 0x20000780, 0x8c); break; case 6: syscall(__NR_setsockopt, r[0], 1, 0x24, 0, 0); break; case 7: *(uint64_t*)0x200031c0 = 0x200009c0; *(uint16_t*)0x200009c0 = 0x10; *(uint16_t*)0x200009c2 = 0; *(uint32_t*)0x200009c4 = 0; *(uint32_t*)0x200009c8 = 0x9024800; *(uint32_t*)0x200031c8 = 0xc; *(uint64_t*)0x200031d0 = 0x20003180; *(uint64_t*)0x20003180 = 0x20000a00; *(uint32_t*)0x20000a00 = 0x74; *(uint16_t*)0x20000a04 = 0x29; *(uint16_t*)0x20000a06 = 0x12; *(uint32_t*)0x20000a08 = 0x70bd28; *(uint32_t*)0x20000a0c = 0x25dfdbfc; *(uint8_t*)0x20000a10 = 0xc; *(uint8_t*)0x20000a11 = 0; *(uint16_t*)0x20000a12 = 0; *(uint16_t*)0x20000a14 = 0x34; *(uint16_t*)0x20000a16 = 0x37; *(uint16_t*)0x20000a18 = 0x18; *(uint16_t*)0x20000a1a = 0x67; *(uint8_t*)0x20000a20 = 0xfe; *(uint8_t*)0x20000a21 = 0x80; *(uint8_t*)0x20000a22 = 0; *(uint8_t*)0x20000a23 = 0; *(uint8_t*)0x20000a24 = 0; *(uint8_t*)0x20000a25 = 0; *(uint8_t*)0x20000a26 = 0; *(uint8_t*)0x20000a27 = 0; *(uint8_t*)0x20000a28 = 0; *(uint8_t*)0x20000a29 = 0; *(uint8_t*)0x20000a2a = 0; *(uint8_t*)0x20000a2b = 0; *(uint8_t*)0x20000a2c = 0; *(uint8_t*)0x20000a2d = 0; *(uint8_t*)0x20000a2e = 0; *(uint8_t*)0x20000a2f = 0xbb; *(uint16_t*)0x20000a30 = 0xc; *(uint16_t*)0x20000a32 = 0x2b; *(uint32_t*)0x20000a38 = 8; *(uint16_t*)0x20000a3c = 0xc; *(uint16_t*)0x20000a3e = 0x2c; *(uint32_t*)0x20000a44 = htobe32(0x7f000001); *(uint16_t*)0x20000a48 = 0xc; *(uint16_t*)0x20000a4a = 0; *(uint16_t*)0x20000a4c = 8; *(uint16_t*)0x20000a4e = 0x42; *(uint16_t*)0x20000a54 = 0x20; *(uint16_t*)0x20000a56 = 0x7c; *(uint16_t*)0x20000a58 = 8; *(uint16_t*)0x20000a5a = 0x7a; *(uint16_t*)0x20000a60 = 0xc; *(uint16_t*)0x20000a62 = 0xff; memcpy((void*)0x20000a68, ".", 2); *(uint16_t*)0x20000a6c = 8; *(uint16_t*)0x20000a6e = 0x47; *(uint64_t*)0x20003188 = 0x74; *(uint64_t*)0x200031d8 = 1; *(uint64_t*)0x200031e0 = 0; *(uint64_t*)0x200031e8 = 0; *(uint32_t*)0x200031f0 = 0x4000000; syscall(__NR_sendmsg, r[0], 0x200031c0, 0); break; case 8: syscall(__NR_setsockopt, r[1], 0x107, 7, 0x20003200, 0); break; } } void loop() { memset(r, -1, sizeof(r)); execute(9); } int main() { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); loop(); return 0; }