// https://syzkaller.appspot.com/bug?id=0b210638616bb68109e9642158d4c0072770ae1c // 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 #ifndef __NR_mmap #define __NR_mmap 222 #endif #ifndef __NR_setns #define __NR_setns 268 #endif #ifndef __NR_setsockopt #define __NR_setsockopt 208 #endif #ifndef __NR_socket #define __NR_socket 198 #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[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_icmp_raw arguments: [ // domain: const = 0x2 (8 bytes) // type: const = 0x3 (8 bytes) // proto: const = 0x1 (4 bytes) // ] // returns sock_icmp res = syscall(__NR_socket, /*domain=*/2ul, /*type=*/3ul, /*proto=*/1); 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 { // raw: ipt_replace_t["raw", 2, 3, IPT_RAW_VALID_HOOKS, // ipt_raw_matches, ipt_raw_targets, ipt_hook, ipt_unused, ipt_unused, // ipt_hook, ipt_unused, ipt_hook, ipt_unused, ipt_unused, ipt_hook, // ipt_unused] { // name: buffer: {72 61 77 00 00 00 00 00 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 = 0x9 (4 bytes) // num_entries: const = 0x3 (4 bytes) // size: bytesize = 0x220 (4 bytes) // hook_pre_routing: const = 0x0 (4 bytes) // hook_local_in: const = 0xffffffff (4 bytes) // hook_forward: const = 0xffffffff (4 bytes) // hook_local_out: const = 0x188 (4 bytes) // hook_post_routing: const = 0xffffffff (4 bytes) // underflow_pre_routing: const = 0xf0 (4 bytes) // underflow_local_in: const = 0xffffffff (4 bytes) // underflow_forward: const = 0xffffffff (4 bytes) // underflow_local_out: const = 0x188 (4 bytes) // underflow_post_routing: const = 0xffffffff (4 bytes) // num_counters: const = 0x3 (4 bytes) // counters: nil // entries: ipt_replace_entries[2, ipt_raw_matches, ipt_raw_targets] // { // entries: array[ipt_entry[ipt_raw_matches, ipt_raw_targets]] { // ipt_entry[ipt_raw_matches, ipt_raw_targets] { // matches: ipt_entry_matches[ipt_raw_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 = 0xc8 (2 bytes) // next_offset: len = 0xf0 (2 bytes) // comefrom: const = 0x0 (4 bytes) // counters: xt_counters { // pcnt: const = 0x0 (8 bytes) // bcnt: const = 0x0 (8 bytes) // } // matches: array[ipt_raw_matches] { // union ipt_raw_matches { // common: union ipt_matches { // inet: union xt_inet_matches { // hashlimit1: xt_entry_match_t["hashlimit", // xt_hashlimit_mtinfo1, 1] { // header: xt_entry_match["hashlimit", 1] { // match_size: len = 0x58 (2 bytes) // name: buffer: {68 61 73 68 6c 69 6d 69 74 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00} (length 0x1d) revision: const = // 0x1 (1 bytes) // } // data: xt_hashlimit_mtinfo1 { // name: buffer: {6c 6f 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00} (length 0x10) cfg: // hashlimit_cfg1 { // mode: xt_hashlimit_modes = 0x0 (4 bytes) // avg: int32 = 0x3e8 (4 bytes) // burst: int32 = 0x5 (4 bytes) // size: int32 = 0x8 (4 bytes) // max: int32 = 0x40 (4 bytes) // gc_interval: int32 = 0x3e8 (4 bytes) // expire: int32 = 0x3e8 (4 bytes) // srcmask: xt_hashlimit_mask = 0x0 (1 bytes) // dstmask: xt_hashlimit_mask = 0x0 (1 bytes) // pad = 0x0 (2 bytes) // } // hinfo: align64[intptr] { // v: intptr = 0x0 (8 bytes) // } // } // } // } // } // } // } // } // target: union ipt_raw_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 = 0xffffffffffffffff (4 bytes) pad = 0x0 // (4 bytes) // } // } // } // } // } // ipt_entry[ipt_raw_matches, ipt_raw_targets] { // matches: ipt_entry_matches[ipt_raw_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_raw_matches] { // } // } // target: union ipt_raw_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 = 0xffffffffffffffff (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 = 0xffffffffffffffff (4 bytes) // pad = 0x0 (4 bytes) // } // } // } // } // } // } // len: len = 0x280 (8 bytes) // ] memcpy((void*)0x20000d40, "raw\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\000", 32); *(uint32_t*)0x20000d60 = 9; *(uint32_t*)0x20000d64 = 3; *(uint32_t*)0x20000d68 = 0x220; *(uint32_t*)0x20000d6c = 0; *(uint32_t*)0x20000d70 = -1; *(uint32_t*)0x20000d74 = -1; *(uint32_t*)0x20000d78 = 0x188; *(uint32_t*)0x20000d7c = -1; *(uint32_t*)0x20000d80 = 0xf0; *(uint32_t*)0x20000d84 = -1; *(uint32_t*)0x20000d88 = -1; *(uint32_t*)0x20000d8c = 0x188; *(uint32_t*)0x20000d90 = -1; *(uint32_t*)0x20000d94 = 3; *(uint64_t*)0x20000d98 = 0; memset((void*)0x20000da0, 0, 84); *(uint32_t*)0x20000df4 = 0; *(uint16_t*)0x20000df8 = 0xc8; *(uint16_t*)0x20000dfa = 0xf0; *(uint32_t*)0x20000dfc = 0; *(uint64_t*)0x20000e00 = 0; *(uint64_t*)0x20000e08 = 0; *(uint16_t*)0x20000e10 = 0x58; memcpy((void*)0x20000e12, "hashlimit\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000", 29); *(uint8_t*)0x20000e2f = 1; memcpy((void*)0x20000e30, "lo\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 16); *(uint32_t*)0x20000e40 = 0; *(uint32_t*)0x20000e44 = 0x3e8; *(uint32_t*)0x20000e48 = 5; *(uint32_t*)0x20000e4c = 8; *(uint32_t*)0x20000e50 = 0x40; *(uint32_t*)0x20000e54 = 0x3e8; *(uint32_t*)0x20000e58 = 0x3e8; *(uint8_t*)0x20000e5c = 0; *(uint8_t*)0x20000e5d = 0; *(uint64_t*)0x20000e60 = 0; *(uint16_t*)0x20000e68 = 0x28; memset((void*)0x20000e6a, 0, 29); *(uint8_t*)0x20000e87 = 0; *(uint32_t*)0x20000e88 = -1; memset((void*)0x20000e90, 0, 84); *(uint32_t*)0x20000ee4 = 0; *(uint16_t*)0x20000ee8 = 0x70; *(uint16_t*)0x20000eea = 0x98; *(uint32_t*)0x20000eec = 0; *(uint64_t*)0x20000ef0 = 0; *(uint64_t*)0x20000ef8 = 0; *(uint16_t*)0x20000f00 = 0x28; memset((void*)0x20000f02, 0, 29); *(uint8_t*)0x20000f1f = 0; *(uint32_t*)0x20000f20 = -1; memset((void*)0x20000f28, 0, 84); *(uint32_t*)0x20000f7c = 0; *(uint16_t*)0x20000f80 = 0x70; *(uint16_t*)0x20000f82 = 0x98; *(uint32_t*)0x20000f84 = 0; *(uint64_t*)0x20000f88 = 0; *(uint64_t*)0x20000f90 = 0; *(uint16_t*)0x20000f98 = 0x28; memset((void*)0x20000f9a, 0, 29); *(uint8_t*)0x20000fb7 = 0; *(uint32_t*)0x20000fb8 = -1; syscall(__NR_setsockopt, /*fd=*/r[0], /*level=*/0, /*opt=*/0x40, /*val=*/0x20000d40ul, /*len=*/0x280ul); } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x20000000ul, /*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=*/0x21000000ul, /*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; }