// https://syzkaller.appspot.com/bug?id=eb1e119dafaaba7aa276a3c4da457532baeac215 // 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 { char buf[1024]; char* hash; strncpy(buf, (char*)a0, sizeof(buf) - 1); buf[sizeof(buf) - 1] = 0; while ((hash = strchr(buf, '#'))) { *hash = '0' + (char)(a1 % 10); a1 /= 10; } return open(buf, a2, 0); } } static void kill_and_wait(int pid, int* status) { kill(-pid, SIGKILL); kill(pid, SIGKILL); int i; for (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; for (iter = 0;; 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; } } } uint64_t r[1] = {0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; memcpy((void*)0x200000c0, "/dev/binder#\000", 13); res = syz_open_dev(0x200000c0, 0, 0); if (res != -1) r[0] = res; *(uint64_t*)0x20000140 = 0xfffffca6; *(uint64_t*)0x20000148 = 0; *(uint64_t*)0x20000150 = 0x20000500; memcpy( (void*)0x20000500, "\x11\x63\x48\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x97\x89\xd6\x7e\x92\xf8\xeb\xf4" "\x76\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\x56\xa3\x17\x73\x59\xa5\xbe\x4d\x7c\xc9\x3e\x2c\x27" "\xde\x9c\xb2\xf7\x8c\xe6\x84\xf9\xb9\x85\x6a\xda\xad\x83\x8b\xba\xb7\x80" "\x16\x9d\xc3\x99\x1a\xf9\xf5\x29\xa8\x5e\xf7\xc2\x96\x11\x4b\x36\xf4\xc9" "\x8c\x8c\x8a\xac\xc2\x93\xe7\xf3\x35\xcc\x16\xe0\xb1\xe9\x90\x64\x4f\xe5" "\x0b\x25\x5e\xb8\x24\xd0\x1a\x89\x55\x50\xcd\x62\xb6\xe7\x65\xf8\x95\x26" "\xcc\x77\xf9\x18\x14\x86\xb1\x98\xfb\xad\x93\xfe\xeb\x16\x94\x25\x6b\x49" "\xa3\x62\x01\xd3\xb5\xc3\x08\x9f\x4a\xef\xce\x6d\xc8\x71\x9f\x36\x91\x4b" "\x6c\x0a\xa8\x72\xbe\x7d\xaa\xc5\x6d\xb0\xca\x22\xdb\x31\x53\xca\x77\xda" "\x62\xf9\x69\x5f\x23\xa0\x68\x19\x1a\x48\xe1\x6d\x66\x64\xbf\xad\x41\xf8" "\xc3\x0b\x60\x56\x38\xdd\x57\x22\x74\x32\x02\xc3\xa7\x93\x0e\xa2\xbf\x21" "\xff\xff\x00\x00\x00\x00\x00\x00\x0a\x3e\x19\xfd\x8f\xed\xcd\xaf\x1b\x98" "\x6c\x4f\xb3\x3f\xf7\x97\x5b\x0d\x66\x4c\x86\x46\xb7\xf4\x77\xeb\xd8\xbb" "\x65\x95\xf5\x31\x07\xa2\xd8\xb7\x4c\x8e\x99\x1a\x4f\xb4\xb4\xf6\xf9\x43" "\x0f\xee\x2f\x77\x29\x9e\xfe\x80\x65\xc0\x4a\x79\xe0\xcf\x5c\x41\x83\x6a" "\x80\xc3\xad\x99\x10\xe7\x96\xae\xf8\xac\xb6\xbf\x6b\x49\xb1\x8c\x9d\xcc" "\xfc\x31\x24\x8c\x15\x6d\x9c\xd0\x97\xe0\xc2\xd5\xec\xb6\xac\xb7\x75\xbd" "\x60\x75\x76\x33\xad\xa2\x7e\xba\x81\x0e\x8e\xe9\x72\xf4\x24\xa4\x56\x9f" "\xa3\x6b\x01\x00\x00\x00\x64\xd4\xf4\xb9\xea\xa9\xc3\xf3\x33\xfb\xd0\x04" "\x1e\xd9\x19\x7b\x79\xb6\x70\x91\xba\xd9\xa5\x04\x56\x31\x87\xf5\x70\xf1" "\xff\xf2\x14\x7d\xb5\xd8\x4b\x4b\xe2\xa2\x4c\x9a\xa0\xf6\x75\xcc\xc2\xbf" "\xcd\x29\x78\xfb\x0c\x51\x34\xe3\x8e\x2e\x1b\x15\x64\x52\xc7\x12\x3c\x2d" "\x01\x51\x73\x46\xf8\x5e\xaa\xf1\x5e\x06\x07\x62\x67\x64\xd9\xcb\xcf\xda" "\xeb\x6b\x86\x5c\x64\x4d\x5a\x60\xf2\x01\xed\x14\x23\x01\x0b\xb8\xbb\xd2" "\xf3\xa8\xd6\x61\x7c\x21\x9e\x67\x50\x5b\x66\x2d\x9f\x3c\x43\xff\xea\x0c" "\xae\x7d\xea\x30\x18\x93\x5b\xc2\xd7\x70\x54\x47\xc4\x9f\xd9\x2f\xf7\xb3" "\x5d\xd8\xb7\x96\xf8\x24\xa7\x7a\x8c\x1b\xf7\x01\xcd\x99\x17\x5d\x4c\x40" "\x64\x68\x55\x7c\xf5\xdc\x6c\x7d\x1d\x7e\xc4\xf9\xcb\x81\x34\xe9\xfe\x3a" "\x2f\x81\x57\x50\x7f\xc7\xf8\x68\xdc\x14\xff\xc8\x5f\x6f\x1e\x91\x29\xca" "\x37\x78\x26\x22\xce\x94\x5d\xaf\xd3\x0c\xa4\xf7\x7f\xfb\x02\xae\x92\xd1" "\xb5\xbd\x4f\xd0\x26\x5b\xad\xf6\xe2\x5f\x82\x67\x43\x72\xf1\x36\xf9\x93" "\xda\x50\xc4\x2c\x61\x9a\x47\x90\x9e\xc9\xb8\xad\x14\x07\x2e\xec\x93\x77" "\x08\x3e\xb7\xf1\xf3\xcb\xb4\x97\x32\x85\x32\xcb\x0f\xbd\x52\x12\x14\x1d" "\x4c\xfa\x4e\x46\x7c\xf1\xa7\xdc\x8e\xee\xb9\x7a\x77\xef\x89\x67\xa9\xde" "\xc8\xcd\x80\xe3\x13\xc4\x6f\x65\x46\xe0\xc1\xd6\x38\x0a\x0a\x61\x6f\xff" "\x0a\x74\xf6\x7a\x2a\xe2\x01\xbd\x03\x4b\x55\xd7\x15\x1f\xdd\xb6\x6a\xb8" "\x4d\xe2\xdf\xe9\x31\xc8\x56\x98\x7a\x88\x85\xce\xd3\x58\x3a\x77\xa0\xfa" "\xa8\xb7\xd7\x0d\xba\xd1\xb6\xa6\xdd\xf4\x73\xfe\xf8\x06\x4d\xf2\xa6\x11" "\x23\x2d\x97\xdf\x9d\x46\xac\x2a\x1c\x07\x24\x76\x23\x16\x95\xb2\xd9\xbb" "\xe8\x58\x89\x99\x21\xb3\x98\x88\xac\x36\x67\xdf\xd0\x20\x42\x69\xb7\x6e" "\x4d\x08\xc6\xb8\xa5\x92\x96\xa0\xd9\xf0\x8a\x16\xbd\x87\x21\x12\xc3\x93" "\x5a\x6c\x3b\x70\xdb\x92\xf3\x7a\x75\x41\x2d\xc7\x97\x5e\x94\x15\x0c" "\x05", 810); *(uint64_t*)0x20000158 = 0xfffffffffffffed6; *(uint64_t*)0x20000160 = 0; *(uint64_t*)0x20000168 = 0; syscall(__NR_ioctl, r[0], 0xc0306201, 0x20000140); } int main(void) { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); loop(); return 0; }