// https://syzkaller.appspot.com/bug?id=b8afb3d95297388287141f3721edb7a94b0280c5 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include static __thread int skip_segv; static __thread jmp_buf segv_env; static void segv_handler(int sig, siginfo_t* info, void* ctx) { uintptr_t addr = (uintptr_t)info->si_addr; const uintptr_t prog_start = 1 << 20; const uintptr_t prog_end = 100 << 20; if (__atomic_load_n(&skip_segv, __ATOMIC_RELAXED) && (addr < prog_start || addr > prog_end)) { _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(...) \ { \ __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); \ if (_setjmp(segv_env) == 0) { \ __VA_ARGS__; \ } \ __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); \ } uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0x0}; int main(void) { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); install_segv_handler(); long res = 0; NONFAILING(memcpy((void*)0x20000180, "\x73\x74\x61\x74\x09\xc0\xc2\xfe\xbc\xf9\xdf\x2d\xea\xc8" "\xc1\x77\xff\x17\x12\x48\xe9\x11\x93\x51\x30\x49\xf8\x31" "\x55\x0d\x6f\x7d\xe6\x6c\xf6\x37\xbd\xbf\x13\x11\x92\x0c" "\x8a\x26\xed\xa4\xdc\xc3\x78\x3f\x9d\xb5\x11\x6b\x34\xd3" "\x1b\x05\x12\xa5\x60\x8a\xaf\xf0\x1e\x79\x52\x34\x0c\xd6" "\xfd\x00\x00\x00\x00", 75)); res = syscall(__NR_openat, 0xffffff9c, 0x20000180, 0x275a, 0); if (res != -1) r[0] = res; NONFAILING(memcpy((void*)0x200005c0, "\xf7", 1)); syscall(__NR_pwrite64, r[0], 0x200005c0, 1, 0); NONFAILING(memcpy((void*)0x20000000, "cgroup.controllers", 19)); res = syscall(__NR_openat, 0xffffff9c, 0x20000000, 0x275a, 0); if (res != -1) r[1] = res; NONFAILING(sprintf((char*)0x20000100, "0x%016llx", (long long)0)); syscall(__NR_write, r[1], 0x20000100, 0x12); NONFAILING(*(uint16_t*)0x20000080 = 0); NONFAILING(*(uint16_t*)0x20000082 = 0); NONFAILING(*(uint64_t*)0x20000088 = 0xffff); NONFAILING(*(uint64_t*)0x20000090 = 2); NONFAILING(*(uint32_t*)0x20000098 = 0); NONFAILING(*(uint32_t*)0x2000009c = 0); NONFAILING(*(uint32_t*)0x200000a0 = 0); NONFAILING(*(uint32_t*)0x200000a4 = 0); NONFAILING(*(uint32_t*)0x200000a8 = 0); NONFAILING(*(uint32_t*)0x200000ac = 0); syscall(__NR_ioctl, r[1], 0x40305828, 0x20000080); NONFAILING(*(uint16_t*)0x20000140 = 0); NONFAILING(*(uint16_t*)0x20000142 = 0); NONFAILING(*(uint64_t*)0x20000148 = 0x56cd4216); NONFAILING(*(uint64_t*)0x20000150 = 0x10001); NONFAILING(*(uint32_t*)0x20000158 = 0); NONFAILING(*(uint32_t*)0x2000015c = 0); NONFAILING(*(uint32_t*)0x20000160 = 0); NONFAILING(*(uint32_t*)0x20000164 = 0); NONFAILING(*(uint32_t*)0x20000168 = 0); NONFAILING(*(uint32_t*)0x2000016c = 0); syscall(__NR_ioctl, r[0], 0x40305828, 0x20000140); NONFAILING(memcpy( (void*)0x200000c0, "\x67\x72\x65\x30\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 16)); NONFAILING(*(uint32_t*)0x200000d0 = 0); res = syscall(__NR_ioctl, r[0], 0x8933, 0x200000c0); if (res != -1) NONFAILING(r[2] = *(uint32_t*)0x200000d0); NONFAILING(*(uint16_t*)0x20000280 = 0x11); NONFAILING(*(uint16_t*)0x20000282 = htobe16(0x10)); NONFAILING(*(uint32_t*)0x20000284 = r[2]); NONFAILING(*(uint16_t*)0x20000288 = 1); NONFAILING(*(uint8_t*)0x2000028a = 6); NONFAILING(*(uint8_t*)0x2000028b = 6); NONFAILING(*(uint8_t*)0x2000028c = 0xaa); NONFAILING(*(uint8_t*)0x2000028d = 0xaa); NONFAILING(*(uint8_t*)0x2000028e = 0xaa); NONFAILING(*(uint8_t*)0x2000028f = 0xaa); NONFAILING(*(uint8_t*)0x20000290 = 0xaa); NONFAILING(*(uint8_t*)0x20000291 = 0xaa); NONFAILING(*(uint8_t*)0x20000292 = 0); NONFAILING(*(uint8_t*)0x20000293 = 0); syscall(__NR_bind, r[0], 0x20000280, 0x14); NONFAILING(*(uint32_t*)0x20000300 = 0); NONFAILING(*(uint32_t*)0x20000304 = r[1]); NONFAILING(*(uint64_t*)0x20000308 = 0); NONFAILING(*(uint64_t*)0x20000310 = 0xfffa931c); NONFAILING(*(uint64_t*)0x20000318 = 0); NONFAILING(*(uint64_t*)0x20000320 = 0); syscall(__NR_ioctl, r[0], 0xc028660f, 0x20000300); return 0; }