// https://syzkaller.appspot.com/bug?id=101b7e71f53b37caf00bf159bd293d6d6512242a // 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_fcntl #define __NR_fcntl 25 #endif #ifndef __NR_mmap #define __NR_mmap 222 #endif #ifndef __NR_mount #define __NR_mount 40 #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 long syz_create_resource(volatile long val) { return val; } 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_tcp arguments: [ // domain: const = 0x2 (8 bytes) // type: const = 0x1 (8 bytes) // proto: const = 0x0 (4 bytes) // ] // returns sock_tcp res = syscall(__NR_socket, /*domain=*/2ul, /*type=*/1ul, /*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 = 0x260 (4 bytes) // hook_pre_routing: const = 0xffffffff (4 bytes) // hook_local_in: const = 0x0 (4 bytes) // hook_forward: const = 0x130 (4 bytes) // hook_local_out: const = 0x1c8 (4 bytes) // hook_post_routing: const = 0xffffffff (4 bytes) // underflow_pre_routing: const = 0xffffffff (4 bytes) // underflow_local_in: const = 0x98 (4 bytes) // underflow_forward: const = 0x130 (4 bytes) // underflow_local_out: const = 0x1c8 (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 { // ip: ipt_ip { // src: union ipv4_addr { // empty: const = 0x0 (4 bytes) // } // dst: union ipv4_addr { // empty: const = 0x0 (4 bytes) // } // smsk: ipv4_addr_mask_vals = 0x0 (4 bytes) // dmsk: ipv4_addr_mask_vals = 0x0 (4 bytes) // iniface: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00} (length 0x10) outiface: buffer: {00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x10) // iniface_mask: devname_mask { // lo: devname_mask_values = 0x0 (1 bytes) // pad = 0x0 (15 bytes) // } // outiface_mask: devname_mask { // lo: devname_mask_values = 0x0 (1 bytes) // pad = 0x0 (15 bytes) // } // proto: ipv4_types = 0x6 (2 bytes) // flags: ipt_ip_flags = 0x0 (1 bytes) // invflags: ipt_ip_invflags = 0x0 (1 bytes) // } // } // 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 { // inet: union xt_inet_targets { // SYNPROXY: xt_target_t["SYNPROXY", xt_synproxy_info, 0] // { // target_size: len = 0x28 (2 bytes) // name: buffer: {53 59 4e 50 52 4f 58 59 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_synproxy_info { // options: xt_synproxy_options = 0xf (1 bytes) // wscale: int8 = 0x7 (1 bytes) // mss: int16 = 0x5b4 (2 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 = 0xfffffffe (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 = 0xfffffffe (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 = 0xfffffffe (4 bytes) // pad = 0x0 (4 bytes) // } // } // } // } // } // } // len: len = 0x2c0 (8 bytes) // ] memcpy((void*)0x20000000, "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*)0x20000020 = 0xe; *(uint32_t*)0x20000024 = 4; *(uint32_t*)0x20000028 = 0x260; *(uint32_t*)0x2000002c = -1; *(uint32_t*)0x20000030 = 0; *(uint32_t*)0x20000034 = 0x130; *(uint32_t*)0x20000038 = 0x1c8; *(uint32_t*)0x2000003c = -1; *(uint32_t*)0x20000040 = -1; *(uint32_t*)0x20000044 = 0x98; *(uint32_t*)0x20000048 = 0x130; *(uint32_t*)0x2000004c = 0x1c8; *(uint32_t*)0x20000050 = -1; *(uint32_t*)0x20000054 = 4; *(uint64_t*)0x20000058 = 0; *(uint32_t*)0x20000060 = htobe32(0); *(uint32_t*)0x20000064 = htobe32(0); *(uint32_t*)0x20000068 = htobe32(0); *(uint32_t*)0x2000006c = htobe32(0); memset((void*)0x20000070, 0, 16); memset((void*)0x20000080, 0, 16); *(uint8_t*)0x20000090 = 0; *(uint8_t*)0x200000a0 = 0; *(uint16_t*)0x200000b0 = 6; *(uint8_t*)0x200000b2 = 0; *(uint8_t*)0x200000b3 = 0; *(uint32_t*)0x200000b4 = 0; *(uint16_t*)0x200000b8 = 0x70; *(uint16_t*)0x200000ba = 0x98; *(uint32_t*)0x200000bc = 0; *(uint64_t*)0x200000c0 = 0; *(uint64_t*)0x200000c8 = 0; *(uint16_t*)0x200000d0 = 0x28; memcpy((void*)0x200000d2, "SYNPROXY\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000", 29); *(uint8_t*)0x200000ef = 0; *(uint8_t*)0x200000f0 = 0xf; *(uint8_t*)0x200000f1 = 7; *(uint16_t*)0x200000f2 = 0x5b4; memset((void*)0x200000f8, 0, 84); *(uint32_t*)0x2000014c = 0; *(uint16_t*)0x20000150 = 0x70; *(uint16_t*)0x20000152 = 0x98; *(uint32_t*)0x20000154 = 0; *(uint64_t*)0x20000158 = 0; *(uint64_t*)0x20000160 = 0; *(uint16_t*)0x20000168 = 0x28; memset((void*)0x2000016a, 0, 29); *(uint8_t*)0x20000187 = 0; *(uint32_t*)0x20000188 = 0xfffffffe; memset((void*)0x20000190, 0, 84); *(uint32_t*)0x200001e4 = 0; *(uint16_t*)0x200001e8 = 0x70; *(uint16_t*)0x200001ea = 0x98; *(uint32_t*)0x200001ec = 0; *(uint64_t*)0x200001f0 = 0; *(uint64_t*)0x200001f8 = 0; *(uint16_t*)0x20000200 = 0x28; memset((void*)0x20000202, 0, 29); *(uint8_t*)0x2000021f = 0; *(uint32_t*)0x20000220 = 0xfffffffe; memset((void*)0x20000228, 0, 84); *(uint32_t*)0x2000027c = 0; *(uint16_t*)0x20000280 = 0x70; *(uint16_t*)0x20000282 = 0x98; *(uint32_t*)0x20000284 = 0; *(uint64_t*)0x20000288 = 0; *(uint64_t*)0x20000290 = 0; *(uint16_t*)0x20000298 = 0x28; memset((void*)0x2000029a, 0, 29); *(uint8_t*)0x200002b7 = 0; *(uint32_t*)0x200002b8 = 0xfffffffe; syscall(__NR_setsockopt, /*fd=*/r[0], /*level=*/0, /*opt=*/0x40, /*val=*/0x20000000ul, /*len=*/0x2c0ul); // fcntl$lock arguments: [ // fd: fd (resource) // cmd: fcntl_lock = 0x25 (8 bytes) // lock: nil // ] syscall(__NR_fcntl, /*fd=*/(intptr_t)-1, /*cmd=F_OFD_SETLK*/ 0x25ul, /*lock=*/0ul); // syz_create_resource$binfmt arguments: [ // file: nil // ] // returns ptr_binfmt_file syz_create_resource(/*file=*/0); // setsockopt$inet6_IPV6_HOPOPTS arguments: [ // fd: sock_in6 (resource) // level: const = 0x29 (4 bytes) // optname: const = 0x36 (4 bytes) // optval: nil // optlen: len = 0x8 (8 bytes) // ] syscall(__NR_setsockopt, /*fd=*/(intptr_t)-1, /*level=*/0x29, /*optname=*/0x36, /*optval=*/0ul, /*optlen=*/8ul); // mount$9p_fd arguments: [ // src: const = 0x0 (8 bytes) // dst: nil // type: nil // flags: mount_flags = 0x201820 (8 bytes) // opts: nil // ] syscall(__NR_mount, /*src=*/0ul, /*dst=*/0ul, /*type=*/0ul, /*flags=MS_REMOUNT|MS_RELATIME|MS_NODIRATIME|MS_BIND*/ 0x201820ul, /*opts=*/0ul); } 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; }