// https://syzkaller.appspot.com/bug?id=e16a5939447ee24dd21d2d26248fa3fabdc51105 // 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 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 (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } } } #ifndef __NR_mmap #define __NR_mmap 192 #endif #ifndef __NR_openat #define __NR_openat 295 #endif #ifndef __NR_write #define __NR_write 4 #endif #undef __NR_mmap #define __NR_mmap __NR_mmap2 uint64_t r[1] = {0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; memcpy((void*)0x20000080, "/dev/uhid\000", 10); res = syscall(__NR_openat, 0xffffff9c, 0x20000080, 0x802, 0); if (res != -1) r[0] = res; memcpy( (void*)0x20000600, "\x0b\x00\x00\x00\x73\x79\x7a\x31\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x11\x61\x55\x3d\x00\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x73\x79\x7a\x31\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x73\x79\x7a\x30\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x18\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x02\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\xe8\x77\xdf\x82\x49\xd3\x34\x29\x9c\x02\xee" "\xb9\x87\x7d\x74\xb0\xc5\x54\x72\xc2\x25\x4e\xe6\x58\x1a\xb5\x30\xab\x36" "\x83\x9a\x7b\xf4\xc7\x66\xa0\xe2\xa5\xe5\x4e\xa1\xa1\x18\xa0\x01\x15\x7b" "\x7e\x4c\x1a\x66\x98\x3d\x1b\xd2\xf0\x5a\xa5\x5a\x01\xc3\x10\x3c\xad\xd9" "\x31\x63\x03\xf0\x7f\xee\x31\x80\xa5\x4d\x04\xed\x64\xde\x66\x84\xcd\x1a" "\xfc\x8b\xba\x8b\x2c\xc9\x40\x50\x53\xb2\xf4\xb0\xcc\xd1\xee\x09\xf6\x2d" "\xbd\x77\x50\x58\xf0\x50\xf4\xc1\xc8\x9a\x44\xe4\xd0\xbc\x9a\xe9\x44\x92" "\xbc\xd5\x45\x80\x83\xc2\x2b\xb7\x4d\x7e\x88\xd0\x41\x62\x2b\x94\x13\xd0" "\x85\x8c\x62\x02\xb4\xce\xbe\x3b\x37\xa3\x11\xa9\x60\x2c\x30\xd5\x1b\x2c" "\x09\x0e\x65\x1b\x62\x1f\x7b\xf9\x11\x8c\x00\xda\xd3\xe6\x33\x96\xc5\x0e" "\xec\x51\xe7\x07\xdc\x5c\xe5\x9e\x53\x18\x8e\x8b\x4f\xa2\xb7\x95\xac\x88" "\x0b\x93\x3c\x1d\x11\xe8\x8b\x7d\xc0\xfa\xbe\xfa\x44\xaa\x7f\x48\x19\xaa" "\x47\xf7\x5d\x90\x4b\x3c\x6a\xf3\x2e\xe4\x34\xc4\xe1\x6c\x2a\x96\x7d\x8b" "\x59\xca\xdf\x94\x06\x4a\x42\x2a\x58\xcb\x3d\xac\x30\x13\x1e\xa7\x3e\x22" "\xd9\xa8\xe8\x22\x4a\x5e\x3f\x62\xb4\x62\x2d\xa5\x98\xf4\x28\xa9\x63\x01" "\x79\x02\x86\xf9\xee\x63\xf6\x18\x5a\x88\xa5\xfa\xe0\x22\xe6\x85\xe4\x95" "\x3c\x0b\x58\x77\xe1\xc4\x92\xfa\x75\x40\xf7\x9f\x2b\xdf\x67\x97\xc9\x6e" "\x4d\x1f\x86\x1e\x2d\x73\xec\xcb\x03\x9f\x44\xc8\xac\x4d\x56\x55\x9f\xdc" "\xce\xfe\x5e\xc2\x6d\xba\x43\x26\x83\xe7\x4b\xd2\x11\x50\xba\x59\xf9\x71" "\xee\x0b\x33\xce\x51\xb7\x9a\x5b\xe6\xe1\xdc\x85\x5f\x89\x9d\x7f\x98\x6a" "\xb2\x6d\xd1\xe6\x6c\x72\x7a\x9b\x6b\xb0\x2c\x0b\xad\x6b\x65\x25\x42\x65" "\x88\x9c\x3a\xc2\xc8\x07\x25\xfa\xa3\x57\x69\x74\x36", 661); syscall(__NR_write, (intptr_t)r[0], 0x20000600, 0x11a); *(uint32_t*)0x20000200 = 0xc; memcpy((void*)0x20000204, "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\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*)0x20000284, "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); memcpy((void*)0x200002c4, "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); *(uint32_t*)0x20000304 = 0; *(uint16_t*)0x20000308 = 0; *(uint16_t*)0x2000030a = 0; *(uint32_t*)0x2000030c = 0; *(uint32_t*)0x20000310 = 0; *(uint32_t*)0x20000314 = 0; *(uint32_t*)0x20000318 = 0; syscall(__NR_write, (intptr_t)r[0], 0x20000200, 0x120); } int main(void) { syscall(__NR_mmap, 0x1ffff000, 0x1000, 0, 0x32, -1, 0); syscall(__NR_mmap, 0x20000000, 0x1000000, 7, 0x32, -1, 0); syscall(__NR_mmap, 0x21000000, 0x1000, 0, 0x32, -1, 0); loop(); return 0; }