// 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 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; } 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_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 = 0x27 (2 bytes) // flags: netlink_msg_flags = 0x9 (2 bytes) // seq: int32 = 0x70bd25 (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 = 0x4000002 (4 bytes) // pad = 0x0 (4 bytes) // } // } // f: send_flags = 0x4000080 (8 bytes) // ] *(uint64_t*)0x200000000100 = 0; *(uint32_t*)0x200000000108 = 0; *(uint64_t*)0x200000000110 = 0x200000000180; *(uint64_t*)0x200000000180 = 0x200000000300; *(uint32_t*)0x200000000300 = 0x14; *(uint16_t*)0x200000000304 = 0x27; *(uint16_t*)0x200000000306 = 9; *(uint32_t*)0x200000000308 = 0x70bd25; *(uint32_t*)0x20000000030c = 0x25dfdbfd; *(uint8_t*)0x200000000310 = 6; *(uint8_t*)0x200000000311 = 0; *(uint16_t*)0x200000000312 = 0; *(uint64_t*)0x200000000188 = 0x14; *(uint64_t*)0x200000000118 = 1; *(uint64_t*)0x200000000120 = 0; *(uint64_t*)0x200000000128 = 0; *(uint32_t*)0x200000000130 = 0x4000002; syscall(__NR_sendmsg, /*fd=*/r[0], /*msg=*/0x200000000100ul, /*f=MSG_ZEROCOPY|MSG_EOR*/ 0x4000080ul); // socket$kcm arguments: [ // domain: const = 0x10 (8 bytes) // type: kcm_socket_type = 0x2 (8 bytes) // proto: const = 0x0 (4 bytes) // ] // returns sock_kcm res = syscall(__NR_socket, /*domain=*/0x10ul, /*type=SOCK_DGRAM*/ 2ul, /*proto=*/0); if (res != -1) r[1] = res; // sendmsg$kcm arguments: [ // fd: sock_kcm (resource) // msg: ptr[in, send_msghdr] { // send_msghdr { // 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: {d8 00 00 00 1c 00 81 04 4e 81 f7 82 db 44 b9 04 02 // 1d 08 02 01 00 00 00 05 00 f0 a1 18 00 02 00 00 00 00 00 00 // 00 0e 12 08 00 0f 01 00 81 04 01 a8 00 16 00 20 00 01 40 03 // 00 00 08 03 60 fa b9 39 cf 5c 04 61 c1 d6 7f 6f 94 00 71 34 // cf 6e e0 80 00 a0 e4 08 e8 d8 ef 07 5c 11 50 3c 6b ba ce 80 // 17 cb 09 00 00 00 1f b7 91 64 3a 5e e4 00 1b 14 62 18 a0 74 // 45 d6 d9 30 df e1 d9 d3 22 fe 7c 9f d6 87 75 73 0d 16 a4 68 // 3f 5a eb 4e db b5 7a 50 25 cc ca 9e 00 36 0d b7 01 00 00 00 // 40 fa d9 56 67 e0 06 00 00 00 00 00 00 00 80 bb 9a d8 09 d5 // e1 ca ce 81 ed 0b ff ec e0 b4 2a 9e cb ee 5d e6 cc d4 0d d6 // 8a db ef 3d 93 45 2a 00 00 00 00 00 00 00 00 00 00 00 00} // (length 0xd8) // } // len: len = 0xd8 (8 bytes) // } // } // } // msg_iovlen: len = 0x1 (8 bytes) // msg_control: nil // msg_controllen: bytesize = 0x0 (8 bytes) // msg_flags: const = 0x7400 (4 bytes) // pad = 0x0 (4 bytes) // } // } // f: send_flags = 0x20004800 (8 bytes) // ] *(uint64_t*)0x200000000080 = 0; *(uint32_t*)0x200000000088 = 0; *(uint64_t*)0x200000000090 = 0x200000000200; *(uint64_t*)0x200000000200 = 0x200000000340; memcpy((void*)0x200000000340, "\xd8\x00\x00\x00\x1c\x00\x81\x04\x4e\x81\xf7\x82\xdb\x44\xb9\x04\x02" "\x1d\x08\x02\x01\x00\x00\x00\x05\x00\xf0\xa1\x18\x00\x02\x00\x00\x00" "\x00\x00\x00\x00\x0e\x12\x08\x00\x0f\x01\x00\x81\x04\x01\xa8\x00\x16" "\x00\x20\x00\x01\x40\x03\x00\x00\x08\x03\x60\xfa\xb9\x39\xcf\x5c\x04" "\x61\xc1\xd6\x7f\x6f\x94\x00\x71\x34\xcf\x6e\xe0\x80\x00\xa0\xe4\x08" "\xe8\xd8\xef\x07\x5c\x11\x50\x3c\x6b\xba\xce\x80\x17\xcb\x09\x00\x00" "\x00\x1f\xb7\x91\x64\x3a\x5e\xe4\x00\x1b\x14\x62\x18\xa0\x74\x45\xd6" "\xd9\x30\xdf\xe1\xd9\xd3\x22\xfe\x7c\x9f\xd6\x87\x75\x73\x0d\x16\xa4" "\x68\x3f\x5a\xeb\x4e\xdb\xb5\x7a\x50\x25\xcc\xca\x9e\x00\x36\x0d\xb7" "\x01\x00\x00\x00\x40\xfa\xd9\x56\x67\xe0\x06\x00\x00\x00\x00\x00\x00" "\x00\x80\xbb\x9a\xd8\x09\xd5\xe1\xca\xce\x81\xed\x0b\xff\xec\xe0\xb4" "\x2a\x9e\xcb\xee\x5d\xe6\xcc\xd4\x0d\xd6\x8a\xdb\xef\x3d\x93\x45\x2a" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 216); *(uint64_t*)0x200000000208 = 0xd8; *(uint64_t*)0x200000000098 = 1; *(uint64_t*)0x2000000000a0 = 0; *(uint64_t*)0x2000000000a8 = 0; *(uint32_t*)0x2000000000b0 = 0x7400; syscall(__NR_sendmsg, /*fd=*/r[1], /*msg=*/0x200000000080ul, /*f=MSG_FASTOPEN|MSG_NOSIGNAL|MSG_CONFIRM*/ 0x20004800ul); } 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; }