// https://syzkaller.appspot.com/bug?id=cf95a10add560e71aaf41be5e7313e95b669bda6 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #ifndef __NR_memfd_create #define __NR_memfd_create 319 #endif static __thread int clone_ongoing; static __thread int skip_segv; static __thread jmp_buf segv_env; static void segv_handler(int sig, siginfo_t* info, void* ctx) { if (__atomic_load_n(&clone_ongoing, __ATOMIC_RELAXED) != 0) { exit(sig); } uintptr_t addr = (uintptr_t)info->si_addr; const uintptr_t prog_start = 1 << 20; const uintptr_t prog_end = 100 << 20; int skip = __atomic_load_n(&skip_segv, __ATOMIC_RELAXED) != 0; int valid = addr < prog_start || addr > prog_end; if (skip && valid) { _longjmp(segv_env, 1); } exit(sig); } static void install_segv_handler(void) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = SIG_IGN; syscall(SYS_rt_sigaction, 0x20, &sa, NULL, 8); syscall(SYS_rt_sigaction, 0x21, &sa, NULL, 8); memset(&sa, 0, sizeof(sa)); sa.sa_sigaction = segv_handler; sa.sa_flags = SA_NODEFER | SA_SIGINFO; sigaction(SIGSEGV, &sa, NULL); sigaction(SIGBUS, &sa, NULL); } #define NONFAILING(...) \ ({ \ int ok = 1; \ __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); \ if (_setjmp(segv_env) == 0) { \ __VA_ARGS__; \ } else \ ok = 0; \ __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); \ ok; \ }) uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; int main(void) { syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); install_segv_handler(); intptr_t res = 0; NONFAILING(memcpy( (void*)0x20000200, "-B\325NI\305j\232ppp\360\b\204\242m\000\v\030\0004\246Ey\333\321\247\261" "S\361:)\000\312\327Uw\000\274\3722\263\273\215\254\254va}knh#\317)" "\017\310\300:\234c\020d\356\251\213\0066\270G\321c\341$" "\377\227k\336\305\3516\335U)\3118\000\260\373\314\202n=\177=" "\315Jx\252\217~\2710a\251\262\004K\230\223=" "\253Q\367\005\035\241\316\213\031\352\357\343\313\201\017m;" "\305\363\344\307\255\260\au\367O8\0349\024b\327\fw\216\211K\223\006{" "H\223\262\307C\312\2577\253V\177{o{hTV0<\253\377\250\204\241F\"![" "\211\344/\374\0063\265h\\]\336\317xU\005\364>\352\366\357\336o1\f", 204)); res = syscall(__NR_memfd_create, 0x20000200ul, 0ul); if (res != -1) r[0] = res; res = syscall(__NR_dup, r[0]); if (res != -1) r[1] = res; NONFAILING(sprintf((char*)0x20000040, "0x%016llx", (long long)0)); syscall(__NR_write, r[1], 0x20000040ul, 0x12ul); syscall(__NR_mmap, 0x20000000ul, 0x1000ul, 4ul, 0x11ul, r[0], 0ul); NONFAILING(*(uint64_t*)0x20000100 = 0); syscall(__NR_sendfile, r[0], r[1], 0x20000100ul, 0x220ul); NONFAILING(memcpy((void*)0x20000200, "cgroup.controllers\000", 19)); res = syscall(__NR_openat, 0xffffff9c, 0x20000200ul, 0x26e1ul, 0ul); if (res != -1) r[2] = res; NONFAILING(memcpy((void*)0x20000080, "threaded\000", 9)); syscall(__NR_write, r[2], 0x20000080ul, 0x11ffffce1ul); return 0; }