// https://syzkaller.appspot.com/bug?id=f3c29707e8433dfca34d8ac14df7541391aedd0b // 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 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 long syz_open_dev(volatile long a0, volatile long a1, volatile long a2) { if (a0 == 0xc || a0 == 0xb) { char buf[128]; sprintf(buf, "/dev/%s/%d:%d", a0 == 0xc ? "char" : "block", (uint8_t)a1, (uint8_t)a2); return open(buf, O_RDWR, 0); } else { unsigned long nb = a1; char buf[1024]; char* hash; strncpy(buf, (char*)a0, sizeof(buf) - 1); buf[sizeof(buf) - 1] = 0; while ((hash = strchr(buf, '#'))) { *hash = '0' + (char)(nb % 10); nb /= 10; } return open(buf, a2 & ~O_CREAT, 0); } } 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[1] = {0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // sendmsg$TIPC_NL_MEDIA_SET arguments: [ // fd: sock_nl_generic (resource) // msg: ptr[in, msghdr_netlink[netlink_msg_t[genl_tipc2_family_id, // genlmsghdr_t[TIPC_NL_MEDIA_SET], tipc_nl_policy]]] { // msghdr_netlink[netlink_msg_t[genl_tipc2_family_id, // genlmsghdr_t[TIPC_NL_MEDIA_SET], tipc_nl_policy]] { // addr: nil // addrlen: len = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // vec: ptr[in, iovec[in, netlink_msg_t[genl_tipc2_family_id, // genlmsghdr_t[TIPC_NL_MEDIA_SET], tipc_nl_policy]]] { // iovec[in, netlink_msg_t[genl_tipc2_family_id, // genlmsghdr_t[TIPC_NL_MEDIA_SET], tipc_nl_policy]] { // addr: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {00 04 26 bd 70 00 fc db df 25 0c 00 00 // 00 34 00 09 80 08 00 02 00 00 10 00 00 08 00 01 00 fb ff // ff ff 08 00 01 00 ff ff ff 7f 08 00 02 00 d6 3c 00 00 08 // 00 01 00 04 00 00 00 08 00 01 00 09 00 00 00 2c 01 01 80 // 0d 00 01 00 75 64 70 3a 73 79 7a 32 00 00 00 00 38 00 04 // 00 14 00 01 00 02 00 4e 23 ac 1e 00 01 00 00 00 00 00 00 // 00 00 20 00 02 00 0a 00 4e 22 7f ff ff ff fc 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 01 00 00 80 08 00 03 00 // 04 00 00 00 38 00 04 00 20 00 01 00 0a 00 4e 20 00 00 00 // 09 ff 02 00 00 00 00 00 00 00 00 00 00 00 00 00 01 04 00 // 00 00 14 00 02 00 02 00 4e 24 00 00 00 00 00 00 00 00 00 // 00 00 00 4c 00 02 80 08 00 03 00 ff 01 00 00 08 00 04 00 // 01 04 00 00 08 00 03 00 09 00 00 00 08 00 02 00 f6 00 00 // 00 08 00 01 00 1c 00 00 00 08 00 02 00 01 00 00 00 08 00 // 01 00 1a 00 00 00 08 00 03 00 09 00 00 00 08 00 01 00 17 // 00 00 00 54 00 02 80 08 00 01 00 1c 00 00 00 08} (length // 0x127) // } // } // } // len: len = 0x2d0 (8 bytes) // } // } // vlen: const = 0x1 (8 bytes) // ctrl: const = 0x0 (8 bytes) // ctrllen: const = 0x0 (8 bytes) // f: send_flags = 0x40408c1 (4 bytes) // pad = 0x0 (4 bytes) // } // } // f: send_flags = 0x40 (8 bytes) // ] *(uint64_t*)0x200000000340 = 0; *(uint32_t*)0x200000000348 = 0; *(uint64_t*)0x200000000350 = 0x200000000300; *(uint64_t*)0x200000000300 = 0x200000000440; memcpy( (void*)0x200000000440, "\x00\x04\x26\xbd\x70\x00\xfc\xdb\xdf\x25\x0c\x00\x00\x00\x34\x00\x09\x80" "\x08\x00\x02\x00\x00\x10\x00\x00\x08\x00\x01\x00\xfb\xff\xff\xff\x08\x00" "\x01\x00\xff\xff\xff\x7f\x08\x00\x02\x00\xd6\x3c\x00\x00\x08\x00\x01\x00" "\x04\x00\x00\x00\x08\x00\x01\x00\x09\x00\x00\x00\x2c\x01\x01\x80\x0d\x00" "\x01\x00\x75\x64\x70\x3a\x73\x79\x7a\x32\x00\x00\x00\x00\x38\x00\x04\x00" "\x14\x00\x01\x00\x02\x00\x4e\x23\xac\x1e\x00\x01\x00\x00\x00\x00\x00\x00" "\x00\x00\x20\x00\x02\x00\x0a\x00\x4e\x22\x7f\xff\xff\xff\xfc\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x80\x08\x00" "\x03\x00\x04\x00\x00\x00\x38\x00\x04\x00\x20\x00\x01\x00\x0a\x00\x4e\x20" "\x00\x00\x00\x09\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x01\x04\x00\x00\x00\x14\x00\x02\x00\x02\x00\x4e\x24\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x4c\x00\x02\x80\x08\x00\x03\x00\xff\x01" "\x00\x00\x08\x00\x04\x00\x01\x04\x00\x00\x08\x00\x03\x00\x09\x00\x00\x00" "\x08\x00\x02\x00\xf6\x00\x00\x00\x08\x00\x01\x00\x1c\x00\x00\x00\x08\x00" "\x02\x00\x01\x00\x00\x00\x08\x00\x01\x00\x1a\x00\x00\x00\x08\x00\x03\x00" "\x09\x00\x00\x00\x08\x00\x01\x00\x17\x00\x00\x00\x54\x00\x02\x80\x08\x00" "\x01\x00\x1c\x00\x00\x00\x08", 295); *(uint64_t*)0x200000000308 = 0x2d0; *(uint64_t*)0x200000000358 = 1; *(uint64_t*)0x200000000360 = 0; *(uint64_t*)0x200000000368 = 0; *(uint32_t*)0x200000000370 = 0x40408c1; syscall(__NR_sendmsg, /*fd=*/(intptr_t)-1, /*msg=*/0x200000000340ul, /*f=MSG_DONTWAIT*/ 0x40ul); // syz_open_dev$evdev arguments: [ // dev: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 69 6e 70 75 74 2f 65 76 65 6e 74 23 00} // (length 0x12) // } // id: intptr = 0x2 (8 bytes) // flags: open_flags = 0x8a2b81 (8 bytes) // ] // returns fd_evdev memcpy((void*)0x200000000000, "/dev/input/event#\000", 18); res = -1; res = syz_open_dev( /*dev=*/0x200000000000, /*id=*/2, /*flags=O_TRUNC|O_NONBLOCK|O_NOFOLLOW|O_NOCTTY|O_EXCL|O_CLOEXEC|0x802001*/ 0x8a2b81); if (res != -1) r[0] = res; // write$char_usb arguments: [ // fd: fd_char_usb (resource) // buf: ptr[in, buffer] { // buffer: {e2} (length 0x1) // } // count: len = 0x12d8 (8 bytes) // ] memset((void*)0x200000000040, 226, 1); syscall(__NR_write, /*fd=*/r[0], /*buf=*/0x200000000040ul, /*count=*/0x12d8ul); } 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; loop(); return 0; }