// https://syzkaller.appspot.com/bug?id=bda19bf6b14e7fddccf28ac6f0205c7df6d8c32e // 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 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[6] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0x0}; void execute_one(void) { intptr_t res = 0; syscall(SYS_socket, /*domain=*/2ul, /*type=*/0ul, /*proto=*/0x84); res = syscall(SYS_socket, /*domain=*/0x1cul, /*type=*/1ul, /*proto=*/0); if (res != -1) r[0] = res; syscall(SYS_setsockopt, /*fd=*/r[0], /*level=*/0x29, /*optname=*/0x31, /*optval=*/0ul, /*optlen=*/0x1010ul); syscall(SYS_sendto, /*fd=*/r[0], /*buf=*/0ul, /*len=*/0ul, /*f=*/0ul, /*addr=*/0ul, /*addrlen=*/0ul); res = syscall(SYS_socket, /*domain=*/0x1cul, /*type=*/1ul, /*proto=*/0); if (res != -1) r[1] = res; *(uint8_t*)0x20000180 = 0x1c; *(uint8_t*)0x20000181 = 0x1c; *(uint16_t*)0x20000182 = htobe16(0x4e23 + procid * 4); *(uint32_t*)0x20000184 = 0; *(uint64_t*)0x20000188 = htobe64(0); *(uint64_t*)0x20000190 = htobe64(1); *(uint32_t*)0x20000198 = 0; syscall(SYS_connect, /*fd=*/r[1], /*addr=*/0x20000180ul, /*addrlen=*/0x1cul); syscall(SYS_sendto, /*fd=*/r[1], /*buf=*/0ul, /*len=*/0ul, /*f=*/0ul, /*addr=*/0ul, /*addrlen=*/0ul); res = syscall(SYS_fcntl, /*fd=*/-1, /*cmd=*/0x11ul, /*arg=*/-1); if (res != -1) r[2] = res; syscall(SYS_getsockopt, /*fd=*/r[2], /*level=*/0x84, /*opt=*/7, /*val=*/0ul, /*len=*/0ul); *(uint8_t*)0x200000c0 = 0x10; *(uint8_t*)0x200000c1 = 2; *(uint16_t*)0x200000c2 = htobe16(0x4e23 + procid * 4); *(uint32_t*)0x200000c4 = htobe32(0xe0000001); memset((void*)0x200000c8, 0, 8); syscall(SYS_connect, /*fd=*/-1, /*addr=*/0x200000c0ul, /*addrlen=*/0x10ul); syscall(SYS_socketpair, /*domain=*/0x17ul, /*type=*/2ul, /*proto=*/5, /*fds=*/0ul); syscall(SYS_socketpair, /*domain=*/0x17ul, /*type=*/2ul, /*proto=*/5, /*fds=*/0ul); syscall(SYS_setsockopt, /*fd=*/-1, /*level=*/0x84, /*opt=*/0x900, /*val=*/0ul, /*len=*/0ul); res = syscall(SYS_socket, /*domain=*/0x1cul, /*type=*/1ul, /*proto=*/0); if (res != -1) r[3] = res; syscall(SYS_sendto, /*fd=*/r[3], /*buf=*/0ul, /*len=*/0ul, /*f=*/0ul, /*addr=*/0ul, /*addrlen=*/0ul); *(uint32_t*)0x200000c0 = 0; res = syscall(SYS_accept, /*fd=*/-1, /*peer=*/0ul, /*peerlen=*/0x200000c0ul); if (res != -1) r[4] = res; syscall(SYS_sendto, /*fd=*/r[4], /*buf=*/0ul, /*len=*/0ul, /*f=*/0ul, /*addr=*/0ul, /*addrlen=*/0ul); syscall(SYS_setsockopt, /*fd=*/-1, /*level=*/6, /*optname=*/0x2000, /*optval=*/0ul, /*optlen=*/0ul); *(uint32_t*)0x200003c0 = 3; syscall(SYS_setsockopt, /*fd=*/-1, /*level=*/6, /*optname=*/0x22, /*optval=*/0x200003c0ul, /*optlen=*/4ul); syscall(SYS_shutdown, /*fd=*/-1, /*how=*/1ul); syscall(SYS_setsockopt, /*fd=*/-1, /*level=*/6, /*optname=*/0x2000, /*optval=*/0ul, /*optlen=*/0ul); *(uint64_t*)0x20000080 = 0x200006c0; *(uint64_t*)0x20000088 = 0x100000; syscall(SYS_pwritev, /*fd=*/-1, /*vec=*/0x20000080ul, /*vlen=*/1ul, /*off=*/0ul); syscall(SYS_open, /*file=*/0ul, /*flags=*/0x40000400000002c2ul, /*mode=*/0x9eul); res = syscall(SYS_fork); { int i; for (i = 0; i < 32; i++) { syscall(SYS_fork); } } if (res != -1) r[5] = res; syscall(SYS_procctl, /*idtype=*/2ul, /*id=*/r[5], /*cmd=*/0xeul, /*data=*/0ul); *(uint32_t*)0x20000000 = 0; *(uint32_t*)0x20000004 = 0; *(uint32_t*)0x20000008 = -1; *(uint32_t*)0x2000000c = 0; *(uint16_t*)0x20000010 = 0x6a; *(uint16_t*)0x20000012 = 0x584; *(uint32_t*)0x20000014 = 0; *(uint64_t*)0x20000018 = 0x80000000; *(uint32_t*)0x20000020 = 0x6e; *(uint64_t*)0x20000028 = 0x4f; *(uint64_t*)0x20000030 = 9; *(uint64_t*)0x20000038 = 0x2033; *(uint32_t*)0x20000040 = 0; *(uint32_t*)0x20000044 = r[5]; *(uint16_t*)0x20000048 = 0x24b; *(uint16_t*)0x2000004a = 0; *(uint64_t*)0x20000050 = 0; *(uint64_t*)0x20000058 = 0; syscall(SYS_shmctl, /*shmid=*/0, /*cmd=*/1ul, /*buf=*/0x20000000ul); syscall(SYS_setsockopt, /*fd=*/-1, /*level=*/0x84, /*opt=*/0x32, /*val=*/0ul, /*len=*/0ul); memcpy((void*)0x20000100, "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*)0x20000120 = 0; syscall(SYS_setsockopt, /*fd=*/-1, /*level=*/6, /*optname=*/0x2000, /*optval=*/0x20000100ul, /*optlen=*/0x24ul); } int main(void) { syscall(SYS_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000ul, /*prot=*/7ul, /*flags=*/0x1012ul, /*fd=*/-1, /*offset=*/0ul); for (procid = 0; procid < 4; procid++) { if (fork() == 0) { loop(); } } sleep(1000000); return 0; }