// https://syzkaller.appspot.com/bug?id=61ec9b78979c77b478704a46b43300223433acfe // 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[10]; void* thr(void* arg) { switch ((long)arg) { case 0: r[0] = syscall(__NR_mmap, 0x20000000ul, 0xfff000ul, 0x3ul, 0x32ul, 0xfffffffffffffffful, 0x0ul); break; case 1: r[1] = syscall(__NR_pipe2, 0x20dff000ul, 0x800ul); if (r[1] != -1) r[2] = *(uint32_t*)0x20dff004; break; case 2: r[3] = syscall(__NR_ioctl, r[2], 0x5425ul, 0x80000000ul); break; case 3: memcpy((void*)0x20480ff8, "\x2e\x2f\x66\x69\x6c\x65\x30\x00", 8); r[5] = syscall(__NR_readlink, 0x20480ff8ul, 0x2014efe4ul, 0x1cul); break; case 4: memcpy((void*)0x20303000, "\x73\x74\x61\x63\x6b\x00", 6); r[7] = syz_open_procfs(0x0ul, 0x20303000ul); break; case 5: *(uint64_t*)0x20ab9000 = (uint64_t)0x0; r[9] = syscall(__NR_sendfile, r[7], r[7], 0x20ab9000ul, 0x2ul); break; } return 0; } void test() { long i; pthread_t th[12]; memset(r, -1, sizeof(r)); srand(getpid()); for (i = 0; i < 6; i++) { pthread_create(&th[i], 0, thr, (void*)i); usleep(rand() % 10000); } for (i = 0; i < 6; i++) { pthread_create(&th[6 + i], 0, thr, (void*)i); if (rand() % 2) 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; }