// https://syzkaller.appspot.com/bug?id=883431818e036ae6a9981156a64b821110f39187 // autogenerated by syzkaller (http://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include __attribute__((noreturn)) static void doexit(int status) { volatile unsigned i; syscall(__NR_exit_group, status); for (i = 0;; i++) { } } #include #include const int kFailStatus = 67; const int kRetryStatus = 69; static void exitf(const char* msg, ...) { int e = errno; va_list args; va_start(args, msg); vfprintf(stderr, msg, args); va_end(args); fprintf(stderr, " (errno %d)\n", e); doexit(kRetryStatus); } 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) { close(fd); 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) exitf("failed to open /proc/thread-self/fail-nth"); sprintf(buf, "%d", nth + 1); if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf)) exitf("failed to write /proc/thread-self/fail-nth"); return fd; } static void test(); void loop() { while (1) { test(); } } void test() { syscall(__NR_mmap, 0x20000000, 0xfff000, 3, 0x32, -1, 0); *(uint32_t*)0x2025c000 = 2; *(uint32_t*)0x2025c004 = 0x78; *(uint8_t*)0x2025c008 = 0xe2; *(uint8_t*)0x2025c009 = 0; *(uint8_t*)0x2025c00a = 0; *(uint8_t*)0x2025c00b = 0; *(uint32_t*)0x2025c00c = 0; *(uint64_t*)0x2025c010 = 0; *(uint64_t*)0x2025c018 = 0; *(uint64_t*)0x2025c020 = 0; *(uint8_t*)0x2025c028 = 0x72; *(uint8_t*)0x2025c029 = 0; *(uint8_t*)0x2025c02a = 0; *(uint8_t*)0x2025c02b = 0; *(uint32_t*)0x2025c02c = 0; *(uint32_t*)0x2025c030 = 0; *(uint32_t*)0x2025c034 = 0; *(uint64_t*)0x2025c038 = 0; *(uint64_t*)0x2025c040 = 0; *(uint64_t*)0x2025c048 = 0; *(uint64_t*)0x2025c050 = 0; *(uint64_t*)0x2025c058 = 0; *(uint32_t*)0x2025c060 = 0; *(uint64_t*)0x2025c068 = 0; *(uint32_t*)0x2025c070 = 0; *(uint16_t*)0x2025c074 = 0; *(uint16_t*)0x2025c076 = 0; syscall(__NR_perf_event_open, 0x2025c000, 0, 0, -1, 0); memcpy((void*)0x204aeff6, "/dev/ptmx", 10); write_file("/sys/kernel/debug/failslab/ignore-gfp-wait", "N"); write_file("/sys/kernel/debug/fail_futex/ignore-private", "N"); inject_fault(6); syscall(__NR_openat, 0xffffffffffffff9c, 0x204aeff6, 0x4000, 0); } int main() { for (;;) { loop(); } }