// https://syzkaller.appspot.com/bug?id=f0beeabf36434bf4cb12c9459ba9ee4dc3983c3b // 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___vfork14 #define SYS___vfork14 282 #endif #ifndef SYS_fcntl #define SYS_fcntl 92 #endif #ifndef SYS_fktrace #define SYS_fktrace 288 #endif #ifndef SYS_getpgrp #define SYS_getpgrp 81 #endif #ifndef SYS_mmap #define SYS_mmap 197 #endif #ifndef SYS_open #define SYS_open 5 #endif #ifndef SYS_pipe #define SYS_pipe 42 #endif #ifndef SYS_ptrace #define SYS_ptrace 26 #endif #ifndef SYS_read #define SYS_read 3 #endif #ifndef SYS_recvfrom #define SYS_recvfrom 29 #endif #ifndef SYS_writev #define SYS_writev 121 #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[5] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; res = syscall(SYS_pipe, /*pipefd=*/0x20001680ul); if (res != -1) { r[0] = *(uint32_t*)0x20001680; r[1] = *(uint32_t*)0x20001684; } memcpy((void*)0x20000480, "./file0\000", 8); res = syscall(SYS_open, /*file=*/0x20000480ul, /*flags=*/0x80000000000206ul, /*mode=*/0x4ebfac6bbaf7949ul); if (res != -1) r[2] = res; res = syscall(SYS_getpgrp); if (res != -1) r[3] = res; syscall(SYS_ptrace, /*request=*/9ul, /*pid=*/r[3], /*addr=*/0ul, /*data=*/0ul); syscall(SYS_writev, /*fd=*/-1, /*vec=*/0x20000200ul, /*vlen=*/0ul); syscall(SYS_fktrace, /*fd=*/r[2], /*ops=*/4ul, /*trpoints=*/0x40ul, /*pid=*/r[3]); syscall(SYS_fcntl, /*fd=*/r[1], /*cmd=*/0xaul, /*arg=*/-1); syscall(SYS___vfork14); res = syscall(SYS_open, /*file=*/0ul, /*flags=*/0x100ul, /*mode=*/0x4ebfac6bbaf7949ul); if (res != -1) r[4] = res; syscall(SYS_writev, /*fd=*/r[4], /*vec=*/0ul, /*vlen=*/0ul); syscall(SYS_fcntl, /*fd=*/r[4], /*cmd=*/0ul, /*arg=*/r[4]); *(uint16_t*)0x200001c0 = 1; *(uint8_t*)0x200001c2 = 0; *(uint32_t*)0x200001c4 = 0x4e23 + procid * 4; syscall(SYS_recvfrom, /*fd=*/r[0], /*buf=*/0x20000180ul, /*len=*/0xaul, /*f=*/0x2000ul, /*addr=*/0x200001c0ul, /*addrlen=*/8ul); syscall(SYS_read, /*fd=*/r[4], /*buf=*/0x20000140ul, /*count=*/4ul); } int main(void) { syscall(SYS_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000ul, /*prot=*/3ul, /*flags=*/0x1012ul, /*fd=*/-1, /*pad=*/0ul, /*offset=*/0ul); for (procid = 0; procid < 6; procid++) { if (fork() == 0) { loop(); } } sleep(1000000); return 0; }