// https://syzkaller.appspot.com/bug?id=e6d1ed219bd92dd9b3e653eda032852996a9b457 // 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_procfs(uintptr_t a0, uintptr_t a1) { char buf[128]; memset(buf, 0, sizeof(buf)); if (a0 == 0) { snprintf(buf, sizeof(buf), "/proc/self/%s", (char*)a1); } else if (a0 == (uintptr_t)-1) { snprintf(buf, sizeof(buf), "/proc/thread-self/%s", (char*)a1); } else { snprintf(buf, sizeof(buf), "/proc/self/task/%d/%s", (int)a0, (char*)a1); } int fd = open(buf, O_RDWR); if (fd == -1) fd = open(buf, O_RDONLY); return fd; } 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; } } } } uint64_t r[1] = {0xffffffffffffffff}; void execute_call(int call) { long res; switch (call) { case 0: memcpy((void*)0x20000100, "\x2f\x65\x78\x65\x00\x00\x00\x00\x00\x00\x0f\xe1\xff\x54\x8c\x9a" "\x8d\x8a\x50\x44\xbc\x91\x6d\x45\xb7\xa1\x46\x86\x91\xf6\xba\xaf" "\x6f\xc1\x5f\xe4\x1f\x98\x2f\xc9\x90\x8e\xf9\x05\xed\x6e\x47\x1e" "\xa8\xea\x8f\x36\x88\x79\x9e\x40\xef\xee\x63\xeb\xf4\x6b\x4d\x8d" "\x40\xfb\x62\x64\xf8\xaf\x5f\x9f\x5e\x2b\xd1\xf4\xb1\x44\x55\x12" "\xe1\xcf\x2e\xfd\x03\xbf\xa4\xe2\x9f\x49\xe5\x08\x5c\xf9\x1c\xc7" "\x57\x13\xa9\xc3\x7d\x1f\x9c\x41\x9b\x50\x12\xbf\xb2\x33\x4d\xb4" "\xd6\x54\x86\x5f\xa0\x53\x18\xd5\xb4\x44\x39\x1b\x78\x76\x9a\xf4" "\x05\xcd\x5c\xc8\x1b\xb1\xea\xfb\x3d\x37\x3f\x97\x8d\x7d\x11\xaf" "\xb9\x31\x18\x9e\x8a\xdd\x49\xae\x51\x56\x14\xce\x1f\xb5\x21\xf5" "\x0c\xa9\x4c\x19\xf9\x69\x16\xd3", 168); res = syz_open_procfs(0, 0x20000100); if (res != -1) r[0] = res; break; case 1: syscall(__NR_ftruncate, r[0], 2); break; } } void loop() { execute(2); } int main() { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); loop(); return 0; }