// 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 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 arguments: [ // domain: socket_domain = 0x8000000010 (8 bytes) // type: socket_type = 0x2 (8 bytes) // proto: int32 = 0x0 (4 bytes) // ] // returns sock res = syscall(__NR_socket, /*domain=AF_NETLINK|0x8000000000*/ 0x8000000010ul, /*type=SOCK_DGRAM*/ 2ul, /*proto=*/0); if (res != -1) r[0] = res; // write arguments: [ // fd: fd (resource) // buf: ptr[in, buffer] { // buffer: {fc 00 00 00 1c 00 07 04 ab 5b 25 09 b8 68 03 00 02 ab 08 7a // 01 00 00 00 01 48 10 93 21 00 01 c0 f0 03 05 84 05 00 60 10 00 00 00 // 00 00 03 98 15 fa 2c 53 c2 86 48 00 00 00 b9 d9 56 62 53 7a 00 bc 00 // 0c 00 f0 ff 7f 00 00 b4 00 60 00 33 d4 40 00 04 05 60 91 6a 00 33 f4 // 36 31 30 12 da fd 5a 32 e2 73 fc 83 ab 82 d7 10 f7 4c ec 18 44 06 f9 // 0d 43 5e f8 b2 9d 3e f3 d9 2c 94 17 0e 5b ba 2e 17 73 12 e0 81 be a0 // 5d 3a 02 1e 8c a0 62 91 4a 46 cc fc 51 0b b7 3c 94 55 cd c8 36 3a e4 // f5 df 77 bc 4c fd 62 39 ec 2a 0f 0d 1b ca e5 fa 0f 5f 9d cd d5 1a f5 // 1a f8 50 29 43 28 3f 4b b1 02 b2 b8 f5 56 67 91 cf 19 02 01 de d8 15 // b2 cc d2 43 f3 95 ed 94 e0 ad 91 bd 64 33 80 2e 07 84 f2 01 3c d1 89 // 00 58 a1 00 00 c8 80 ac 80 1f e4 af 00 00 49 f0 d4 79 6f 00 00 09 05 // 48 de} (length 0xfc) // } // count: len = 0xfc (8 bytes) // ] memcpy((void*)0x2000000002c0, "\xfc\x00\x00\x00\x1c\x00\x07\x04\xab\x5b\x25\x09\xb8\x68\x03\x00\x02" "\xab\x08\x7a\x01\x00\x00\x00\x01\x48\x10\x93\x21\x00\x01\xc0\xf0\x03" "\x05\x84\x05\x00\x60\x10\x00\x00\x00\x00\x00\x03\x98\x15\xfa\x2c\x53" "\xc2\x86\x48\x00\x00\x00\xb9\xd9\x56\x62\x53\x7a\x00\xbc\x00\x0c\x00" "\xf0\xff\x7f\x00\x00\xb4\x00\x60\x00\x33\xd4\x40\x00\x04\x05\x60\x91" "\x6a\x00\x33\xf4\x36\x31\x30\x12\xda\xfd\x5a\x32\xe2\x73\xfc\x83\xab" "\x82\xd7\x10\xf7\x4c\xec\x18\x44\x06\xf9\x0d\x43\x5e\xf8\xb2\x9d\x3e" "\xf3\xd9\x2c\x94\x17\x0e\x5b\xba\x2e\x17\x73\x12\xe0\x81\xbe\xa0\x5d" "\x3a\x02\x1e\x8c\xa0\x62\x91\x4a\x46\xcc\xfc\x51\x0b\xb7\x3c\x94\x55" "\xcd\xc8\x36\x3a\xe4\xf5\xdf\x77\xbc\x4c\xfd\x62\x39\xec\x2a\x0f\x0d" "\x1b\xca\xe5\xfa\x0f\x5f\x9d\xcd\xd5\x1a\xf5\x1a\xf8\x50\x29\x43\x28" "\x3f\x4b\xb1\x02\xb2\xb8\xf5\x56\x67\x91\xcf\x19\x02\x01\xde\xd8\x15" "\xb2\xcc\xd2\x43\xf3\x95\xed\x94\xe0\xad\x91\xbd\x64\x33\x80\x2e\x07" "\x84\xf2\x01\x3c\xd1\x89\x00\x58\xa1\x00\x00\xc8\x80\xac\x80\x1f\xe4" "\xaf\x00\x00\x49\xf0\xd4\x79\x6f\x00\x00\x09\x05\x48\xde", 252); syscall(__NR_write, /*fd=*/r[0], /*buf=*/0x2000000002c0ul, /*count=*/0xfcul); // 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[1] = res; // socket arguments: [ // domain: socket_domain = 0x1d (8 bytes) // type: socket_type = 0x2 (8 bytes) // proto: int32 = 0x6 (4 bytes) // ] // returns sock syscall(__NR_socket, /*domain=AF_CAN*/ 0x1dul, /*type=SOCK_DGRAM*/ 2ul, /*proto=*/6); // 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[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {14 00 00 00 26 00 01 00 26 03 00 00 fc // db df 25 06} (length 0x11) // } // } // } // len: len = 0x14 (8 bytes) // } // } // vlen: const = 0x1 (8 bytes) // ctrl: const = 0x0 (8 bytes) // ctrllen: const = 0x0 (8 bytes) // f: send_flags = 0x4000d (4 bytes) // pad = 0x0 (4 bytes) // } // } // f: send_flags = 0x20048000 (8 bytes) // ] *(uint64_t*)0x200000000000 = 0; *(uint32_t*)0x200000000008 = 0; *(uint64_t*)0x200000000010 = 0x200000001ac0; *(uint64_t*)0x200000001ac0 = 0x2000000041c0; memcpy((void*)0x2000000041c0, "\x14\x00\x00\x00\x26\x00\x01\x00\x26\x03\x00\x00\xfc\xdb\xdf\x25\x06", 17); *(uint64_t*)0x200000001ac8 = 0x14; *(uint64_t*)0x200000000018 = 1; *(uint64_t*)0x200000000020 = 0; *(uint64_t*)0x200000000028 = 0; *(uint32_t*)0x200000000030 = 0x4000d; syscall(__NR_sendmsg, /*fd=*/r[1], /*msg=*/0x200000000000ul, /*f=MSG_FASTOPEN|MSG_BATCH|MSG_MORE*/ 0x20048000ul); } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000ul, /*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=*/0x1000ul, /*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 < 4; procid++) { if (fork() == 0) { loop(); } } sleep(1000000); return 0; }