// https://syzkaller.appspot.com/bug?id=bda1a87bea05a9072003e6447c44b03ca1492b1c // 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 static long syz_open_pts(long a0, long a1) { int ptyno = 0; if (ioctl(a0, TIOCGPTN, &ptyno)) return -1; char buf[128]; sprintf(buf, "/dev/pts/%d", ptyno); return open(buf, a1, 0); } 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 int inject_fault(int nth) { int fd; char buf[16]; fd = open("/proc/thread-self/fail-nth", O_RDWR); if (fd == -1) exit(1); sprintf(buf, "%d", nth + 1); if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf)) exit(1); return fd; } uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; int main(void) { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); long res = 0; res = syscall(__NR_socketpair, 1, 5, 0, 0x20000140); if (res != -1) r[0] = *(uint32_t*)0x20000144; syscall(__NR_ioctl, r[0], 0x8912, 0x400200); memcpy((void*)0x20000100, "/dev/ptmx", 10); res = syscall(__NR_openat, 0xffffffffffffff9c, 0x20000100, 0, 0); if (res != -1) r[1] = res; *(uint32_t*)0x20000080 = 0x208; *(uint32_t*)0x20000084 = 0; *(uint32_t*)0x20000088 = 0; *(uint32_t*)0x2000008c = 0x3ff; *(uint8_t*)0x20000090 = 0; *(uint8_t*)0x20000091 = 0; *(uint8_t*)0x20000092 = 0; *(uint8_t*)0x20000093 = 0; *(uint32_t*)0x20000094 = 0; *(uint32_t*)0x20000098 = 0; *(uint32_t*)0x2000009c = 0; *(uint32_t*)0x200000a0 = 0; syscall(__NR_ioctl, r[1], 0x5402, 0x20000080); *(uint32_t*)0x203b9fdc = 0; *(uint32_t*)0x203b9fe0 = 0; *(uint32_t*)0x203b9fe4 = 0; *(uint32_t*)0x203b9fe8 = 0; *(uint8_t*)0x203b9fec = 0; *(uint8_t*)0x203b9fed = 0; *(uint8_t*)0x203b9fee = 0; *(uint8_t*)0x203b9fef = 0; *(uint32_t*)0x203b9ff0 = 0; *(uint32_t*)0x203b9ff4 = 0; *(uint32_t*)0x203b9ff8 = 0; *(uint32_t*)0x203b9ffc = 0; syscall(__NR_ioctl, r[1], 0x40045431, 0x203b9fdc); res = syz_open_pts(r[1], 0); if (res != -1) r[2] = res; *(uint32_t*)0x20000040 = 0; *(uint32_t*)0x20000044 = 0; *(uint32_t*)0x20000048 = 0; *(uint32_t*)0x2000004c = 0; *(uint8_t*)0x20000050 = 0; *(uint8_t*)0x20000051 = 0; *(uint8_t*)0x20000052 = 0; *(uint8_t*)0x20000053 = 0; *(uint32_t*)0x20000054 = 0; *(uint32_t*)0x20000058 = 0; *(uint32_t*)0x2000005c = 0; *(uint32_t*)0x20000060 = 0; write_file("/sys/kernel/debug/failslab/ignore-gfp-wait", "N"); write_file("/sys/kernel/debug/fail_futex/ignore-private", "N"); inject_fault(0); syscall(__NR_ioctl, r[2], 0x5412, 0x20000040); return 0; }