// https://syzkaller.appspot.com/bug?id=df466e1151a7e45dd880d8c7033f1ad48acebfb4 // 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_bpf #define __NR_bpf 321 #endif static unsigned long long procid; 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; } const int kInitNetNsFd = 201; static long syz_init_net_socket(volatile long domain, volatile long type, volatile long proto) { return syscall(__NR_socket, domain, type, proto); } 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[2] = {0xffffffffffffffff, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // setsockopt$inet6_IPV6_XFRM_POLICY arguments: [ // fd: sock_in6 (resource) // level: const = 0x29 (4 bytes) // optname: const = 0x43 (4 bytes) // optval: ptr[in, xfrm_filter] { // xfrm_filter { // info: xfrm_userpolicy_info { // sel: xfrm_selector { // daddr: union xfrm_address_t { // in: union ipv4_addr { // broadcast: const = 0xffffffff (4 bytes) // } // } // saddr: union xfrm_address_t { // in6: union ipv6_addr { // dev: ipv6_addr_t[netdev_addr_id] { // a0: const = 0xfe (1 bytes) // a1: const = 0x80 (1 bytes) // a2: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00} // (length 0xd) a3: int8 = 0x0 (1 bytes) // } // } // } // dport: int16be = 0x0 (2 bytes) // dport_mask: int16be = 0x0 (2 bytes) // sport: int16be = 0x0 (2 bytes) // sport_mask: int16be = 0x0 (2 bytes) // family: xfrm_family = 0x0 (2 bytes) // prefixlen_d: xfrm_prefixlens = 0x0 (1 bytes) // prefixlen_s: xfrm_prefixlens = 0x0 (1 bytes) // proto: ipv6_types = 0x0 (1 bytes) // pad = 0x0 (3 bytes) // ifindex: ifindex (resource) // user: uid (resource) // } // lft: xfrm_lifetime_cfg { // soft_byte_limit: int64 = 0x0 (8 bytes) // hard_byte_limit: int64 = 0x0 (8 bytes) // soft_packet_limit: int64 = 0x0 (8 bytes) // hard_packet_limit: int64 = 0x0 (8 bytes) // soft_add_expires_seconds: int64 = 0x0 (8 bytes) // hard_add_expires_seconds: int64 = 0x0 (8 bytes) // soft_use_expires_seconds: int64 = 0x0 (8 bytes) // hard_use_expires_seconds: int64 = 0x0 (8 bytes) // } // curlft: xfrm_lifetime_cur { // bytes: int64 = 0x0 (8 bytes) // packets: int64 = 0x0 (8 bytes) // add_time: int64 = 0x0 (8 bytes) // use_time: int64 = 0x0 (8 bytes) // } // priority: int32 = 0x0 (4 bytes) // index: int32 = 0x0 (4 bytes) // dir: xfrm_policy_dir = 0x0 (1 bytes) // action: xfrm_policy_actions = 0x0 (1 bytes) // flags: xfrm_policy_flags = 0x0 (1 bytes) // share: xfrm_policy_shares = 0x0 (1 bytes) // pad = 0x0 (4 bytes) // } // tmpl: xfrm_user_tmpl { // id: xfrm_id { // daddr: union xfrm_address_t { // in6: union ipv6_addr { // empty: ipv6_addr_empty { // a0: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00} (length 0x10) // } // } // } // spi: int32be = 0x0 (4 bytes) // proto: xfrm_proto = 0x0 (1 bytes) // pad = 0x0 (3 bytes) // } // family: xfrm_family = 0x0 (2 bytes) // pad = 0x0 (2 bytes) // saddr: union xfrm_address_t { // in6: union ipv6_addr { // private1: ipv6_addr_private[1] { // a0: const = 0xfc (1 bytes) // a1: const = 0x1 (1 bytes) // a2: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00} (length // 0xd) a3: int8 = 0x0 (1 bytes) // } // } // } // reqid: int32 = 0x0 (4 bytes) // mode: xfrm_mode = 0x0 (1 bytes) // share: xfrm_policy_shares = 0x0 (1 bytes) // optional: int8 = 0x0 (1 bytes) // pad = 0x0 (1 bytes) // aalgos: int32 = 0x0 (4 bytes) // ealgos: int32 = 0x0 (4 bytes) // calgos: int32 = 0x0 (4 bytes) // } // } // } // optlen: len = 0xe8 (8 bytes) // ] *(uint32_t*)0x200000000340 = htobe32(-1); *(uint8_t*)0x200000000350 = 0xfe; *(uint8_t*)0x200000000351 = 0x80; memset((void*)0x200000000352, 0, 13); *(uint8_t*)0x20000000035f = 0; *(uint16_t*)0x200000000360 = htobe16(0); *(uint16_t*)0x200000000362 = htobe16(0); *(uint16_t*)0x200000000364 = htobe16(0); *(uint16_t*)0x200000000366 = htobe16(0); *(uint16_t*)0x200000000368 = 0; *(uint8_t*)0x20000000036a = 0; *(uint8_t*)0x20000000036b = 0; *(uint8_t*)0x20000000036c = 0; *(uint32_t*)0x200000000370 = 0; *(uint32_t*)0x200000000374 = 0; *(uint64_t*)0x200000000378 = 0; *(uint64_t*)0x200000000380 = 0; *(uint64_t*)0x200000000388 = 0; *(uint64_t*)0x200000000390 = 0; *(uint64_t*)0x200000000398 = 0; *(uint64_t*)0x2000000003a0 = 0; *(uint64_t*)0x2000000003a8 = 0; *(uint64_t*)0x2000000003b0 = 0; *(uint64_t*)0x2000000003b8 = 0; *(uint64_t*)0x2000000003c0 = 0; *(uint64_t*)0x2000000003c8 = 0; *(uint64_t*)0x2000000003d0 = 0; *(uint32_t*)0x2000000003d8 = 0; *(uint32_t*)0x2000000003dc = 0; *(uint8_t*)0x2000000003e0 = 0; *(uint8_t*)0x2000000003e1 = 0; *(uint8_t*)0x2000000003e2 = 0; *(uint8_t*)0x2000000003e3 = 0; memset((void*)0x2000000003e8, 0, 16); *(uint32_t*)0x2000000003f8 = htobe32(0); *(uint8_t*)0x2000000003fc = 0; *(uint16_t*)0x200000000400 = 0; *(uint8_t*)0x200000000404 = 0xfc; *(uint8_t*)0x200000000405 = 1; memset((void*)0x200000000406, 0, 13); *(uint8_t*)0x200000000413 = 0; *(uint32_t*)0x200000000414 = 0; *(uint8_t*)0x200000000418 = 0; *(uint8_t*)0x200000000419 = 0; *(uint8_t*)0x20000000041a = 0; *(uint32_t*)0x20000000041c = 0; *(uint32_t*)0x200000000420 = 0; *(uint32_t*)0x200000000424 = 0; syscall(__NR_setsockopt, /*fd=*/(intptr_t)-1, /*level=*/0x29, /*optname=*/0x43, /*optval=*/0x200000000340ul, /*optlen=*/0xe8ul); // openat$nci arguments: [ // fd: const = 0xffffffffffffff9c (8 bytes) // file: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 76 69 72 74 75 61 6c 5f 6e 63 69 00} (length // 0x11) // } // flags: const = 0x2 (4 bytes) // mode: const = 0x0 (2 bytes) // ] // returns fd_nci memcpy((void*)0x200000000240, "/dev/virtual_nci\000", 17); res = syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0x200000000240ul, /*flags=*/2, /*mode=*/0); if (res != -1) r[0] = res; // write$nci arguments: [ // fd: fd_nci (resource) // data: nil // len: bytesize = 0xc (8 bytes) // ] syscall(__NR_write, /*fd=*/r[0], /*data=*/0ul, /*len=*/0xcul); // bpf$MAP_CREATE arguments: [ // cmd: const = 0x0 (8 bytes) // arg: nil // size: len = 0x50 (8 bytes) // ] // returns fd_bpf_map syscall(__NR_bpf, /*cmd=*/0ul, /*arg=*/0ul, /*size=*/0x50ul); // bpf$BPF_BTF_LOAD arguments: [ // cmd: const = 0x12 (8 bytes) // arg: nil // size: len = 0x0 (8 bytes) // ] // returns fd_btf syscall(__NR_bpf, /*cmd=*/0x12ul, /*arg=*/0ul, /*size=*/0ul); // bpf$BPF_BTF_GET_FD_BY_ID arguments: [ // cmd: const = 0x13 (8 bytes) // arg: ptr[in, bpf_btf_id] { // bpf_btf_id (resource) // } // size: len = 0x4 (8 bytes) // ] // returns fd_btf *(uint32_t*)0x200000000400 = 0; syscall(__NR_bpf, /*cmd=*/0x13ul, /*arg=*/0x200000000400ul, /*size=*/4ul); // syz_init_net_socket$nl_generic arguments: [ // domain: const = 0x10 (8 bytes) // type: const = 0x3 (8 bytes) // proto: const = 0x10 (8 bytes) // ] // returns sock_nl_generic_init res = -1; res = syz_init_net_socket(/*domain=*/0x10, /*type=*/3, /*proto=*/0x10); if (res != -1) r[1] = res; // sendmsg$NFC_CMD_START_POLL arguments: [ // fd: sock_nl_generic_init (resource) // msg: nil // f: send_flags = 0x40 (8 bytes) // ] syscall(__NR_sendmsg, /*fd=*/r[1], /*msg=*/0ul, /*f=MSG_DONTWAIT*/ 0x40ul); } 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; for (procid = 0; procid < 5; procid++) { if (fork() == 0) { loop(); } } sleep(1000000); return 0; }