// https://syzkaller.appspot.com/bug?id=1f6c88cf262094cc3000762d0235183c034e3b77 // 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 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[2] = {0xffffffffffffffff, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // openat$fb0 arguments: [ // fd: const = 0xffffffffffffff9c (8 bytes) // file: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 66 62 30 00} (length 0x9) // } // flags: open_flags = 0x0 (4 bytes) // mode: const = 0x0 (2 bytes) // ] // returns fd_fb memcpy((void*)0x2000000002c0, "/dev/fb0\000", 9); res = syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0x2000000002c0ul, /*flags=*/0, /*mode=*/0); if (res != -1) r[0] = res; // ioctl$FBIOPUT_VSCREENINFO arguments: [ // fd: fd_fb (resource) // cmd: const = 0x4601 (4 bytes) // arg: ptr[in, fb_var_screeninfo] { // fb_var_screeninfo { // xres: fb_xres = 0x36a (4 bytes) // yres: fb_yres = 0x78 (4 bytes) // xres_virtual: fb_xres = 0x300 (4 bytes) // yres_virtual: fb_yres = 0x0 (4 bytes) // xoffset: int32 = 0xa (4 bytes) // yoffset: int32 = 0x0 (4 bytes) // bits_per_pixel: fb_bpp = 0x0 (4 bytes) // grayscale: int32 = 0x0 (4 bytes) // red: fb_bitfield { // offset: int32 = 0x0 (4 bytes) // length: int32 = 0x0 (4 bytes) // msb_right: int32 = 0x0 (4 bytes) // } // green: fb_bitfield { // offset: int32 = 0x0 (4 bytes) // length: int32 = 0x0 (4 bytes) // msb_right: int32 = 0x0 (4 bytes) // } // blue: fb_bitfield { // offset: int32 = 0x0 (4 bytes) // length: int32 = 0x0 (4 bytes) // msb_right: int32 = 0x0 (4 bytes) // } // transp: fb_bitfield { // offset: int32 = 0x0 (4 bytes) // length: int32 = 0x0 (4 bytes) // msb_right: int32 = 0x0 (4 bytes) // } // nonstd: fb_nonstd = 0x0 (4 bytes) // activate: fb_activate = 0x40 (4 bytes) // height: int32 = 0x0 (4 bytes) // width: int32 = 0x1 (4 bytes) // accel_flags: fb_accel_flags = 0x1 (4 bytes) // pixclock: int32 = 0x4 (4 bytes) // left_margin: int32 = 0x9f6 (4 bytes) // right_margin: int32 = 0x3 (4 bytes) // upper_margin: int32 = 0x1ff (4 bytes) // lower_margin: int32 = 0x803d (4 bytes) // hsync_len: int32 = 0x1 (4 bytes) // vsync_len: int32 = 0x7 (4 bytes) // sync: fb_sync = 0x5f (4 bytes) // vmode: fb_mode = 0x202 (4 bytes) // rotate: fb_rotate = 0x1 (4 bytes) // colorspace: v4l2_colorspace = 0xc (4 bytes) // reserved: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} // (length 0x10) // } // } // ] *(uint32_t*)0x200000000380 = 0x36a; *(uint32_t*)0x200000000384 = 0x78; *(uint32_t*)0x200000000388 = 0x300; *(uint32_t*)0x20000000038c = 0; *(uint32_t*)0x200000000390 = 0xa; *(uint32_t*)0x200000000394 = 0; *(uint32_t*)0x200000000398 = 0; *(uint32_t*)0x20000000039c = 0; *(uint32_t*)0x2000000003a0 = 0; *(uint32_t*)0x2000000003a4 = 0; *(uint32_t*)0x2000000003a8 = 0; *(uint32_t*)0x2000000003ac = 0; *(uint32_t*)0x2000000003b0 = 0; *(uint32_t*)0x2000000003b4 = 0; *(uint32_t*)0x2000000003b8 = 0; *(uint32_t*)0x2000000003bc = 0; *(uint32_t*)0x2000000003c0 = 0; *(uint32_t*)0x2000000003c4 = 0; *(uint32_t*)0x2000000003c8 = 0; *(uint32_t*)0x2000000003cc = 0; *(uint32_t*)0x2000000003d0 = 0; *(uint32_t*)0x2000000003d4 = 0x40; *(uint32_t*)0x2000000003d8 = 0; *(uint32_t*)0x2000000003dc = 1; *(uint32_t*)0x2000000003e0 = 1; *(uint32_t*)0x2000000003e4 = 4; *(uint32_t*)0x2000000003e8 = 0x9f6; *(uint32_t*)0x2000000003ec = 3; *(uint32_t*)0x2000000003f0 = 0x1ff; *(uint32_t*)0x2000000003f4 = 0x803d; *(uint32_t*)0x2000000003f8 = 1; *(uint32_t*)0x2000000003fc = 7; *(uint32_t*)0x200000000400 = 0x5f; *(uint32_t*)0x200000000404 = 0x202; *(uint32_t*)0x200000000408 = 1; *(uint32_t*)0x20000000040c = 0xc; memset((void*)0x200000000410, 0, 16); syscall(__NR_ioctl, /*fd=*/r[0], /*cmd=*/0x4601, /*arg=*/0x200000000380ul); // mkdirat arguments: [ // fd: fd_dir (resource) // path: ptr[in, buffer] { // buffer: {2e 2f 73 79 73 00} (length 0x6) // } // mode: open_mode = 0x1ff (8 bytes) // ] memcpy((void*)0x200000000180, "./sys\000", 6); syscall( __NR_mkdirat, /*fd=*/0xffffff9c, /*path=*/0x200000000180ul, /*mode=S_IXOTH|S_IWOTH|S_IROTH|S_IXGRP|S_IWGRP|S_IRGRP|S_IXUSR|S_IWUSR|0x100*/ 0x1fful); // mount arguments: [ // src: nil // dst: ptr[in, buffer] { // buffer: {2e 2f 73 79 73 00} (length 0x6) // } // type: ptr[in, buffer] { // buffer: {73 79 73 66 73 00} (length 0x6) // } // flags: mount_flags = 0x0 (8 bytes) // data: nil // ] memcpy((void*)0x2000000001c0, "./sys\000", 6); memcpy((void*)0x200000000200, "sysfs\000", 6); syscall(__NR_mount, /*src=*/0ul, /*dst=*/0x2000000001c0ul, /*type=*/0x200000000200ul, /*flags=*/0ul, /*data=*/0ul); // openat arguments: [ // fd: fd_dir (resource) // file: ptr[in, buffer] { // buffer: {2e 2f 73 79 73 2f 63 6c 61 73 73 2f 76 74 63 6f 6e 73 6f 6c // 65 2f 76 74 63 6f 6e 31 2f 62 69 6e 64 00} (length 0x22) // } // flags: open_flags = 0x1 (4 bytes) // mode: open_mode = 0x0 (2 bytes) // ] // returns fd memcpy((void*)0x200000000180, "./sys/class/vtconsole/vtcon1/bind\000", 34); res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x200000000180ul, /*flags=O_WRONLY*/ 1, /*mode=*/0); if (res != -1) r[1] = res; // write$FUSE_INTERRUPT arguments: [ // fd: fd_fuse (resource) // arg: ptr[in, fuse_out_t[fuse_unique, void]] { // fuse_out_t[fuse_unique, void] { // len: len = 0x10 (4 bytes) // err: fuse_errors = 0xffffffffffffffda (4 bytes) // unique: fuse_unique (resource) // payload: buffer: {} (length 0x0) // } // } // len: bytesize = 0x10 (8 bytes) // ] *(uint32_t*)0x200000002bc0 = 0x10; *(uint32_t*)0x200000002bc4 = 0xffffffda; *(uint64_t*)0x200000002bc8 = 0; syscall(__NR_write, /*fd=*/r[1], /*arg=*/0x200000002bc0ul, /*len=*/0x10ul); // write arguments: [ // fd: fd (resource) // buf: ptr[in, buffer] { // buffer: {31} (length 0x1) // } // count: len = 0x1 (8 bytes) // ] memset((void*)0x200000000280, 49, 1); syscall(__NR_write, /*fd=*/r[1], /*buf=*/0x200000000280ul, /*count=*/1ul); } 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; loop(); return 0; }