// https://syzkaller.appspot.com/bug?id=d4463a2d3563cdc5823b22d4e115144d0af7e88c // 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; } #define BITMASK(bf_off, bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type, htobe, addr, val, bf_off, bf_len) \ *(type*)(addr) = \ htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | \ (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) 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[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // socket$nl_generic arguments: [ // domain: const = 0x10 (8 bytes) // type: const = 0x3 (8 bytes) // proto: const = 0x10 (4 bytes) // ] // returns sock_nl_generic res = syscall(__NR_socket, /*domain=*/0x10ul, /*type=*/3ul, /*proto=*/0x10); if (res != -1) r[0] = res; // sendmsg$nl_generic arguments: [ // fd: sock_nl_generic (resource) // msg: ptr[in, msghdr_netlink[netlink_msg_t[netlink_random_msg_type, // genlmsghdr, nl_generic_attr]]] { // msghdr_netlink[netlink_msg_t[netlink_random_msg_type, genlmsghdr, // nl_generic_attr]] { // addr: nil // addrlen: len = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // vec: ptr[in, iovec[in, netlink_msg_t[netlink_random_msg_type, // genlmsghdr, nl_generic_attr]]] { // iovec[in, netlink_msg_t[netlink_random_msg_type, genlmsghdr, // nl_generic_attr]] { // addr: ptr[in, netlink_msg_t[netlink_random_msg_type, genlmsghdr, // nl_generic_attr]] { // netlink_msg_t[netlink_random_msg_type, genlmsghdr, // nl_generic_attr] { // len: len = 0x14 (4 bytes) // type: int16 = 0x29 (2 bytes) // flags: netlink_msg_flags = 0x1 (2 bytes) // seq: int32 = 0x70bd27 (4 bytes) // pid: int32 = 0x25dfdbfd (4 bytes) // payload: genlmsghdr { // cmd: int8 = 0x6 (1 bytes) // version: const = 0x0 (1 bytes) // reserved: const = 0x0 (2 bytes) // } // attrs: array[nl_generic_attr] { // } // } // } // len: len = 0x14 (8 bytes) // } // } // vlen: const = 0x1 (8 bytes) // ctrl: const = 0x0 (8 bytes) // ctrllen: const = 0x0 (8 bytes) // f: send_flags = 0x2204c85c (4 bytes) // pad = 0x0 (4 bytes) // } // } // f: send_flags = 0x20040000 (8 bytes) // ] *(uint64_t*)0x200000000900 = 0; *(uint32_t*)0x200000000908 = 0; *(uint64_t*)0x200000000910 = 0x200000000940; *(uint64_t*)0x200000000940 = 0x200000000980; *(uint32_t*)0x200000000980 = 0x14; *(uint16_t*)0x200000000984 = 0x29; *(uint16_t*)0x200000000986 = 1; *(uint32_t*)0x200000000988 = 0x70bd27; *(uint32_t*)0x20000000098c = 0x25dfdbfd; *(uint8_t*)0x200000000990 = 6; *(uint8_t*)0x200000000991 = 0; *(uint16_t*)0x200000000992 = 0; *(uint64_t*)0x200000000948 = 0x14; *(uint64_t*)0x200000000918 = 1; *(uint64_t*)0x200000000920 = 0; *(uint64_t*)0x200000000928 = 0; *(uint32_t*)0x200000000930 = 0x2204c85c; syscall(__NR_sendmsg, /*fd=*/r[0], /*msg=*/0x200000000900ul, /*f=MSG_FASTOPEN|MSG_BATCH*/ 0x20040000ul); // bpf$PROG_LOAD arguments: [ // cmd: const = 0x5 (8 bytes) // arg: ptr[in, bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], fd_bpf_prog[opt]]] { // bpf_prog_t[flags[bpf_prog_type, int32], bpf_prog_attach_types, // bpf_btf_id[opt], fd_bpf_prog[opt]] { // type: bpf_prog_type = 0x6 (4 bytes) // ninsn: bytesize8 = 0x4 (4 bytes) // insns: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {18 02 00 00 00 00 00 00 00 00 00 00 00 00 00 // 30 85 00 00 00 2c 00 00 00 95 00 00 00 00 00 00 00 2b 40 03 fe // 37 a0 77 ae 55 f5 2c 0d 80 a2 64 9b ac a8 53 09 be 96 d5 a4 5b // bb db 5f f7 ff ff ff d0 75 b3 ee e1 44 73 f5 1b e9 8d b7 ef bb // 05 98 42 ba dc fc 81 36 44 70 e8 e0 4a cb 80 7f bb ab c6 8a bd // cc e9 f6 72 b6 bb 61 c3 02 df d5 c1 10 71 ad ac 29 fd 64 d3 3a // 35 02 fb eb 1e d9 9d d0 e7 92 f2 4c 42 0b fc c2 63 54 21 d3 39 // ad 52 1d 69 53 b1 13 78 50 d9 e9 eb f6 5e e9 88 ea 2d be e5 28 // 67 8e b4 7e fb 7b 3f 19 04 6c 6f 1b d1 bf 56 e5 85 3e d9 61 37 // f9 5b 3a 11 95 4e d1 c8 a8 67 64 68 cf 24 05 e4 87 23 d4 b1 // ff} (length 0xcc) // } // } // } // license: ptr[in, buffer] { // buffer: {47 50 4c 00} (length 0x4) // } // loglev: int32 = 0x0 (4 bytes) // logsize: len = 0x1000 (4 bytes) // log: ptr[out, buffer] { // buffer: (DirOut) // } // kern_version: bpf_kern_version = 0x0 (4 bytes) // flags: bpf_prog_load_flags = 0x0 (4 bytes) // prog_name: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} // (length 0x10) prog_ifindex: ifindex (resource) expected_attach_type: // union bpf_prog_attach_types { // xdp: xdp_attach_types = 0x0 (4 bytes) // } // btf_fd: fd_btf (resource) // func_info_rec_size: const = 0x8 (4 bytes) // func_info: nil // func_info_cnt: len = 0x0 (4 bytes) // line_info_rec_size: const = 0x10 (4 bytes) // line_info: nil // line_info_cnt: len = 0x0 (4 bytes) // attach_btf_id: bpf_btf_id (resource) // attach_prog_fd: fd_bpf_prog (resource) // core_relo_cnt: len = 0x0 (4 bytes) // fd_array: nil // core_relos: nil // core_relo_rec_size: const = 0x10 (4 bytes) // log_true_size: int32 = 0x0 (4 bytes) // prog_token_fd: union _bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], // fd_bpf_prog[opt]]_prog_token_fd_wrapper { // void: buffer: {} (length 0x0) // } // pad: union _bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], // fd_bpf_prog[opt]]_pad_wrapper { // value: const = 0x0 (4 bytes) // } // } // } // size: len = 0x18 (8 bytes) // ] // returns fd_bpf_prog *(uint32_t*)0x200000000100 = 6; *(uint32_t*)0x200000000104 = 4; *(uint64_t*)0x200000000108 = 0x2000000001c0; memcpy((void*)0x2000000001c0, "\x18\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x30\x85" "\x00\x00\x00\x2c\x00\x00\x00\x95\x00\x00\x00\x00\x00\x00\x00\x2b\x40" "\x03\xfe\x37\xa0\x77\xae\x55\xf5\x2c\x0d\x80\xa2\x64\x9b\xac\xa8\x53" "\x09\xbe\x96\xd5\xa4\x5b\xbb\xdb\x5f\xf7\xff\xff\xff\xd0\x75\xb3\xee" "\xe1\x44\x73\xf5\x1b\xe9\x8d\xb7\xef\xbb\x05\x98\x42\xba\xdc\xfc\x81" "\x36\x44\x70\xe8\xe0\x4a\xcb\x80\x7f\xbb\xab\xc6\x8a\xbd\xcc\xe9\xf6" "\x72\xb6\xbb\x61\xc3\x02\xdf\xd5\xc1\x10\x71\xad\xac\x29\xfd\x64\xd3" "\x3a\x35\x02\xfb\xeb\x1e\xd9\x9d\xd0\xe7\x92\xf2\x4c\x42\x0b\xfc\xc2" "\x63\x54\x21\xd3\x39\xad\x52\x1d\x69\x53\xb1\x13\x78\x50\xd9\xe9\xeb" "\xf6\x5e\xe9\x88\xea\x2d\xbe\xe5\x28\x67\x8e\xb4\x7e\xfb\x7b\x3f\x19" "\x04\x6c\x6f\x1b\xd1\xbf\x56\xe5\x85\x3e\xd9\x61\x37\xf9\x5b\x3a\x11" "\x95\x4e\xd1\xc8\xa8\x67\x64\x68\xcf\x24\x05\xe4\x87\x23\xd4\xb1\xff", 204); *(uint64_t*)0x200000000110 = 0x2000000002c0; memcpy((void*)0x2000000002c0, "GPL\000", 4); *(uint32_t*)0x200000000118 = 0; *(uint32_t*)0x20000000011c = 0x1000; *(uint64_t*)0x200000000120 = 0x200000000300; *(uint32_t*)0x200000000128 = 0; *(uint32_t*)0x20000000012c = 0; memset((void*)0x200000000130, 0, 16); *(uint32_t*)0x200000000140 = 0; *(uint32_t*)0x200000000144 = 0; *(uint32_t*)0x200000000148 = -1; *(uint32_t*)0x20000000014c = 8; *(uint64_t*)0x200000000150 = 0; *(uint32_t*)0x200000000158 = 0; *(uint32_t*)0x20000000015c = 0x10; *(uint64_t*)0x200000000160 = 0; *(uint32_t*)0x200000000168 = 0; *(uint32_t*)0x20000000016c = 0; *(uint32_t*)0x200000000170 = -1; *(uint32_t*)0x200000000174 = 0; *(uint64_t*)0x200000000178 = 0; *(uint64_t*)0x200000000180 = 0; *(uint32_t*)0x200000000188 = 0x10; *(uint32_t*)0x20000000018c = 0; *(uint32_t*)0x200000000190 = 0; res = syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0x200000000100ul, /*size=*/0x18ul); if (res != -1) r[1] = res; // socket$nl_route arguments: [ // domain: const = 0x10 (8 bytes) // type: const = 0x3 (8 bytes) // proto: const = 0x0 (4 bytes) // ] // returns sock_nl_route res = syscall(__NR_socket, /*domain=*/0x10ul, /*type=*/3ul, /*proto=*/0); if (res != -1) r[2] = res; // sendmsg$nl_route arguments: [ // fd: sock_nl_route (resource) // msg: ptr[in, msghdr_netlink[netlink_msg_route]] { // msghdr_netlink[netlink_msg_route] { // addr: nil // addrlen: len = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // vec: ptr[in, iovec[in, netlink_msg_route]] { // iovec[in, netlink_msg_route] { // addr: ptr[in, netlink_msg_route] { // union netlink_msg_route { // newlink: netlink_msg_t[const[RTM_NEWLINK, int16], // ifinfomsg[AF_UNSPEC], ifla_policy] { // len: len = 0x34 (4 bytes) // type: const = 0x10 (2 bytes) // flags: netlink_msg_flags = 0x801 (2 bytes) // seq: int32 = 0x100000 (4 bytes) // pid: int32 = 0x0 (4 bytes) // payload: ifinfomsg[AF_UNSPEC] { // ifi_family: const = 0x0 (1 bytes) // __ifi_pad: const = 0x0 (1 bytes) // ifi_type: const = 0x0 (2 bytes) // ifi_index: ifindex (resource) // ifi_flags: net_device_flags = 0x0 (4 bytes) // ifi_change: net_device_flags = 0x0 (4 bytes) // } // attrs: array[ifla_policy] { // union ifla_policy { // IFLA_XDP: nlattr_tt[const[IFLA_XDP, int16:14], 0, 1, // array[ifla_xdp_policy]] { // nla_len: offsetof = 0xc (2 bytes) // nla_type: const = 0x2b (1 bytes) // NLA_F_NET_BYTEORDER: const = 0x0 (0 bytes) // NLA_F_NESTED: const = 0x1 (1 bytes) // payload: array[ifla_xdp_policy] { // union ifla_xdp_policy { // IFLA_XDP_FD: nlattr_t[const[IFLA_XDP_FD, int16], // fd_bpf_prog] { // nla_len: offsetof = 0x8 (2 bytes) // nla_type: const = 0x1 (2 bytes) // payload: fd_bpf_prog (resource) // size: buffer: {} (length 0x0) // } // } // } // size: buffer: {} (length 0x0) // } // } // union ifla_policy { // IFLA_GROUP: nlattr_t[const[IFLA_GROUP, int16], int32] // { // nla_len: offsetof = 0x8 (2 bytes) // nla_type: const = 0x1b (2 bytes) // payload: int32 = 0x0 (4 bytes) // size: buffer: {} (length 0x0) // } // } // } // } // } // } // len: len = 0x34 (8 bytes) // } // } // vlen: const = 0x1 (8 bytes) // ctrl: const = 0x0 (8 bytes) // ctrllen: const = 0x0 (8 bytes) // f: send_flags = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // } // } // f: send_flags = 0x0 (8 bytes) // ] *(uint64_t*)0x200000001340 = 0; *(uint32_t*)0x200000001348 = 0; *(uint64_t*)0x200000001350 = 0x200000001380; *(uint64_t*)0x200000001380 = 0x2000000013c0; *(uint32_t*)0x2000000013c0 = 0x34; *(uint16_t*)0x2000000013c4 = 0x10; *(uint16_t*)0x2000000013c6 = 0x801; *(uint32_t*)0x2000000013c8 = 0x100000; *(uint32_t*)0x2000000013cc = 0; *(uint8_t*)0x2000000013d0 = 0; *(uint8_t*)0x2000000013d1 = 0; *(uint16_t*)0x2000000013d2 = 0; *(uint32_t*)0x2000000013d4 = 0; *(uint32_t*)0x2000000013d8 = 0; *(uint32_t*)0x2000000013dc = 0; *(uint16_t*)0x2000000013e0 = 0xc; STORE_BY_BITMASK(uint16_t, , 0x2000000013e2, 0x2b, 0, 14); STORE_BY_BITMASK(uint16_t, , 0x2000000013e3, 0, 6, 1); STORE_BY_BITMASK(uint16_t, , 0x2000000013e3, 1, 7, 1); *(uint16_t*)0x2000000013e4 = 8; *(uint16_t*)0x2000000013e6 = 1; *(uint32_t*)0x2000000013e8 = r[1]; *(uint16_t*)0x2000000013ec = 8; *(uint16_t*)0x2000000013ee = 0x1b; *(uint32_t*)0x2000000013f0 = 0; *(uint64_t*)0x200000001388 = 0x34; *(uint64_t*)0x200000001358 = 1; *(uint64_t*)0x200000001360 = 0; *(uint64_t*)0x200000001368 = 0; *(uint32_t*)0x200000001370 = 0; syscall(__NR_sendmsg, /*fd=*/r[2], /*msg=*/0x200000001340ul, /*f=*/0ul); } 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; }