// https://syzkaller.appspot.com/bug?id=987533394eda5f97c1e30b2a5346b6c3b452d5ac // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef __NR_memfd_create #define __NR_memfd_create 319 #endif 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; fd = open("/proc/thread-self/fail-nth", O_RDWR); if (fd == -1) exit(1); char buf[16]; sprintf(buf, "%d", nth); if (write(fd, buf, strlen(buf)) != (ssize_t)strlen(buf)) exit(1); return fd; } static void setup_fault() { static struct { const char* file; const char* val; bool fatal; } files[] = { {"/sys/kernel/debug/failslab/ignore-gfp-wait", "N", true}, {"/sys/kernel/debug/fail_futex/ignore-private", "N", false}, {"/sys/kernel/debug/fail_page_alloc/ignore-gfp-highmem", "N", false}, {"/sys/kernel/debug/fail_page_alloc/ignore-gfp-wait", "N", false}, {"/sys/kernel/debug/fail_page_alloc/min-order", "0", false}, }; unsigned i; for (i = 0; i < sizeof(files) / sizeof(files[0]); i++) { if (!write_file(files[i].file, files[i].val)) { if (files[i].fatal) exit(1); } } } uint64_t r[1] = {0xffffffffffffffff}; int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=*/0x32ul, /*fd=*/-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000ul, /*prot=*/7ul, /*flags=*/0x32ul, /*fd=*/-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x21000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=*/0x32ul, /*fd=*/-1, /*offset=*/0ul); setup_fault(); intptr_t res = 0; memcpy( (void*)0x20000040, "\\)" "\200\232\202\262\343\352n\271\177\203m\200\252\256\271\005p\307\"nT\266-" "\345\231\006Z\327ue\272\370\204\3673\331\235)6L\261\224`\302L\206\332,E," "`\375\213j\rA\265\002&\220?\006P\v+}" "\275\201t\037\230T\363\230E\202\315o\020\'\233\261\020ya\320\275\252h`" "\336\030O\343L\2315\251F\345p\016\312O\265\034\243\377(3\3438K\340\307O@" ".\373\204h\\\001:U\203\005\25287\376\016\211\211-" "dL\245\204\352\035N\347\220\216\224\327j\2733\212W\241@\022\313," "\227\244C\271J\360\215ih\255Y\306\360\002t\360\225\312A;" "\346\261\364\204\030\363M\316Lq[<\025\270\340\2101\317\276\315\301\271}" "\367\306_8{\367\334K38M\370\377", 215); res = syscall(__NR_memfd_create, /*name=*/0x20000040ul, /*flags=*/0ul); if (res != -1) r[0] = res; syscall(__NR_mmap, /*addr=*/0x20ffd000ul, /*len=*/0x1ffffful, /*prot=*/0ul, /*flags=*/0x12ul, /*fd=*/r[0], /*offset=*/0ul); inject_fault(4); syscall(__NR_mmap, /*addr=*/0x20ffd000ul, /*len=*/0x3000ul, /*prot=*/0ul, /*flags=*/0x12ul, /*fd=*/r[0], /*offset=*/0ul); return 0; }