// https://syzkaller.appspot.com/bug?id=9f98775afdb4117f7a2b523e98ccdcc8e20dfd06 // 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 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[2] = {0xffffffffffffffff, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // socket$nl_netfilter arguments: [ // domain: const = 0x10 (8 bytes) // type: const = 0x3 (8 bytes) // proto: const = 0xc (4 bytes) // ] // returns sock_nl_netfilter res = syscall(__NR_socket, /*domain=*/0x10ul, /*type=*/3ul, /*proto=*/0xc); if (res != -1) r[0] = res; // sendmsg$IPCTNL_MSG_CT_NEW arguments: [ // fd: sock_nl_netfilter (resource) // msg: ptr[in, // msghdr_netlink[netlink_msg_netfilter_t[NFNL_SUBSYS_CTNETLINK, // IPCTNL_MSG_CT_NEW, ct_nla_policy]]] { // msghdr_netlink[netlink_msg_netfilter_t[NFNL_SUBSYS_CTNETLINK, // IPCTNL_MSG_CT_NEW, ct_nla_policy]] { // addr: nil // addrlen: len = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // vec: ptr[in, iovec[in, // netlink_msg_netfilter_t[NFNL_SUBSYS_CTNETLINK, IPCTNL_MSG_CT_NEW, // ct_nla_policy]]] { // iovec[in, netlink_msg_netfilter_t[NFNL_SUBSYS_CTNETLINK, // IPCTNL_MSG_CT_NEW, ct_nla_policy]] { // addr: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {90 00 00 00 00 01 01 06 00 00 00 00 00 // 00 00 00 02 00 00 00 34 00 01 80 14 00 01 80 08 00 01 00 // 01 02 03 04 08 00 02 00 05 06 07 08 1c 00 02 80 05 00 01 // 00 06 00 00 00 06 00 02 00 04 d2 00 00 06 00 03 00 00 15 // 00 00 34 00 02 80 14 00 01 80 08 00 01 00 05 06 07 08 08 // 00 02 00 01 02 03 04 1c 00 02 80 05 00 01 00 06 00 00 00 // 06 00 02 00 00 15 00 00 06 00 03 00 04 d2 00 00 08 00 07 // 00 00 00 01 2c 0c 00 05 80 08 00 01 00 66 74 70 00} // (length 0x90) // } // } // } // len: len = 0x90 (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*)0x200000000200 = 0; *(uint32_t*)0x200000000208 = 0; *(uint64_t*)0x200000000210 = 0x200000000000; *(uint64_t*)0x200000000000 = 0x200000000400; memcpy((void*)0x200000000400, "\x90\x00\x00\x00\x00\x01\x01\x06\x00\x00\x00\x00\x00\x00\x00\x00\x02" "\x00\x00\x00\x34\x00\x01\x80\x14\x00\x01\x80\x08\x00\x01\x00\x01\x02" "\x03\x04\x08\x00\x02\x00\x05\x06\x07\x08\x1c\x00\x02\x80\x05\x00\x01" "\x00\x06\x00\x00\x00\x06\x00\x02\x00\x04\xd2\x00\x00\x06\x00\x03\x00" "\x00\x15\x00\x00\x34\x00\x02\x80\x14\x00\x01\x80\x08\x00\x01\x00\x05" "\x06\x07\x08\x08\x00\x02\x00\x01\x02\x03\x04\x1c\x00\x02\x80\x05\x00" "\x01\x00\x06\x00\x00\x00\x06\x00\x02\x00\x00\x15\x00\x00\x06\x00\x03" "\x00\x04\xd2\x00\x00\x08\x00\x07\x00\x00\x00\x01\x2c\x0c\x00\x05\x80" "\x08\x00\x01\x00\x66\x74\x70\x00", 144); *(uint64_t*)0x200000000008 = 0x90; *(uint64_t*)0x200000000218 = 1; *(uint64_t*)0x200000000220 = 0; *(uint64_t*)0x200000000228 = 0; *(uint32_t*)0x200000000230 = 0; syscall(__NR_sendmsg, /*fd=*/r[0], /*msg=*/0x200000000200ul, /*f=*/0ul); // sendmsg$IPCTNL_MSG_EXP_NEW arguments: [ // fd: sock_nl_netfilter (resource) // msg: ptr[in, // msghdr_netlink[netlink_msg_netfilter_t[NFNL_SUBSYS_CTNETLINK_EXP, // IPCTNL_MSG_EXP_NEW, exp_nla_policy]]] { // msghdr_netlink[netlink_msg_netfilter_t[NFNL_SUBSYS_CTNETLINK_EXP, // IPCTNL_MSG_EXP_NEW, exp_nla_policy]] { // addr: nil // addrlen: len = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // vec: ptr[in, iovec[in, // netlink_msg_netfilter_t[NFNL_SUBSYS_CTNETLINK_EXP, // IPCTNL_MSG_EXP_NEW, exp_nla_policy]]] { // iovec[in, netlink_msg_netfilter_t[NFNL_SUBSYS_CTNETLINK_EXP, // IPCTNL_MSG_EXP_NEW, exp_nla_policy]] { // addr: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {c8 00 00 00 00 02 01 06 00 00 00 00 00 // 00 00 00 02 00 00 00 34 00 01 80 14 00 01 80 08 00 01 00 // 01 02 03 04 08 00 02 00 05 06 07 08 1c 00 02 80 05 00 01 // 00 06 00 00 00 06 00 02 00 04 d2 00 00 06 00 03 00 00 15 // 00 00 34 00 02 80 14 00 01 80 08 00 01 00 05 06 07 08 08 // 00 02 00 01 02 03 04 1c 00 02 80 05 00 01 00 06 00 00 00 // 06 00 02 00 00 14 00 00 06 00 03 00 9c 40 00 00 34 00 03 // 80 14 00 01 80 08 00 01 00 ff ff ff ff 08 00 02 00 ff ff // ff ff 1c 00 02 80 05 00 01 00 ff 00 00 00 06 00 02 00 00 // 00 00 00 06 00 03 00 ff ff 00 00 16 00 0b 00 6e 61 74 2d // 66 6f 6c 6c 6f 77 2d 6d 61 73 74 65 72 00 00 00} (length // 0xc8) // } // } // } // len: len = 0xc8 (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*)0x200000000300 = 0; *(uint32_t*)0x200000000308 = 0; *(uint64_t*)0x200000000310 = 0x200000000100; *(uint64_t*)0x200000000100 = 0x200000000800; memcpy((void*)0x200000000800, "\xc8\x00\x00\x00\x00\x02\x01\x06\x00\x00\x00\x00\x00\x00\x00\x00\x02" "\x00\x00\x00\x34\x00\x01\x80\x14\x00\x01\x80\x08\x00\x01\x00\x01\x02" "\x03\x04\x08\x00\x02\x00\x05\x06\x07\x08\x1c\x00\x02\x80\x05\x00\x01" "\x00\x06\x00\x00\x00\x06\x00\x02\x00\x04\xd2\x00\x00\x06\x00\x03\x00" "\x00\x15\x00\x00\x34\x00\x02\x80\x14\x00\x01\x80\x08\x00\x01\x00\x05" "\x06\x07\x08\x08\x00\x02\x00\x01\x02\x03\x04\x1c\x00\x02\x80\x05\x00" "\x01\x00\x06\x00\x00\x00\x06\x00\x02\x00\x00\x14\x00\x00\x06\x00\x03" "\x00\x9c\x40\x00\x00\x34\x00\x03\x80\x14\x00\x01\x80\x08\x00\x01\x00" "\xff\xff\xff\xff\x08\x00\x02\x00\xff\xff\xff\xff\x1c\x00\x02\x80\x05" "\x00\x01\x00\xff\x00\x00\x00\x06\x00\x02\x00\x00\x00\x00\x00\x06\x00" "\x03\x00\xff\xff\x00\x00\x16\x00\x0b\x00\x6e\x61\x74\x2d\x66\x6f\x6c" "\x6c\x6f\x77\x2d\x6d\x61\x73\x74\x65\x72\x00\x00\x00", 200); *(uint64_t*)0x200000000108 = 0xc8; *(uint64_t*)0x200000000318 = 1; *(uint64_t*)0x200000000320 = 0; *(uint64_t*)0x200000000328 = 0; *(uint32_t*)0x200000000330 = 0; syscall(__NR_sendmsg, /*fd=*/r[0], /*msg=*/0x200000000300ul, /*f=*/0ul); // socket$nl_netfilter arguments: [ // domain: const = 0x10 (8 bytes) // type: const = 0x3 (8 bytes) // proto: const = 0xc (4 bytes) // ] // returns sock_nl_netfilter res = syscall(__NR_socket, /*domain=*/0x10ul, /*type=*/3ul, /*proto=*/0xc); if (res != -1) r[1] = res; // sendmsg$IPCTNL_MSG_EXP_DELETE arguments: [ // fd: sock_nl_netfilter (resource) // msg: ptr[in, // msghdr_netlink[netlink_msg_netfilter_t[NFNL_SUBSYS_CTNETLINK_EXP, // IPCTNL_MSG_EXP_DELETE, exp_nla_policy]]] { // msghdr_netlink[netlink_msg_netfilter_t[NFNL_SUBSYS_CTNETLINK_EXP, // IPCTNL_MSG_EXP_DELETE, exp_nla_policy]] { // addr: nil // addrlen: len = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // vec: ptr[in, iovec[in, // netlink_msg_netfilter_t[NFNL_SUBSYS_CTNETLINK_EXP, // IPCTNL_MSG_EXP_DELETE, exp_nla_policy]]] { // iovec[in, netlink_msg_netfilter_t[NFNL_SUBSYS_CTNETLINK_EXP, // IPCTNL_MSG_EXP_DELETE, exp_nla_policy]] { // addr: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {18 01 00 00 02 02 05 00 00 00 00 00 00 // 00 00 00 07 00 00 07 68 00 01 80 06 00 03 40 00 04 00 00 // 2c 00 01 80 14 00 03 00 ff 01 00 00 00 00 00 00 00 00 00 // 00 00 00 00 01 14 00 04 00 ff 01 00 00 00 00 00 00 00 00 // 00 00 00 00 00 01 0c 00 02 80 05 00 01 00 bd 00 00 00 0c // 00 02 80 05 00 01 00 21 00 00 00 0c 00 02 80 05 00 01 00 // 84 00 00 00 0c 00 02 80 05 00 01 00 84 00 00 00 08 00 04 // 40 00 00 00 05 80 00 01 80 0c 00 02 80 05 00 01 00 2f 00 // 00 00 06 00 03 40 00 04 00 00 06 00 03 40 00 04 00 00 06 // 00 03 40 00 00 00 00 2c e6 01 80 14 00 03 00 ff 01 00 00 // 00 00 00 00 00 00 00 00 00 00 00 01 14 00 04 00 20 01 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 2c 00 01 80 14 00 // 03 00 fe 88 00 00 00 00 00 00 00 00 00 00 00 00 00 01 14 // 00 04 00 ff 02 00 00 00 00 00 00 00 00 00 00 00 00 00 01 // 09 00 06 00 73 6e 6d 70 00 00 00 00 08 00 04 40 00 00 00 // 01} (length 0x118) // } // } // } // len: len = 0x118 (8 bytes) // } // } // vlen: const = 0x1 (8 bytes) // ctrl: const = 0x0 (8 bytes) // ctrllen: const = 0x0 (8 bytes) // f: send_flags = 0x80 (4 bytes) // pad = 0x0 (4 bytes) // } // } // f: send_flags = 0x20000080 (8 bytes) // ] *(uint64_t*)0x200000000300 = 0; *(uint32_t*)0x200000000308 = 0; *(uint64_t*)0x200000000310 = 0x2000000002c0; *(uint64_t*)0x2000000002c0 = 0x200000000180; memcpy( (void*)0x200000000180, "\x18\x01\x00\x00\x02\x02\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x07\x00" "\x00\x07\x68\x00\x01\x80\x06\x00\x03\x40\x00\x04\x00\x00\x2c\x00\x01\x80" "\x14\x00\x03\x00\xff\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x01\x14\x00\x04\x00\xff\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x01\x0c\x00\x02\x80\x05\x00\x01\x00\xbd\x00\x00\x00\x0c\x00" "\x02\x80\x05\x00\x01\x00\x21\x00\x00\x00\x0c\x00\x02\x80\x05\x00\x01\x00" "\x84\x00\x00\x00\x0c\x00\x02\x80\x05\x00\x01\x00\x84\x00\x00\x00\x08\x00" "\x04\x40\x00\x00\x00\x05\x80\x00\x01\x80\x0c\x00\x02\x80\x05\x00\x01\x00" "\x2f\x00\x00\x00\x06\x00\x03\x40\x00\x04\x00\x00\x06\x00\x03\x40\x00\x04" "\x00\x00\x06\x00\x03\x40\x00\x00\x00\x00\x2c\xe6\x01\x80\x14\x00\x03\x00" "\xff\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x14\x00" "\x04\x00\x20\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x2c\x00\x01\x80\x14\x00\x03\x00\xfe\x88\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x01\x14\x00\x04\x00\xff\x02\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x01\x09\x00\x06\x00\x73\x6e\x6d\x70\x00\x00" "\x00\x00\x08\x00\x04\x40\x00\x00\x00\x01", 280); *(uint64_t*)0x2000000002c8 = 0x118; *(uint64_t*)0x200000000318 = 1; *(uint64_t*)0x200000000320 = 0; *(uint64_t*)0x200000000328 = 0; *(uint32_t*)0x200000000330 = 0x80; syscall(__NR_sendmsg, /*fd=*/r[1], /*msg=*/0x200000000300ul, /*f=MSG_FASTOPEN|MSG_EOR*/ 0x20000080ul); } 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; }