// https://syzkaller.appspot.com/bug?id=e7af9f950d9a214f2afd68b5449e296a07dc3e4e // autogenerated by syzkaller (http://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include static void test(); void loop() { while (1) { test(); } } 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[3]; void execute_call(int call) { switch (call) { case 0: syscall(__NR_mmap, 0x20000000, 0xfff000, 3, 0x32, -1, 0); break; case 1: r[0] = syscall(__NR_socket, 0xa, 2, 0); break; case 2: memcpy((void*)0x20190fd8, "\x73\x69\x74\x30\x00\x00\xfb\xff\x00\x00\x00\x00\x00\x00\x00\x00", 16); *(uint32_t*)0x20190fe8 = 0; *(uint8_t*)0x20190fec = 0; *(uint8_t*)0x20190fed = 0; *(uint8_t*)0x20190fee = 0; *(uint8_t*)0x20190fef = 0; *(uint8_t*)0x20190ff0 = 0; *(uint8_t*)0x20190ff1 = 0; *(uint8_t*)0x20190ff2 = 0; *(uint8_t*)0x20190ff3 = 0; *(uint8_t*)0x20190ff4 = 0; *(uint8_t*)0x20190ff5 = 0; *(uint8_t*)0x20190ff6 = 0; *(uint8_t*)0x20190ff7 = 0; *(uint8_t*)0x20190ff8 = 0; *(uint8_t*)0x20190ff9 = 0; *(uint8_t*)0x20190ffa = 0; *(uint8_t*)0x20190ffb = 0; *(uint8_t*)0x20190ffc = 0; *(uint8_t*)0x20190ffd = 0; *(uint8_t*)0x20190ffe = 0; *(uint8_t*)0x20190fff = 0; if (syscall(__NR_ioctl, r[0], 0x8933, 0x20190fd8) != -1) r[1] = *(uint32_t*)0x20190fe8; break; case 3: *(uint8_t*)0x20c0cfb0 = 0xfe; *(uint8_t*)0x20c0cfb1 = 0x80; *(uint8_t*)0x20c0cfb2 = 0; *(uint8_t*)0x20c0cfb3 = 0; *(uint8_t*)0x20c0cfb4 = 0; *(uint8_t*)0x20c0cfb5 = 0; *(uint8_t*)0x20c0cfb6 = 0; *(uint8_t*)0x20c0cfb7 = 0; *(uint8_t*)0x20c0cfb8 = 0; *(uint8_t*)0x20c0cfb9 = 0; *(uint8_t*)0x20c0cfba = 0; *(uint8_t*)0x20c0cfbb = 0; *(uint8_t*)0x20c0cfbc = 0; *(uint8_t*)0x20c0cfbd = 0; *(uint8_t*)0x20c0cfbe = 0; *(uint8_t*)0x20c0cfbf = 0xaa; *(uint64_t*)0x20c0cfc0 = htobe64(0); *(uint64_t*)0x20c0cfc8 = htobe64(1); *(uint64_t*)0x20c0cfd0 = htobe64(0); *(uint64_t*)0x20c0cfd8 = htobe64(1); *(uint32_t*)0x20c0cfe0 = 0; *(uint16_t*)0x20c0cfe4 = 0; *(uint16_t*)0x20c0cfe6 = 0; *(uint32_t*)0x20c0cfe8 = -1; *(uint64_t*)0x20c0cff0 = 0; *(uint32_t*)0x20c0cff8 = 0x400000; *(uint32_t*)0x20c0cffc = r[1]; syscall(__NR_ioctl, r[0], 0x890b, 0x20c0cfb0); break; case 4: r[2] = syscall(__NR_socket, 0x10, 3, 0); break; case 5: *(uint64_t*)0x20bb2000 = 0x20447fd7; *(uint64_t*)0x20bb2008 = 0x29; memcpy((void*)0x20447fd7, "\x29\x00\x00\x00\x18\x00\x31\x15\xff\xff\xef\x00" "\x00\xc5\x0a\x17\x0a\x80\x00\x66\x01\x6d\x00\x09" "\x99\x98\xff\xbf\x08\x00\x08\x00\x04\x00\x01\x00" "\x0e\xf4\xff\x01\xff", 41); syscall(__NR_writev, r[2], 0x20bb2000, 1); break; } } void test() { memset(r, -1, sizeof(r)); execute(6); } int main() { for (;;) { loop(); } }