// https://syzkaller.appspot.com/bug?id=524be83fa28f8e505866554a99eebc187fda36bc // 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 #include #ifndef __NR_bpf #define __NR_bpf 321 #endif static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } #define BITMASK(bf_off, bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type, htobe, addr, val, bf_off, bf_len) \ *(type*)(addr) = \ htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | \ (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) 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 void setup_sysctl() { int cad_pid = fork(); if (cad_pid < 0) exit(1); if (cad_pid == 0) { for (;;) sleep(100); } char tmppid[32]; snprintf(tmppid, sizeof(tmppid), "%d", cad_pid); struct { const char* name; const char* data; } files[] = { {"/sys/kernel/debug/x86/nmi_longest_ns", "10000000000"}, {"/proc/sys/kernel/hung_task_check_interval_secs", "20"}, {"/proc/sys/net/core/bpf_jit_kallsyms", "1"}, {"/proc/sys/net/core/bpf_jit_harden", "0"}, {"/proc/sys/kernel/kptr_restrict", "0"}, {"/proc/sys/kernel/softlockup_all_cpu_backtrace", "1"}, {"/proc/sys/fs/mount-max", "100"}, {"/proc/sys/vm/oom_dump_tasks", "0"}, {"/proc/sys/debug/exception-trace", "0"}, {"/proc/sys/kernel/printk", "7 4 1 3"}, {"/proc/sys/kernel/keys/gc_delay", "1"}, {"/proc/sys/vm/oom_kill_allocating_task", "1"}, {"/proc/sys/kernel/ctrl-alt-del", "0"}, {"/proc/sys/kernel/cad_pid", tmppid}, }; for (size_t i = 0; i < sizeof(files) / sizeof(files[0]); i++) { if (!write_file(files[i].name, files[i].data)) { } } kill(cad_pid, SIGKILL); while (waitpid(cad_pid, NULL, 0) != cad_pid) ; } uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff}; int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); setup_sysctl(); const char* reason; (void)reason; use_temporary_dir(); intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } *(uint32_t*)0x2000000002c0 = 0x1b; *(uint32_t*)0x2000000002c4 = 0; *(uint32_t*)0x2000000002c8 = 0; *(uint32_t*)0x2000000002cc = 0x8000; *(uint32_t*)0x2000000002d0 = 0; *(uint32_t*)0x2000000002d4 = -1; *(uint32_t*)0x2000000002d8 = 0; memset((void*)0x2000000002dc, 0, 16); *(uint32_t*)0x2000000002ec = 0; *(uint32_t*)0x2000000002f0 = -1; *(uint32_t*)0x2000000002f4 = 0; *(uint32_t*)0x2000000002f8 = 0; *(uint32_t*)0x2000000002fc = 0; *(uint64_t*)0x200000000300 = 0; *(uint32_t*)0x200000000308 = 0; *(uint32_t*)0x20000000030c = 0; res = syscall(__NR_bpf, /*cmd=*/0ul, /*arg=*/0x2000000002c0ul, /*size=*/0x48ul); if (res != -1) r[0] = res; *(uint32_t*)0x200000000380 = 0x1f; *(uint32_t*)0x200000000384 = 0xd; *(uint64_t*)0x200000000388 = 0x200000000100; *(uint8_t*)0x200000000100 = 0x18; STORE_BY_BITMASK(uint8_t, , 0x200000000101, 0, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x200000000101, 0, 4, 4); *(uint16_t*)0x200000000102 = 0; *(uint32_t*)0x200000000104 = 0xfffffffc; *(uint8_t*)0x200000000108 = 0; *(uint8_t*)0x200000000109 = 0; *(uint16_t*)0x20000000010a = 0; *(uint32_t*)0x20000000010c = 7; *(uint8_t*)0x200000000110 = 0x85; *(uint8_t*)0x200000000111 = 0; *(uint16_t*)0x200000000112 = 0; *(uint32_t*)0x200000000114 = 0x11; *(uint8_t*)0x200000000118 = 0x18; STORE_BY_BITMASK(uint8_t, , 0x200000000119, 1, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x200000000119, 1, 4, 4); *(uint16_t*)0x20000000011a = 0; *(uint32_t*)0x20000000011c = r[0]; *(uint8_t*)0x200000000120 = 0; *(uint8_t*)0x200000000121 = 0; *(uint16_t*)0x200000000122 = 0; *(uint32_t*)0x200000000124 = 0; STORE_BY_BITMASK(uint8_t, , 0x200000000128, 7, 0, 3); STORE_BY_BITMASK(uint8_t, , 0x200000000128, 0, 3, 1); STORE_BY_BITMASK(uint8_t, , 0x200000000128, 0xb, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x200000000129, 8, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x200000000129, 0, 4, 4); *(uint16_t*)0x20000000012a = 0; *(uint32_t*)0x20000000012c = 0x20000002; STORE_BY_BITMASK(uint8_t, , 0x200000000130, 3, 0, 3); STORE_BY_BITMASK(uint8_t, , 0x200000000130, 3, 3, 2); STORE_BY_BITMASK(uint8_t, , 0x200000000130, 3, 5, 3); STORE_BY_BITMASK(uint8_t, , 0x200000000131, 0xa, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x200000000131, 8, 4, 4); *(uint16_t*)0x200000000132 = 0xfff8; *(uint32_t*)0x200000000134 = 0; STORE_BY_BITMASK(uint8_t, , 0x200000000138, 7, 0, 3); STORE_BY_BITMASK(uint8_t, , 0x200000000138, 1, 3, 1); STORE_BY_BITMASK(uint8_t, , 0x200000000138, 0xb, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x200000000139, 2, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x200000000139, 0xa, 4, 4); *(uint16_t*)0x20000000013a = 0; *(uint32_t*)0x20000000013c = 0; STORE_BY_BITMASK(uint8_t, , 0x200000000140, 7, 0, 3); STORE_BY_BITMASK(uint8_t, , 0x200000000140, 0, 3, 1); STORE_BY_BITMASK(uint8_t, , 0x200000000140, 0, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x200000000141, 2, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x200000000141, 0, 4, 4); *(uint16_t*)0x200000000142 = 0; *(uint32_t*)0x200000000144 = 0xfffffff8; STORE_BY_BITMASK(uint8_t, , 0x200000000148, 7, 0, 3); STORE_BY_BITMASK(uint8_t, , 0x200000000148, 0, 3, 1); STORE_BY_BITMASK(uint8_t, , 0x200000000148, 0xb, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x200000000149, 3, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x200000000149, 0, 4, 4); *(uint16_t*)0x20000000014a = 0; *(uint32_t*)0x20000000014c = 8; STORE_BY_BITMASK(uint8_t, , 0x200000000150, 7, 0, 3); STORE_BY_BITMASK(uint8_t, , 0x200000000150, 0, 3, 1); STORE_BY_BITMASK(uint8_t, , 0x200000000150, 0xb, 4, 4); STORE_BY_BITMASK(uint8_t, , 0x200000000151, 4, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x200000000151, 0, 4, 4); *(uint16_t*)0x200000000152 = 0; *(uint32_t*)0x200000000154 = 1; *(uint8_t*)0x200000000158 = 0x85; *(uint8_t*)0x200000000159 = 0; *(uint16_t*)0x20000000015a = 0; *(uint32_t*)0x20000000015c = 0xa6; *(uint8_t*)0x200000000160 = 0x95; *(uint8_t*)0x200000000161 = 0; *(uint16_t*)0x200000000162 = 0; *(uint32_t*)0x200000000164 = 0; *(uint64_t*)0x200000000390 = 0x2000000000c0; memcpy((void*)0x2000000000c0, "GPL\000", 4); *(uint32_t*)0x200000000398 = 0; *(uint32_t*)0x20000000039c = 0; *(uint64_t*)0x2000000003a0 = 0; *(uint32_t*)0x2000000003a8 = 0; *(uint32_t*)0x2000000003ac = 0x34; memset((void*)0x2000000003b0, 0, 16); *(uint32_t*)0x2000000003c0 = 0; *(uint32_t*)0x2000000003c4 = 0; *(uint32_t*)0x2000000003c8 = -1; *(uint32_t*)0x2000000003cc = 8; *(uint64_t*)0x2000000003d0 = 0; *(uint32_t*)0x2000000003d8 = 0; *(uint32_t*)0x2000000003dc = 0x10; *(uint64_t*)0x2000000003e0 = 0; *(uint32_t*)0x2000000003e8 = 0; *(uint32_t*)0x2000000003ec = 0; *(uint32_t*)0x2000000003f0 = 0; *(uint32_t*)0x2000000003f4 = 0; *(uint64_t*)0x2000000003f8 = 0; *(uint64_t*)0x200000000400 = 0; *(uint32_t*)0x200000000408 = 0x10; *(uint32_t*)0x20000000040c = 0xfff; *(uint32_t*)0x200000000410 = 0; res = syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0x200000000380ul, /*size=*/0x94ul); if (res != -1) r[1] = res; *(uint32_t*)0x200000000500 = r[1]; *(uint32_t*)0x200000000504 = 0; *(uint32_t*)0x200000000508 = 0; *(uint32_t*)0x20000000050c = 0; *(uint64_t*)0x200000000510 = 0; *(uint64_t*)0x200000000518 = 0; *(uint32_t*)0x200000000520 = 0; *(uint32_t*)0x200000000524 = 0; *(uint32_t*)0x200000000528 = 0; *(uint32_t*)0x20000000052c = 0; *(uint64_t*)0x200000000530 = 0; *(uint64_t*)0x200000000538 = 0; *(uint32_t*)0x200000000540 = 0; *(uint32_t*)0x200000000544 = 0; *(uint32_t*)0x200000000548 = 0; syscall(__NR_bpf, /*cmd=*/0xaul, /*arg=*/0x200000000500ul, /*size=*/0x48ul); return 0; }