// https://syzkaller.appspot.com/bug?id=c396a23dfc5d7c2441beeee15bb754c0cee61b76 // 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 #ifndef SYS_connect #define SYS_connect 98 #endif #ifndef SYS_dup2 #define SYS_dup2 90 #endif #ifndef SYS_mmap #define SYS_mmap 197 #endif #ifndef SYS_setsockopt #define SYS_setsockopt 105 #endif #ifndef SYS_socket #define SYS_socket 394 #endif #ifndef SYS_write #define SYS_write 4 #endif static unsigned long long procid; 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[2] = {0xffffffffffffffff, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; res = syscall(SYS_socket, /*domain=PF_INET*/ 2ul, /*type=SOCK_RAW*/ 3ul, /*proto=*/0); if (res != -1) r[0] = res; res = syscall(SYS_socket, /*domain=PF_INET6*/ 0x18ul, /*type=SOCK_RAW*/ 3ul, /*proto=*/0); if (res != -1) r[1] = res; *(uint16_t*)0x200000c0 = 0x18e6; *(uint8_t*)0x200000c2 = 7; *(uint32_t*)0x200000c4 = 0; syscall(SYS_connect, /*fd=*/r[1], /*addr=*/0x200000c0ul, /*addrlen=*/0x1cul); syscall(SYS_dup2, /*oldfd=*/r[1], /*newfd=*/r[0]); *(uint32_t*)0x20000100 = 0x20000; syscall(SYS_setsockopt, /*fd=*/r[0], /*level=*/0xffff, /*optname=SO_SNDBUF*/ 0x1001, /*optval=*/0x20000100ul, /*optlen=*/4ul); memcpy((void*)0x20001680, "\x04\xbd\xfa\x5d\x1d\x28\x73\xc6\x3e\x35\x34\x82\x5b\xa1\x66\xe2\xfe" "\xa9\xae\xc4\x30\x50\x00\x61\x23\x33\x9a\x34\x6f\x73\x15\x73\xd8\xd5" "\x08\x75\x3f\x95\xb7\x68\x8a\xd4\x8b\x8c\xf6\xbb\xca\x32\x5c\xeb\xc3" "\x7f\xc4\xe1\xdd\x54\x3d\xbe\x2d\xa6\xdd", 61); syscall(SYS_write, /*fd=*/r[0], /*buf=*/0x20001680ul, /*count=*/0x1001cul); } int main(void) { syscall(SYS_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ*/ 3ul, /*flags=MAP_PRIVATE|MAP_FIXED|MAP_ANON*/ 0x1012ul, /*fd=*/-1, /*pad=*/0ul, /*offset=*/0ul); for (procid = 0; procid < 6; procid++) { if (fork() == 0) { loop(); } } sleep(1000000); return 0; }