// https://syzkaller.appspot.com/bug?id=541216bb311fb12f4df117951b14f231d7907bf6 // 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 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; } 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[1] = {0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; res = syscall(SYS_socket, /*domain=*/2ul, /*type=*/1ul, /*proto=*/0); if (res != -1) r[0] = res; memcpy((void*)0x20000080, "rack\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000", 32); *(uint32_t*)0x200000a0 = 0; syscall(SYS_setsockopt, /*fd=*/r[0], /*level=*/6, /*optname=*/0x2000, /*optval=*/0x20000080ul, /*optlen=*/0x24ul); *(uint8_t*)0x200001c0 = 0x10; *(uint8_t*)0x200001c1 = 2; *(uint16_t*)0x200001c2 = htobe16(0x4e22); *(uint32_t*)0x200001c4 = htobe32(0x7f000001); memset((void*)0x200001c8, 0, 8); syscall(SYS_bind, /*fd=*/r[0], /*addr=*/0x200001c0ul, /*addrlen=*/0x10ul); *(uint8_t*)0x200000c0 = 0x10; *(uint8_t*)0x200000c1 = 2; *(uint16_t*)0x200000c2 = htobe16(0x4e22); *(uint32_t*)0x200000c4 = htobe32(0x7f000001); memset((void*)0x200000c8, 0, 8); syscall(SYS_connect, /*fd=*/r[0], /*addr=*/0x200000c0ul, /*addrlen=*/0x10ul); memcpy((void*)0x20000240, "freebsd\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000", 32); *(uint32_t*)0x20000260 = 0; syscall(SYS_setsockopt, /*fd=*/r[0], /*level=*/6, /*optname=*/0x2000, /*optval=*/0x20000240ul, /*optlen=*/0x24ul); memcpy( (void*)0x20000100, "\xea\xc5\x52\x6a\x3f\x53\xe4\x5b\x51\x43\x23\x2a\xd1\x2f\xe2\xf8\xb8\x86" "\x54\x0c\x5d\x96\x65\x45\x7c\x67\x06\x01\xdf\xfb\x41\xd2\xe1\x9d\x49\xe5" "\xdb\x3e\x19\x18\x59\x69\x94\xac\xc8\x65\xd3\x8f\x40\xfd\xfe\x10\x9d\xef" "\x32\xe8\x64\xd3\x39\x3c\xc2\x88\xd6\x6f\x1f\x9d\xed\xc9\xb8\xb5\xf3\xab" "\x72\x83\x81\x9d\xa5\x7e\xf6\x93\x21\xb8\x10\xf2\x02\xb5\x12\xfc\xa2\xc0" "\x27\x50\x6a\xbc\xbc\x39\x24\xe8\x1b\x90\x1d\xa1\xd3\x82\x81\x95\x27\x2a" "\xb0\x68\x26\x12\xae\x60\xdb\xc7\x9a\xb8\xd0\x16\xe9\x80\x92\xbc\xbb\x93" "\x79\x69\xff\x69\x4b\x1a\x47\x4e\x5b\x23\x03\xa3\x36\x2b\xfc\x0a\x34\xf0" "\xda\x9b\xce\x4f\x1f\x87\x9e\x17\x6e\xd5\x3a\xf8\x70\x10\xd2\x83\x4a\x71" "\x98\xd5\x47\xde\x43\x63\xaa\x98\x0d\x79\xd4\x8b\x5c", 175); syscall(SYS_sendto, /*fd=*/r[0], /*buf=*/0x20000100ul, /*len=*/0xaful, /*f=*/0x20004ul, /*addr=*/0ul, /*addrlen=*/0ul); memcpy((void*)0x20000000, "rack\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000", 32); *(uint32_t*)0x20000020 = 0; syscall(SYS_setsockopt, /*fd=*/r[0], /*level=*/6, /*optname=*/0x2000, /*optval=*/0x20000000ul, /*optlen=*/0x24ul); memcpy( (void*)0x20000100, "\xea\xc5\x52\x6a\x3f\x53\xe4\x5b\x51\x43\x23\x2a\xd1\x2f\xe2\xf8\xb8\x86" "\x54\x0c\x5d\x96\x65\x45\x7c\x67\x06\x01\xdf\xfb\x41\xd2\xe1\x9d\x49\xe5" "\xdb\x3e\x19\x18\x59\x69\x94\xac\xc8\x65\xd3\x8f\x40\xfd\xfe\x10\x9d\xef" "\x32\xe8\x64\xd3\x39\x3c\xc2\x88\xd6\x6f\x1f\x9d\xed\xc9\xb8\xb5\xf3\xab" "\x72\x83\x81\x9d\xa5\x7e\xf6\x93\x21\xb8\x10\xf2\x02\xb5\x12\xfc\xa2\xc0" "\x27\x50\x6a\xbc\xbc\x39\x24\xe8\x1b\x90\x1d\xa1\xd3\x82\x81\x95\x27\x2a" "\xb0\x68\x26\x12\xae\x60\xdb\xc7\x9a\xb8\xd0\x16\xe9\x80\x92\xbc\xbb\x93" "\x79\x69\xff\x69\x4b\x1a\x47\x4e\x5b\x23\x03\xa3\x36\x2b\xfc\x0a\x34\xf0" "\xda\x9b\xce\x4f\x1f\x87\x9e\x17\x6e\xd5\x3a\xf8\x70\x10\xd2\x83\x4a\x71" "\x98\xd5\x47\xde\x43\x63\xaa\x98\x0d\x79\xd4\x8b\x5c", 175); syscall(SYS_sendto, /*fd=*/r[0], /*buf=*/0x20000100ul, /*len=*/0xaful, /*f=*/0x20004ul, /*addr=*/0ul, /*addrlen=*/0ul); } int main(void) { syscall(SYS_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000ul, /*prot=*/7ul, /*flags=*/0x1012ul, /*fd=*/-1, /*offset=*/0ul); loop(); return 0; }