// https://syzkaller.appspot.com/bug?id=b5095bfec44ec84213bac54742a82483aad578ce // autogenerated by syzkaller (http://github.com/google/syzkaller) #define _GNU_SOURCE #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; } static void test(); void loop() { while (1) { test(); } } long r[5]; void* thr(void* arg) { switch ((long)arg) { case 0: syscall(__NR_mmap, 0x20000000ul, 0xfff000ul, 0x3ul, 0x32ul, 0xfffffffffffffffful, 0x0ul); break; case 1: syscall(__NR_clone, 0x200ul, 0x20fbf000ul, 0x20744000ul, 0x20f8b000ul, 0x200d5000ul); break; case 2: memcpy((void*)0x20f80000, "./file0", 8); syscall(__NR_mknod, 0x20f80000ul, 0x1040ul, 0x0ul); break; case 3: memcpy((void*)0x207c7000, "./file0", 8); syscall(__NR_execve, 0x207c7000ul, 0x20a7bfc8ul, 0x20f56000ul); break; case 4: memcpy((void*)0x20f9dffa, "stack", 6); r[0] = syz_open_procfs(0x0ul, 0x20f9dffaul); break; case 5: syscall(__NR_read, r[0], 0x20cb0ff8ul, 0x8ul); break; case 6: memcpy((void*)0x20c84feb, "net/ip6_tables_names", 21); r[1] = syz_open_procfs(0x0ul, 0x20c84febul); break; case 7: r[2] = syscall(__NR_socket, 0x2ul, 0x1ul, 0x0ul); break; case 8: r[3] = syscall(__NR_dup2, r[1], r[2]); break; case 9: if (syscall(__NR_pipe2, 0x20fdf000ul, 0x0ul) != -1) { r[4] = *(uint32_t*)0x20fdf004; } break; case 10: syscall(__NR_splice, r[3], 0x0ul, r[4], 0x0ul, 0x82ul, 0x0ul); break; } return 0; } void test() { long i; pthread_t th[22]; memset(r, -1, sizeof(r)); for (i = 0; i < 11; i++) { pthread_create(&th[i], 0, thr, (void*)i); usleep(rand() % 10000); } usleep(rand() % 100000); } int main() { int i; for (i = 0; i < 8; i++) { if (fork() == 0) { loop(); return 0; } } sleep(1000000); return 0; }