// https://syzkaller.appspot.com/bug?id=c905c82285226236abc44f3140e9290e96374cab // 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 #include 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[1] = {0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // setns arguments: [ // fd: fd_namespace (resource) // type: ns_type = 0x0 (8 bytes) // ] syscall(__NR_setns, /*fd=*/0xc9, /*type=*/0ul); // socket$inet_udp arguments: [ // domain: const = 0x2 (8 bytes) // type: const = 0x2 (8 bytes) // proto: const = 0x0 (4 bytes) // ] // returns sock_udp res = syscall(__NR_socket, /*domain=*/2ul, /*type=*/2ul, /*proto=*/0); if (res != -1) r[0] = res; // setsockopt$IPT_SO_SET_REPLACE arguments: [ // fd: sock_in (resource) // level: const = 0x0 (4 bytes) // opt: const = 0x40 (4 bytes) // val: ptr[in, ipt_replace] { // union ipt_replace { // filter: ipt_replace_t["filter", 3, 4, IPT_FILTER_VALID_HOOKS, // ipt_filter_matches, ipt_filter_targets, ipt_unused, ipt_hook, // ipt_hook, ipt_hook, ipt_unused, ipt_unused, ipt_hook, ipt_hook, // ipt_hook, ipt_unused] { // name: buffer: {66 69 6c 74 65 72 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x20) // valid_hooks: const = 0xe (4 bytes) // num_entries: const = 0x4 (4 bytes) // size: bytesize = 0x298 (4 bytes) // hook_pre_routing: const = 0xffffffff (4 bytes) // hook_local_in: const = 0x0 (4 bytes) // hook_forward: const = 0xd0 (4 bytes) // hook_local_out: const = 0x168 (4 bytes) // hook_post_routing: const = 0xffffffff (4 bytes) // underflow_pre_routing: const = 0xffffffff (4 bytes) // underflow_local_in: const = 0xd0 (4 bytes) // underflow_forward: const = 0x168 (4 bytes) // underflow_local_out: const = 0x200 (4 bytes) // underflow_post_routing: const = 0xffffffff (4 bytes) // num_counters: const = 0x4 (4 bytes) // counters: nil // entries: ipt_replace_entries[3, ipt_filter_matches, // ipt_filter_targets] { // entries: array[ipt_entry[ipt_filter_matches, // ipt_filter_targets]] { // ipt_entry[ipt_filter_matches, ipt_filter_targets] { // matches: ipt_entry_matches[ipt_filter_matches] { // ip: union ipt_ip_or_uncond { // uncond: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x54) // } // nfcache: const = 0x0 (4 bytes) // target_offset: len = 0xa8 (2 bytes) // next_offset: len = 0xd0 (2 bytes) // comefrom: const = 0x0 (4 bytes) // counters: xt_counters { // pcnt: const = 0x0 (8 bytes) // bcnt: const = 0x0 (8 bytes) // } // matches: array[ipt_filter_matches] { // union ipt_filter_matches { // common: union ipt_matches { // unspec: union xt_unspec_matches { // time: xt_entry_match_t["time", xt_time_info, 0] { // header: xt_entry_match["time", 0] { // match_size: len = 0x38 (2 bytes) // name: buffer: {74 69 6d 65 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00} (length 0x1d) revision: const = // 0x0 (1 bytes) // } // data: xt_time_info { // date_start: int32 = 0x0 (4 bytes) // date_stop: int32 = 0x7fffffff (4 bytes) // daytime_start: int32 = 0x0 (4 bytes) // daytime_stop: int32 = 0x1517f (4 bytes) // monthdays_match: int32 = 0xffffffff (4 bytes) // weekdays_match: int8 = 0xfe (1 bytes) // flags: xt_time_flags = 0x0 (1 bytes) // pad = 0x0 (2 bytes) // } // } // } // } // } // } // } // target: union ipt_filter_targets { // common: union ipt_targets { // unspec: union xt_unspec_targets { // STANDARD: xt_target_t["", flags[nf_verdicts, int32], // 0] { // target_size: len = 0x28 (2 bytes) // name: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} // (length 0x1d) revision: const = 0x0 (1 bytes) data: // nf_verdicts = 0xffffffff (4 bytes) pad = 0x0 (4 // bytes) // } // } // } // } // } // ipt_entry[ipt_filter_matches, ipt_filter_targets] { // matches: ipt_entry_matches[ipt_filter_matches] { // ip: union ipt_ip_or_uncond { // uncond: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x54) // } // nfcache: const = 0x0 (4 bytes) // target_offset: len = 0x70 (2 bytes) // next_offset: len = 0x98 (2 bytes) // comefrom: const = 0x0 (4 bytes) // counters: xt_counters { // pcnt: const = 0x0 (8 bytes) // bcnt: const = 0x0 (8 bytes) // } // matches: array[ipt_filter_matches] { // } // } // target: union ipt_filter_targets { // common: union ipt_targets { // unspec: union xt_unspec_targets { // STANDARD: xt_target_t["", flags[nf_verdicts, int32], // 0] { // target_size: len = 0x28 (2 bytes) // name: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} // (length 0x1d) revision: const = 0x0 (1 bytes) data: // nf_verdicts = 0xffffffff (4 bytes) pad = 0x0 (4 // bytes) // } // } // } // } // } // ipt_entry[ipt_filter_matches, ipt_filter_targets] { // matches: ipt_entry_matches[ipt_filter_matches] { // ip: union ipt_ip_or_uncond { // uncond: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x54) // } // nfcache: const = 0x0 (4 bytes) // target_offset: len = 0x70 (2 bytes) // next_offset: len = 0x98 (2 bytes) // comefrom: const = 0x0 (4 bytes) // counters: xt_counters { // pcnt: const = 0x0 (8 bytes) // bcnt: const = 0x0 (8 bytes) // } // matches: array[ipt_filter_matches] { // } // } // target: union ipt_filter_targets { // common: union ipt_targets { // unspec: union xt_unspec_targets { // STANDARD: xt_target_t["", flags[nf_verdicts, int32], // 0] { // target_size: len = 0x28 (2 bytes) // name: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} // (length 0x1d) revision: const = 0x0 (1 bytes) data: // nf_verdicts = 0xffffffff (4 bytes) pad = 0x0 (4 // bytes) // } // } // } // } // } // } // underflow: ipt_entry_underflow { // matches: ipt_entry_underflow_matches { // ip: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00} (length 0x54) nfcache: const = 0x0 // (4 bytes) target_offset: len = 0x70 (2 bytes) next_offset: // len = 0x98 (2 bytes) comefrom: const = 0x0 (4 bytes) // counters: xt_counters { // pcnt: const = 0x0 (8 bytes) // bcnt: const = 0x0 (8 bytes) // } // } // target: xt_target_t["", const[NF_ACCEPT_VERDICT, int32], 0] { // target_size: len = 0x28 (2 bytes) // name: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x1d) // revision: const = 0x0 (1 bytes) // data: const = 0xffffffff (4 bytes) // pad = 0x0 (4 bytes) // } // } // } // } // } // } // len: len = 0x1000 (8 bytes) // ] memcpy((void*)0x200000000000, "filter\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*)0x200000000020 = 0xe; *(uint32_t*)0x200000000024 = 4; *(uint32_t*)0x200000000028 = 0x298; *(uint32_t*)0x20000000002c = -1; *(uint32_t*)0x200000000030 = 0; *(uint32_t*)0x200000000034 = 0xd0; *(uint32_t*)0x200000000038 = 0x168; *(uint32_t*)0x20000000003c = -1; *(uint32_t*)0x200000000040 = -1; *(uint32_t*)0x200000000044 = 0xd0; *(uint32_t*)0x200000000048 = 0x168; *(uint32_t*)0x20000000004c = 0x200; *(uint32_t*)0x200000000050 = -1; *(uint32_t*)0x200000000054 = 4; *(uint64_t*)0x200000000058 = 0; memset((void*)0x200000000060, 0, 84); *(uint32_t*)0x2000000000b4 = 0; *(uint16_t*)0x2000000000b8 = 0xa8; *(uint16_t*)0x2000000000ba = 0xd0; *(uint32_t*)0x2000000000bc = 0; *(uint64_t*)0x2000000000c0 = 0; *(uint64_t*)0x2000000000c8 = 0; *(uint16_t*)0x2000000000d0 = 0x38; memcpy((void*)0x2000000000d2, "time\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", 29); *(uint8_t*)0x2000000000ef = 0; *(uint32_t*)0x2000000000f0 = 0; *(uint32_t*)0x2000000000f4 = 0x7fffffff; *(uint32_t*)0x2000000000f8 = 0; *(uint32_t*)0x2000000000fc = 0x1517f; *(uint32_t*)0x200000000100 = -1; *(uint8_t*)0x200000000104 = 0xfe; *(uint8_t*)0x200000000105 = 0; *(uint16_t*)0x200000000108 = 0x28; memset((void*)0x20000000010a, 0, 29); *(uint8_t*)0x200000000127 = 0; *(uint32_t*)0x200000000128 = -1; memset((void*)0x200000000130, 0, 84); *(uint32_t*)0x200000000184 = 0; *(uint16_t*)0x200000000188 = 0x70; *(uint16_t*)0x20000000018a = 0x98; *(uint32_t*)0x20000000018c = 0; *(uint64_t*)0x200000000190 = 0; *(uint64_t*)0x200000000198 = 0; *(uint16_t*)0x2000000001a0 = 0x28; memset((void*)0x2000000001a2, 0, 29); *(uint8_t*)0x2000000001bf = 0; *(uint32_t*)0x2000000001c0 = -1; memset((void*)0x2000000001c8, 0, 84); *(uint32_t*)0x20000000021c = 0; *(uint16_t*)0x200000000220 = 0x70; *(uint16_t*)0x200000000222 = 0x98; *(uint32_t*)0x200000000224 = 0; *(uint64_t*)0x200000000228 = 0; *(uint64_t*)0x200000000230 = 0; *(uint16_t*)0x200000000238 = 0x28; memset((void*)0x20000000023a, 0, 29); *(uint8_t*)0x200000000257 = 0; *(uint32_t*)0x200000000258 = -1; memset((void*)0x200000000260, 0, 84); *(uint32_t*)0x2000000002b4 = 0; *(uint16_t*)0x2000000002b8 = 0x70; *(uint16_t*)0x2000000002ba = 0x98; *(uint32_t*)0x2000000002bc = 0; *(uint64_t*)0x2000000002c0 = 0; *(uint64_t*)0x2000000002c8 = 0; *(uint16_t*)0x2000000002d0 = 0x28; memset((void*)0x2000000002d2, 0, 29); *(uint8_t*)0x2000000002ef = 0; *(uint32_t*)0x2000000002f0 = -1; syscall(__NR_setsockopt, /*fd=*/r[0], /*level=*/0, /*opt=*/0x40, /*val=*/0x200000000000ul, /*len=*/0x1000ul); } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); const char* reason; (void)reason; loop(); return 0; }