// 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 #ifndef __NR_bpf #define __NR_bpf 321 #endif 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 bool write_file(const char* file, const char* what, ...) { char buf[1024]; va_list args; va_start(args, what); vsnprintf(buf, sizeof(buf), what, args); va_end(args); buf[sizeof(buf) - 1] = 0; int len = strlen(buf); int fd = open(file, O_WRONLY | O_CLOEXEC); if (fd == -1) return false; if (write(fd, buf, len) != len) { int err = errno; close(fd); errno = err; return false; } close(fd); return true; } static void kill_and_wait(int pid, int* status) { kill(-pid, SIGKILL); kill(pid, SIGKILL); for (int i = 0; i < 100; i++) { if (waitpid(-1, status, WNOHANG | __WALL) == pid) return; usleep(1000); } DIR* dir = opendir("/sys/fs/fuse/connections"); if (dir) { for (;;) { struct dirent* ent = readdir(dir); if (!ent) break; if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) continue; char abort[300]; snprintf(abort, sizeof(abort), "/sys/fs/fuse/connections/%s/abort", ent->d_name); int fd = open(abort, O_WRONLY); if (fd == -1) { continue; } if (write(fd, abort, 1) < 0) { } close(fd); } closedir(dir); } else { } while (waitpid(-1, status, __WALL) != pid) { } } static void setup_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); write_file("/proc/self/oom_score_adj", "1000"); } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { int iter = 0; for (;; iter++) { int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { setup_test(); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } } } uint64_t r[4] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } res = syscall(__NR_socket, /*domain=*/0x28ul, /*type=*/1ul, /*proto=*/0); if (res != -1) r[0] = res; *(uint16_t*)0x20000040 = 0x28; *(uint16_t*)0x20000042 = 0; *(uint32_t*)0x20000044 = 0x2710; *(uint32_t*)0x20000048 = 1; *(uint32_t*)0x2000004c = 0; syscall(__NR_bind, /*fd=*/r[0], /*addr=*/0x20000040ul, /*addrlen=*/0x10ul); syscall(__NR_listen, /*fd=*/r[0], /*backlog=*/0); res = syscall(__NR_socket, /*domain=*/0x28ul, /*type=*/1ul, /*proto=*/0); if (res != -1) r[1] = res; *(uint16_t*)0x20000640 = 0x28; *(uint16_t*)0x20000642 = 0; *(uint32_t*)0x20000644 = 0x2710; *(uint32_t*)0x20000648 = -1; *(uint32_t*)0x2000064c = 0; syscall(__NR_connect, /*fd=*/r[1], /*addr=*/0x20000640ul, /*addrlen=*/0x10ul); res = syscall(__NR_accept, /*fd=*/r[0], /*peer=*/0ul, /*peerlen=*/0ul); if (res != -1) r[2] = res; *(uint64_t*)0x20000080 = 0x20000400; memcpy((void*)0x20000400, "\x3a\x85\xe1\x31\x00\xc2\x4f\xdb\xfa\x60\x90\x63\xd0\xae\x5f\x84\x13" "\x0b\x90\x17\x4c\x99\x68\x8d\x8b\x6f\xa0\x07\x20\xbc\x7c\x14\xf7\x56" "\x78\xdf\x4e\x70\x75\x83\x7c\x33\x54\x1a\xb4\x86\xe5\x81\x7e\xfd\xe6" "\x1c\xc9\x93\xe2\x8a\xe9\x2a\x86\x6d\xe7\x08\x88\x62\x6a\x64\x67\x6a" "\xce\x9c\xa3\x91\x02\x2f\xa0\xe7\x50\xb7\x7d\x0c\x9a\xf1\x0a\xaf\xe0" "\xa3\x6c\x7a\xd4\x30\x9c\xf6\xac\x8a\xb3\xbe\x4b\x2f\x85\x4f\xde\xbe" "\x1d\xdc\xe6\x31\x3a\xb0\x94\x1f\xa2\xed\xad\x31\x4f\xbd\x21\x30\x78" "\xe7\x77\x0a\xea\xb7\x07\x23\x2a\xd6\x3d\x67\xb4\x6b\x68\x93\xd9\xa8" "\xca\x82\x6a\xf8\xd1\x5e\x95\x6d\x82\x73\x91\xe6\xdf\x9f\x35\x32\xdf" "\x60\x97\x11\x23\xf5\x6f\xae\x10\x14\xdd\x44\xb8\x6e\x1e\x6b\xbe\x73" "\x92\xbb\x80\x82\x40\xa0\xb2\x40\x60\x84\x0e\x4b\xe8\x2d\xca\x47\x73" "\xbb\xa1\xa8\x0b\xe5\x31\xcd\xc6\x64\x02\x63\xfb\x24\xa9\xc3\x5f\x73" "\xa1\xd5\x19\x9f\x16\x25\x7b\xcb\xb4\x71\x50\x79\xb6\x58\x07", 219); *(uint64_t*)0x20000088 = 0xdb; *(uint64_t*)0x20000090 = 0; *(uint64_t*)0x20000098 = 0; *(uint64_t*)0x200000a0 = 0; *(uint64_t*)0x200000a8 = 0; *(uint64_t*)0x200000b0 = 0; *(uint64_t*)0x200000b8 = 0; *(uint64_t*)0x200000c0 = 0; *(uint64_t*)0x200000c8 = 0; *(uint64_t*)0x200000d0 = 0; *(uint64_t*)0x200000d8 = 0; *(uint64_t*)0x200000e0 = 0; *(uint64_t*)0x200000e8 = 0; syscall(__NR_writev, /*fd=*/r[1], /*vec=*/0x20000080ul, /*vlen=*/7ul); *(uint32_t*)0x20000580 = 0x12; *(uint32_t*)0x20000584 = 4; *(uint32_t*)0x20000588 = 4; *(uint32_t*)0x2000058c = 0xa4; *(uint32_t*)0x20000590 = 0; *(uint32_t*)0x20000594 = -1; *(uint32_t*)0x20000598 = 0; memset((void*)0x2000059c, 0, 16); *(uint32_t*)0x200005ac = 0; *(uint32_t*)0x200005b0 = -1; *(uint32_t*)0x200005b4 = 0; *(uint32_t*)0x200005b8 = 0; *(uint32_t*)0x200005bc = 0; *(uint64_t*)0x200005c0 = 0; res = syscall(__NR_bpf, /*cmd=*/0ul, /*arg=*/0x20000580ul, /*size=*/0x48ul); if (res != -1) r[3] = res; *(uint32_t*)0x20000140 = r[3]; *(uint64_t*)0x20000148 = 0x20000300; *(uint64_t*)0x20000150 = 0x200002c0; *(uint32_t*)0x200002c0 = r[2]; *(uint64_t*)0x20000158 = 0; syscall(__NR_bpf, /*cmd=*/2ul, /*arg=*/0x20000140ul, /*size=*/0x47ul); *(uint64_t*)0x200003c0 = 0; *(uint32_t*)0x200003c8 = 0; *(uint64_t*)0x200003d0 = 0x20000500; *(uint64_t*)0x20000500 = 0x20000300; *(uint64_t*)0x20000508 = 0x92; *(uint64_t*)0x200003d8 = 1; *(uint64_t*)0x200003e0 = 0; *(uint64_t*)0x200003e8 = 0; *(uint32_t*)0x200003f0 = 0; syscall(__NR_recvmsg, /*fd=*/r[2], /*msg=*/0x200003c0ul, /*f=*/0ul, 0); } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x21000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1, /*offset=*/0ul); const char* reason; (void)reason; loop(); return 0; }