// https://syzkaller.appspot.com/bug?id=d9f237a286e2de641a654a104ff6e5da92fc698c // 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 (;;) { 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[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // prlimit64 arguments: [ // pid: pid (resource) // res: rlimit_type = 0xe (8 bytes) // new: ptr[in, rlimit] { // rlimit { // soft: intptr = 0xa (8 bytes) // hard: intptr = 0x8b (8 bytes) // } // } // old: nil // ] *(uint64_t*)0x200000000140 = 0xa; *(uint64_t*)0x200000000148 = 0x8b; syscall(__NR_prlimit64, /*pid=*/0, /*res=RLIMIT_RTPRIO*/ 0xeul, /*new=*/0x200000000140ul, /*old=*/0ul); // sched_setscheduler arguments: [ // pid: pid (resource) // policy: sched_policy = 0x1 (8 bytes) // prio: ptr[in, int32] { // int32 = 0x7 (4 bytes) // } // ] *(uint32_t*)0x200000000080 = 7; syscall(__NR_sched_setscheduler, /*pid=*/0, /*policy=SCHED_FIFO*/ 1ul, /*prio=*/0x200000000080ul); // socketpair$unix arguments: [ // domain: const = 0x1 (8 bytes) // type: unix_socket_type = 0x2 (8 bytes) // proto: const = 0x0 (4 bytes) // fds: ptr[out, unix_pair] { // unix_pair { // fd0: sock_unix (resource) // fd1: sock_unix (resource) // } // } // ] res = syscall(__NR_socketpair, /*domain=*/1ul, /*type=SOCK_DGRAM*/ 2ul, /*proto=*/0, /*fds=*/0x200000000540ul); if (res != -1) { r[0] = *(uint32_t*)0x200000000540; r[1] = *(uint32_t*)0x200000000544; } // sendmmsg$unix arguments: [ // fd: sock_unix (resource) // mmsg: ptr[in, array[send_mmsghdr_un]] { // array[send_mmsghdr_un] { // } // } // vlen: len = 0x651 (8 bytes) // f: send_flags = 0x0 (8 bytes) // ] syscall(__NR_sendmmsg, /*fd=*/r[1], /*mmsg=*/0x200000000000ul, /*vlen=*/0x651ul, /*f=*/0ul); // recvmmsg arguments: [ // fd: sock (resource) // mmsg: ptr[in, array[recv_mmsghdr]] { // array[recv_mmsghdr] { // } // } // vlen: len = 0x400034f (8 bytes) // f: recv_flags = 0x2 (8 bytes) // timeout: nil // ] syscall(__NR_recvmmsg, /*fd=*/r[0], /*mmsg=*/0x200000000480ul, /*vlen=*/0x400034ful, /*f=MSG_PEEK*/ 2ul, /*timeout=*/0ul); // 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*)0x200000000040, "/dev/fb0\000", 9); res = syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0x200000000040ul, /*flags=*/0, /*mode=*/0); if (res != -1) r[2] = 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 = 0x400 (4 bytes) // yres: fb_yres = 0x300 (4 bytes) // xres_virtual: fb_xres = 0x0 (4 bytes) // yres_virtual: fb_yres = 0x800 (4 bytes) // xoffset: int32 = 0xbbba (4 bytes) // yoffset: int32 = 0x0 (4 bytes) // bits_per_pixel: fb_bpp = 0x18 (4 bytes) // grayscale: int32 = 0x0 (4 bytes) // red: fb_bitfield { // offset: int32 = 0x8000 (4 bytes) // length: int32 = 0x0 (4 bytes) // msb_right: int32 = 0x0 (4 bytes) // } // green: fb_bitfield { // offset: int32 = 0x0 (4 bytes) // length: int32 = 0xfffffffd (4 bytes) // msb_right: int32 = 0xfffffffe (4 bytes) // } // blue: fb_bitfield { // offset: int32 = 0x0 (4 bytes) // length: int32 = 0xffff0000 (4 bytes) // msb_right: int32 = 0x0 (4 bytes) // } // transp: fb_bitfield { // offset: int32 = 0x1000000 (4 bytes) // length: int32 = 0x0 (4 bytes) // msb_right: int32 = 0x0 (4 bytes) // } // nonstd: fb_nonstd = 0x0 (4 bytes) // activate: fb_activate = 0x3f0 (4 bytes) // height: int32 = 0x0 (4 bytes) // width: int32 = 0xd613 (4 bytes) // accel_flags: fb_accel_flags = 0x0 (4 bytes) // pixclock: int32 = 0x0 (4 bytes) // left_margin: int32 = 0x0 (4 bytes) // right_margin: int32 = 0x0 (4 bytes) // upper_margin: int32 = 0x0 (4 bytes) // lower_margin: int32 = 0xfffffffd (4 bytes) // hsync_len: int32 = 0x0 (4 bytes) // vsync_len: int32 = 0x0 (4 bytes) // sync: fb_sync = 0x0 (4 bytes) // vmode: fb_mode = 0x4 (4 bytes) // rotate: fb_rotate = 0x0 (4 bytes) // colorspace: v4l2_colorspace = 0x0 (4 bytes) // reserved: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} // (length 0x10) // } // } // ] *(uint32_t*)0x200000000100 = 0x400; *(uint32_t*)0x200000000104 = 0x300; *(uint32_t*)0x200000000108 = 0; *(uint32_t*)0x20000000010c = 0x800; *(uint32_t*)0x200000000110 = 0xbbba; *(uint32_t*)0x200000000114 = 0; *(uint32_t*)0x200000000118 = 0x18; *(uint32_t*)0x20000000011c = 0; *(uint32_t*)0x200000000120 = 0x8000; *(uint32_t*)0x200000000124 = 0; *(uint32_t*)0x200000000128 = 0; *(uint32_t*)0x20000000012c = 0; *(uint32_t*)0x200000000130 = 0xfffffffd; *(uint32_t*)0x200000000134 = 0xfffffffe; *(uint32_t*)0x200000000138 = 0; *(uint32_t*)0x20000000013c = 0xffff0000; *(uint32_t*)0x200000000140 = 0; *(uint32_t*)0x200000000144 = 0x1000000; *(uint32_t*)0x200000000148 = 0; *(uint32_t*)0x20000000014c = 0; *(uint32_t*)0x200000000150 = 0; *(uint32_t*)0x200000000154 = 0x3f0; *(uint32_t*)0x200000000158 = 0; *(uint32_t*)0x20000000015c = 0xd613; *(uint32_t*)0x200000000160 = 0; *(uint32_t*)0x200000000164 = 0; *(uint32_t*)0x200000000168 = 0; *(uint32_t*)0x20000000016c = 0; *(uint32_t*)0x200000000170 = 0; *(uint32_t*)0x200000000174 = 0xfffffffd; *(uint32_t*)0x200000000178 = 0; *(uint32_t*)0x20000000017c = 0; *(uint32_t*)0x200000000180 = 0; *(uint32_t*)0x200000000184 = 4; *(uint32_t*)0x200000000188 = 0; *(uint32_t*)0x20000000018c = 0; memset((void*)0x200000000190, 0, 16); syscall(__NR_ioctl, /*fd=*/r[2], /*cmd=*/0x4601, /*arg=*/0x200000000100ul); } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000ul, /*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=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); const char* reason; (void)reason; loop(); return 0; }