// https://syzkaller.appspot.com/bug?id=0871b48d02e776d80d6c15ece0e982af7cf2f9dd // 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[1] = {0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // openat$uhid arguments: [ // fd: const = 0xffffffffffffff9c (8 bytes) // file: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 75 68 69 64 00} (length 0xa) // } // flags: uhid_open_flags = 0x2 (4 bytes) // mode: const = 0x0 (2 bytes) // ] // returns fd_uhid memcpy((void*)0x200000000180, "/dev/uhid\000", 10); res = syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0x200000000180ul, /*flags=O_RDWR*/ 2, /*mode=*/0); if (res != -1) r[0] = res; // write$UHID_CREATE2 arguments: [ // fd: fd_uhid (resource) // data: ptr[in, uhid_req[UHID_CREATE2, uhid_create2_req]] { // uhid_req[UHID_CREATE2, uhid_create2_req] { // type: const = 0xb (4 bytes) // data: uhid_create2_req { // name: buffer: {73 79 7a 30 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00} (length 0x80) phys: buffer: {73 79 7a 31 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00} (length 0x40) uniq: buffer: {73 79 7a // 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x40) // rd_size: len = 0x33 (2 bytes) // bus: int16 = 0x5 (2 bytes) // vendor: int32 = 0x46d (4 bytes) // product: int32 = 0xb012 (4 bytes) // version: int32 = 0x0 (4 bytes) // country: int32 = 0x0 (4 bytes) // rd_data: buffer: {06 00 ff 09 01 a1 01 85 10 09 01 15 00 26 ff 00 // 75 08 95 06 81 00 09 01 91 00 85 11 09 01 95 13 81 00 09 01 91 00 // 85 12 09 01 95 3f 81 00 09 01 91 00 c0} (length 0x33) // } // } // } // len: len = 0x14b (8 bytes) // ] *(uint32_t*)0x200000000000 = 0xb; memcpy( (void*)0x200000000004, "syz0\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 128); memcpy((void*)0x200000000084, "syz1\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000", 64); memcpy((void*)0x2000000000c4, "syz0\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000", 64); *(uint16_t*)0x200000000104 = 0x33; *(uint16_t*)0x200000000106 = 5; *(uint32_t*)0x200000000108 = 0x46d; *(uint32_t*)0x20000000010c = 0xb012; *(uint32_t*)0x200000000110 = 0; *(uint32_t*)0x200000000114 = 0; memcpy((void*)0x200000000118, "\x06\x00\xff\x09\x01\xa1\x01\x85\x10\x09\x01\x15\x00\x26\xff\x00\x75" "\x08\x95\x06\x81\x00\x09\x01\x91\x00\x85\x11\x09\x01\x95\x13\x81\x00" "\x09\x01\x91\x00\x85\x12\x09\x01\x95\x3f\x81\x00\x09\x01\x91\x00\xc0", 51); syscall(__NR_write, /*fd=*/r[0], /*data=*/0x200000000000ul, /*len=*/0x14bul); // write$UHID_INPUT2 arguments: [ // fd: fd_uhid (resource) // data: ptr[in, uhid_req[UHID_INPUT2, uhid_input2_req]] { // uhid_req[UHID_INPUT2, uhid_input2_req] { // type: const = 0xc (4 bytes) // data: uhid_input2_req { // size: len = 0x14 (2 bytes) // data: buffer: {11 ff 04 20 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00} (length 0x14) // } // } // } // len: len = 0x1a (8 bytes) // ] *(uint32_t*)0x200000000d00 = 0xc; *(uint16_t*)0x200000000d04 = 0x14; memcpy((void*)0x200000000d06, "\x11\xff\x04\x20\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00", 20); syscall(__NR_write, /*fd=*/r[0], /*data=*/0x200000000d00ul, /*len=*/0x1aul); // write$UHID_INPUT2 arguments: [ // fd: fd_uhid (resource) // data: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {0c 00 00 00 14 00 11 ff 00 00 04 00 00 00 00 a7 // c9 60 14 f3 ed ab 41 00 00 6f d1 58 34 42 f6 c3 dd 76 e1 92 14 4f // 38 b7 0a 4a 19 53 59 7a ba 40 cf 9a 30 f3 8d d2 49 43 ad de 4f e2 // 55 e1 e5 0d 90 39 61 c0 c7 50 95 72 7c 8b 23 de 39 70 6e dc 94 54 // b4 3b 5b ac 76 7a 72 af aa 1b 71 25 d6 04 6b f6 6f 69 cc 35 50 c9} // (length 0x68) // } // } // } // len: len = 0x1a (8 bytes) // ] memcpy( (void*)0x2000000005c0, "\x0c\x00\x00\x00\x14\x00\x11\xff\x00\x00\x04\x00\x00\x00\x00\xa7\xc9\x60" "\x14\xf3\xed\xab\x41\x00\x00\x6f\xd1\x58\x34\x42\xf6\xc3\xdd\x76\xe1\x92" "\x14\x4f\x38\xb7\x0a\x4a\x19\x53\x59\x7a\xba\x40\xcf\x9a\x30\xf3\x8d\xd2" "\x49\x43\xad\xde\x4f\xe2\x55\xe1\xe5\x0d\x90\x39\x61\xc0\xc7\x50\x95\x72" "\x7c\x8b\x23\xde\x39\x70\x6e\xdc\x94\x54\xb4\x3b\x5b\xac\x76\x7a\x72\xaf" "\xaa\x1b\x71\x25\xd6\x04\x6b\xf6\x6f\x69\xcc\x35\x50\xc9", 104); syscall(__NR_write, /*fd=*/r[0], /*data=*/0x2000000005c0ul, /*len=*/0x1aul); } 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; }