// https://syzkaller.appspot.com/bug?id=e634bd820c7bd376c401dd05f3ba79fe401f44ec // 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); 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) { } } #define SYZ_HAVE_SETUP_TEST 1 static void setup_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); write_file("/proc/self/oom_score_adj", "1000"); } #define SYZ_HAVE_RESET_TEST 1 static void reset_test() { int fd; for (fd = 3; fd < 30; fd++) close(fd); } 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(); reset_test(); 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_memfd_create #define __NR_memfd_create 319 #endif uint64_t r[2] = {0xffffffffffffffff, 0x0}; void execute_one(void) { long res = 0; memcpy((void*)0x20000180, "\006\000\000\000^\000\254\330\375\314\356q\345\365\313\2001`" "\3448\205\244\365\320\033\\\004\f\370F\\\264\272\215\357\022d\356\245" "?\000kZ\213\031h\327|" "\024i\r\030U9\301\327\020\360G\022\250\272a\262\224|%n\036+" "\237\273\270\254\201\215\223q\324\324z\252Z\017\252\307\227#\345g " "l\3255\025\277\374\365\203\2672\000Y\025\222\261\266a\364\351u\262" "\347\354iy\b\333\307\361\207\311\a\221\004J\310\016\377|" "J\'Nxr\000\274\2535\233\205>" "\231\312z2\253KI\334\344\237\245\320\016wm\347\314K\311\213\213E\211" "\003\000\000\000}@Ry\2469^\334\235\240\004\337 " "\aelO7\361\332\314\242x\302\232\365\030F\240\200M\371,+\311\367/" "nt\233a\024\033\030\335\030X\322o\025\227L\346\265\272\307\362W\n\177" "\024ZIL:" "T\033d\031\215E\234\261\271JK\035o\205\351\242\312\234d\b\310\275iQ_" "L\260\271 " "\367/" "F\374\'M#,\204M\272\251\242yr\'?f\tb\332i\375\214\232oj\204\003i\212|" "\367T;=p\242\230f\307\357u=" "\226\313\021\221\316\316\276v\252\273\312\372\243\336\325\037\327\003" ":12\362\375\rN\204=A\256\2333\201\251~" "\267\200\321\342\366\362\270\311\212\253C\342\354\270," "j\341\273\033\037@", 362); res = syscall(__NR_memfd_create, 0x20000180, 3); if (res != -1) r[0] = res; res = syscall(__NR_io_setup, 0x40, 0x200000c0); if (res != -1) r[1] = *(uint64_t*)0x200000c0; *(uint64_t*)0x200003c0 = 0x20000140; *(uint64_t*)0x20000140 = 0; *(uint32_t*)0x20000148 = 0; *(uint32_t*)0x2000014c = 0; *(uint16_t*)0x20000150 = 5; *(uint16_t*)0x20000152 = 0; *(uint32_t*)0x20000154 = r[0]; *(uint64_t*)0x20000158 = 0; *(uint64_t*)0x20000160 = 0; *(uint64_t*)0x20000168 = 0; *(uint64_t*)0x20000170 = 0; *(uint32_t*)0x20000178 = 0; *(uint32_t*)0x2000017c = -1; syscall(__NR_io_submit, r[1], 0x20000258, 0x200003c0); } int main(void) { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); loop(); return 0; }