// 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} (length // 0x8f) // } // } // } // 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", 143); *(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} (length 0xc5) // } // } // } // 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", 197); *(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[in, // netlink_msg_netfilter_tt[NFNL_SUBSYS_CTNETLINK_EXP, // IPCTNL_MSG_EXP_DELETE, array[exp_nla_policy]]] { // netlink_msg_netfilter_tt[NFNL_SUBSYS_CTNETLINK_EXP, // IPCTNL_MSG_EXP_DELETE, array[exp_nla_policy]] { // len: len = 0x20 (4 bytes) // type: const = 0x2 (1 bytes) // subsys: const = 0x2 (1 bytes) // flags: netlink_netfilter_msg_flags = 0x801 (2 bytes) // seq: const = 0x0 (4 bytes) // pid: const = 0x0 (4 bytes) // hdr: nfgenmsg { // nfgen_family: nfproto = 0x5 (1 bytes) // version: const = 0x0 (1 bytes) // res_id: int16be = 0x4 (2 bytes) // } // attrs: array[exp_nla_policy] { // union exp_nla_policy { // CTA_EXPECT_HELP_NAME: // nlattr_t[const[CTA_EXPECT_HELP_NAME, int16], // string[xt_helper_names]] { // nla_len: offsetof = 0xa (2 bytes) // nla_type: const = 0x6 (2 bytes) // payload: buffer: {51 2e 39 33 31 00} (length 0x6) // size: buffer: {} (length 0x0) // } // } // } // } // } // len: len = 0x20 (8 bytes) // } // } // vlen: const = 0x1 (8 bytes) // ctrl: const = 0x0 (8 bytes) // ctrllen: const = 0x0 (8 bytes) // f: send_flags = 0x4000010 (4 bytes) // pad = 0x0 (4 bytes) // } // } // f: send_flags = 0x0 (8 bytes) // ] *(uint64_t*)0x200000000600 = 0; *(uint32_t*)0x200000000608 = 0; *(uint64_t*)0x200000000610 = 0x2000000005c0; *(uint64_t*)0x2000000005c0 = 0x2000000004c0; *(uint32_t*)0x2000000004c0 = 0x20; *(uint8_t*)0x2000000004c4 = 2; *(uint8_t*)0x2000000004c5 = 2; *(uint16_t*)0x2000000004c6 = 0x801; *(uint32_t*)0x2000000004c8 = 0; *(uint32_t*)0x2000000004cc = 0; *(uint8_t*)0x2000000004d0 = 5; *(uint8_t*)0x2000000004d1 = 0; *(uint16_t*)0x2000000004d2 = htobe16(4); *(uint16_t*)0x2000000004d4 = 0xa; *(uint16_t*)0x2000000004d6 = 6; memcpy((void*)0x2000000004d8, "Q.931\000", 6); *(uint64_t*)0x2000000005c8 = 0x20; *(uint64_t*)0x200000000618 = 1; *(uint64_t*)0x200000000620 = 0; *(uint64_t*)0x200000000628 = 0; *(uint32_t*)0x200000000630 = 0x4000010; syscall(__NR_sendmsg, /*fd=*/r[1], /*msg=*/0x200000000600ul, /*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; loop(); return 0; }