// https://syzkaller.appspot.com/bug?id=77bcabec7ab3b41ff2ffe499079e96ceb6dd4aab // 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 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[4] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // socketpair$unix arguments: [ // domain: const = 0x1 (8 bytes) // type: unix_socket_type = 0x1 (8 bytes) // proto: const = 0x0 (4 bytes) // fds: ptr[out, unix_pair] { // unix_pair { // fd0: sock_unix (resource) // fd1: sock_unix (resource) // } // } // ] res = syscall(__NR_socketpair, /*domain=*/1ul, /*type=SOCK_STREAM*/ 1ul, /*proto=*/0, /*fds=*/0x200000000040ul); if (res != -1) { r[0] = *(uint32_t*)0x200000000040; r[1] = *(uint32_t*)0x200000000044; } // bpf$MAP_CREATE arguments: [ // cmd: const = 0x0 (8 bytes) // arg: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {0f 00 00 00 04 00 00 00 04 00 00 00 12} (length // 0xd) // } // } // } // size: len = 0x50 (8 bytes) // ] // returns fd_bpf_map memcpy((void*)0x200000000200, "\x0f\x00\x00\x00\x04\x00\x00\x00\x04\x00\x00\x00\x12", 13); res = syscall(__NR_bpf, /*cmd=*/0ul, /*arg=*/0x200000000200ul, /*size=*/0x50ul); if (res != -1) r[2] = res; // bpf$PROG_LOAD_XDP arguments: [ // cmd: const = 0x5 (8 bytes) // arg: ptr[in, bpf_prog_t[const[BPF_PROG_TYPE_XDP, int32], const[BPF_XDP, // int32], const[0, int32], const[0, int32]]] { // bpf_prog_t[const[BPF_PROG_TYPE_XDP, int32], const[BPF_XDP, int32], // const[0, int32], const[0, int32]] { // type: const = 0xe (4 bytes) // ninsn: bytesize8 = 0x4 (4 bytes) // insns: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {18 02 00 00 80 10 00 00 00 00 00 00 04 00 00 // 00 85 00 00 00 2e 00 00 00 95} (length 0x19) // } // } // } // license: ptr[in, buffer] { // buffer: {73 79 7a 6b 61 6c 6c 65 72 00} (length 0xa) // } // loglev: int32 = 0x0 (4 bytes) // logsize: len = 0x0 (4 bytes) // log: nil // kern_version: bpf_kern_version = 0x40f00 (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: // const = 0x25 (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: const = 0x0 (4 bytes) // attach_prog_fd: const = 0x0 (4 bytes) // 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[const[BPF_PROG_TYPE_XDP, int32], // const[BPF_XDP, int32], const[0, int32], const[0, // int32]]_prog_token_fd_wrapper { // void: buffer: {} (length 0x0) // } // pad: union _bpf_prog_t[const[BPF_PROG_TYPE_XDP, int32], // const[BPF_XDP, int32], const[0, int32], const[0, int32]]_pad_wrapper // { // value: const = 0x0 (4 bytes) // } // } // } // size: len = 0x80 (8 bytes) // ] // returns fd_bpf_prog_xdp *(uint32_t*)0x200000000340 = 0xe; *(uint32_t*)0x200000000344 = 4; *(uint64_t*)0x200000000348 = 0x200000000400; memcpy((void*)0x200000000400, "\x18\x02\x00\x00\x80\x10\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x85" "\x00\x00\x00\x2e\x00\x00\x00\x95", 25); *(uint64_t*)0x200000000350 = 0x200000000000; memcpy((void*)0x200000000000, "syzkaller\000", 10); *(uint32_t*)0x200000000358 = 0; *(uint32_t*)0x20000000035c = 0; *(uint64_t*)0x200000000360 = 0; *(uint32_t*)0x200000000368 = 0x40f00; *(uint32_t*)0x20000000036c = 0; memset((void*)0x200000000370, 0, 16); *(uint32_t*)0x200000000380 = 0; *(uint32_t*)0x200000000384 = 0x25; *(uint32_t*)0x200000000388 = -1; *(uint32_t*)0x20000000038c = 8; *(uint64_t*)0x200000000390 = 0; *(uint32_t*)0x200000000398 = 0; *(uint32_t*)0x20000000039c = 0x10; *(uint64_t*)0x2000000003a0 = 0; *(uint32_t*)0x2000000003a8 = 0; *(uint32_t*)0x2000000003ac = 0; *(uint32_t*)0x2000000003b0 = 0; *(uint32_t*)0x2000000003b4 = 0; *(uint64_t*)0x2000000003b8 = 0; *(uint64_t*)0x2000000003c0 = 0; *(uint32_t*)0x2000000003c8 = 0x10; *(uint32_t*)0x2000000003cc = 0; *(uint32_t*)0x2000000003d0 = 0; res = syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0x200000000340ul, /*size=*/0x80ul); if (res != -1) r[3] = res; // bpf$BPF_PROG_DETACH arguments: [ // cmd: const = 0x8 (8 bytes) // arg: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYRES32: ANYRES32 (resource) // } // union ANYUNION { // ANYRES32: ANYRES32 (resource) // } // union ANYUNION { // ANYBLOB: buffer: {05} (length 0x1) // } // } // } // size: len = 0x10 (8 bytes) // ] *(uint32_t*)0x200000000180 = r[2]; *(uint32_t*)0x200000000184 = r[3]; memset((void*)0x200000000188, 5, 1); syscall(__NR_bpf, /*cmd=*/8ul, /*arg=*/0x200000000180ul, /*size=*/0x10ul); // bpf$MAP_UPDATE_ELEM_TAIL_CALL arguments: [ // cmd: const = 0x2 (8 bytes) // arg: ptr[inout, bpf_map_update_tail_call_arg] { // bpf_map_update_tail_call_arg { // map: tail_call_map_update { // in: tail_call_map_fd (resource) // out: tail_call_map (resource) // } // pad = 0x0 (4 bytes) // key: ptr[in, const[0, const]] { // const = 0x0 (4 bytes) // } // val: ptr[in, fd_bpf_prog] { // fd_bpf_prog (resource) // } // flags: const = 0x0 (8 bytes) // } // } // size: len = 0x20 (8 bytes) // ] *(uint32_t*)0x200000000740 = r[2]; *(uint64_t*)0x200000000748 = 0x2000000006c0; *(uint32_t*)0x2000000006c0 = 0; *(uint64_t*)0x200000000750 = 0x200000000700; *(uint32_t*)0x200000000700 = r[1]; *(uint64_t*)0x200000000758 = 0; syscall(__NR_bpf, /*cmd=*/2ul, /*arg=*/0x200000000740ul, /*size=*/0x20ul); // sendmsg$inet arguments: [ // fd: sock (resource) // msg: ptr[in, msghdr_inet] { // msghdr_inet { // msg_name: nil // msg_namelen: len = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // msg_iov: ptr[in, array[iovec[in, array[int8]]]] { // array[iovec[in, array[int8]]] { // iovec[in, array[int8]] { // addr: ptr[in, buffer] { // buffer: {55} (length 0x1) // } // len: len = 0x1 (8 bytes) // } // iovec[in, array[int8]] { // addr: nil // len: len = 0x0 (8 bytes) // } // iovec[in, array[int8]] { // addr: nil // len: len = 0x0 (8 bytes) // } // } // } // msg_iovlen: len = 0x3 (8 bytes) // msg_control: nil // msg_controllen: bytesize = 0x0 (8 bytes) // msg_flags: const = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // } // } // f: send_flags = 0x3 (8 bytes) // ] *(uint64_t*)0x200000000980 = 0; *(uint32_t*)0x200000000988 = 0; *(uint64_t*)0x200000000990 = 0x200000000140; *(uint64_t*)0x200000000140 = 0x200000000640; memset((void*)0x200000000640, 85, 1); *(uint64_t*)0x200000000148 = 1; *(uint64_t*)0x200000000150 = 0; *(uint64_t*)0x200000000158 = 0; *(uint64_t*)0x200000000160 = 0; *(uint64_t*)0x200000000168 = 0; *(uint64_t*)0x200000000998 = 3; *(uint64_t*)0x2000000009a0 = 0; *(uint64_t*)0x2000000009a8 = 0; *(uint32_t*)0x2000000009b0 = 0; syscall(__NR_sendmsg, /*fd=*/r[0], /*msg=*/0x200000000980ul, /*f=MSG_OOB|0x2*/ 3ul); // close arguments: [ // fd: fd (resource) // ] syscall(__NR_close, /*fd=*/3); // recvmsg$unix arguments: [ // fd: sock_unix (resource) // msg: ptr[inout, recv_msghdr_un] { // recv_msghdr_un { // addr: nil // addrlen: len = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // vec: ptr[in, array[iovec[out, array[int8]]]] { // array[iovec[out, array[int8]]] { // iovec[out, array[int8]] { // addr: ptr[out, buffer] { // buffer: (DirOut) // } // len: len = 0x76 (8 bytes) // } // iovec[out, array[int8]] { // addr: nil // len: len = 0x0 (8 bytes) // } // iovec[out, array[int8]] { // addr: nil // len: len = 0x0 (8 bytes) // } // iovec[out, array[int8]] { // addr: nil // len: len = 0x0 (8 bytes) // } // iovec[out, array[int8]] { // addr: nil // len: len = 0x0 (8 bytes) // } // } // } // vlen: len = 0x5 (8 bytes) // ctrl: nil // ctrllen: bytesize = 0x0 (8 bytes) // f: const = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // } // } // f: recv_flags = 0x2001 (8 bytes) // ] *(uint64_t*)0x200000000a80 = 0; *(uint32_t*)0x200000000a88 = 0; *(uint64_t*)0x200000000a90 = 0x2000000009c0; *(uint64_t*)0x2000000009c0 = 0x2000000002c0; *(uint64_t*)0x2000000009c8 = 0x76; *(uint64_t*)0x2000000009d0 = 0; *(uint64_t*)0x2000000009d8 = 0; *(uint64_t*)0x2000000009e0 = 0; *(uint64_t*)0x2000000009e8 = 0; *(uint64_t*)0x2000000009f0 = 0; *(uint64_t*)0x2000000009f8 = 0; *(uint64_t*)0x200000000a00 = 0; *(uint64_t*)0x200000000a08 = 0; *(uint64_t*)0x200000000a98 = 5; *(uint64_t*)0x200000000aa0 = 0; *(uint64_t*)0x200000000aa8 = 0; *(uint32_t*)0x200000000ab0 = 0; syscall(__NR_recvmsg, /*fd=*/r[1], /*msg=*/0x200000000a80ul, /*f=MSG_OOB|MSG_ERRQUEUE*/ 0x2001ul, 0); } 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; }