// https://syzkaller.appspot.com/bug?id=906433df4abcde9bf8261b1c105f7a48418b8663 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void kill_and_wait(int pid, int* status) { kill(pid, SIGKILL); while (waitpid(-1, status, 0) != pid) { } } static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } #define CAST static void execute_one(void); #define WAIT_FLAGS 0 static void loop(void) { int iter = 0; for (;; iter++) { int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } } } uint64_t r[6] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(socket))(/*domain=AF_INET*/2, /*type=SOCK_DGRAM*/2, /*proto=*/0); if (res != -1) r[0] = res; memcpy((void*)0x20000080, "\x32\x02\x73", 3); ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(connect))(/*fd=*/r[0], /*addr=*/0x20000080, /*addrlen=*/0x10); *(uint32_t*)0x20001200 = 8; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(getsockname))(/*fd=*/r[0], /*addr=*/0x20000000, /*addrlen=*/0x20001200); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(socket))(/*domain=AF_INET*/2, /*type=SOCK_STREAM*/1, /*proto=*/0); if (res != -1) r[1] = res; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(bind))(/*fd=*/r[1], /*addr=*/0x20000000, /*addrlen=*/0x10); res = -1; res = ((intptr_t(*)(intptr_t))CAST(dup))(/*oldfd=*/r[1]); if (res != -1) r[2] = res; ((intptr_t(*)(intptr_t,intptr_t))CAST(listen))(/*fd=*/r[2], /*backlog=*/0); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(socket))(/*domain=AF_INET*/2, /*type=SOCK_STREAM*/1, /*proto=*/0); if (res != -1) r[3] = res; ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(connect))(/*fd=*/r[3], /*addr=*/0x20000000, /*addrlen=*/0x10); res = -1; res = ((intptr_t(*)(intptr_t,intptr_t,intptr_t))CAST(accept))(/*fd=*/r[1], /*peer=*/0, /*peerlen=*/0); if (res != -1) r[4] = res; res = -1; res = ((intptr_t(*)(intptr_t,intptr_t))CAST(dup2))(/*oldfd=*/r[4], /*newfd=*/r[3]); if (res != -1) r[5] = res; memcpy((void*)0x20000040, "\xee\x08\x66\x7e\x19\xac\x14\xe6\x7c\x13\x48\x76\xf1\x97\xa7\x72\x84\x20\xae\xf6\x17\x15\x04\xb1\xc3\xb4\xb3\x83\x0c\xff\xff\xff\xff\x7a\x00\x00\x04\x00\x00\x00\x6a\x89\xdb\xdf", 44); ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(setsockopt))(/*fd=*/r[5], /*level=*/0, /*optname=IP_OPTIONS*/1, /*optval=*/0x20000040, /*optlen=*/0x2c); *(uint32_t*)0x200000c0 = 7; *(uint32_t*)0x200000c4 = 0x1ff; ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(setsockopt))(/*fd=*/r[3], /*level=*/0xffff, /*optname=*/0x80, /*optval=*/0x200000c0, /*optlen=*/8); } int main(void) { ((intptr_t(*)(intptr_t,intptr_t,intptr_t,intptr_t,intptr_t,intptr_t))CAST(mmap))(/*addr=*/0x20000000, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ*/3, /*flags=MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE*/0x1012, /*fd=*/-1, /*offset=*/0); loop(); return 0; }