// https://syzkaller.appspot.com/bug?id=48936ec7813d93df7f55fc23ad1273dd9212abc8 // 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 #include #include #include #include #include #include #include #include #include #ifndef __NR_bpf #define __NR_bpf 321 #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; \ }) static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } #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)))) struct csum_inet { uint32_t acc; }; static void csum_inet_init(struct csum_inet* csum) { csum->acc = 0; } static void csum_inet_update(struct csum_inet* csum, const uint8_t* data, size_t length) { if (length == 0) return; size_t i = 0; for (; i < length - 1; i += 2) csum->acc += *(uint16_t*)&data[i]; if (length & 1) csum->acc += le16toh((uint16_t)data[length - 1]); while (csum->acc > 0xffff) csum->acc = (csum->acc & 0xffff) + (csum->acc >> 16); } static uint16_t csum_inet_digest(struct csum_inet* csum) { return ~csum->acc; } 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; } #define MAX_FDS 30 static void setup_gadgetfs(); static void setup_binderfs(); static void setup_fusectl(); static void sandbox_common_mount_tmpfs(void) { write_file("/proc/sys/fs/mount-max", "100000"); if (mkdir("./syz-tmp", 0777)) exit(1); if (mount("", "./syz-tmp", "tmpfs", 0, NULL)) exit(1); if (mkdir("./syz-tmp/newroot", 0777)) exit(1); if (mkdir("./syz-tmp/newroot/dev", 0700)) exit(1); unsigned bind_mount_flags = MS_BIND | MS_REC | MS_PRIVATE; if (mount("/dev", "./syz-tmp/newroot/dev", NULL, bind_mount_flags, NULL)) exit(1); if (mkdir("./syz-tmp/newroot/proc", 0700)) exit(1); if (mount("syz-proc", "./syz-tmp/newroot/proc", "proc", 0, NULL)) exit(1); if (mkdir("./syz-tmp/newroot/selinux", 0700)) exit(1); const char* selinux_path = "./syz-tmp/newroot/selinux"; if (mount("/selinux", selinux_path, NULL, bind_mount_flags, NULL)) { if (errno != ENOENT) exit(1); if (mount("/sys/fs/selinux", selinux_path, NULL, bind_mount_flags, NULL) && errno != ENOENT) exit(1); } if (mkdir("./syz-tmp/newroot/sys", 0700)) exit(1); if (mount("/sys", "./syz-tmp/newroot/sys", 0, bind_mount_flags, NULL)) exit(1); if (mount("/sys/kernel/debug", "./syz-tmp/newroot/sys/kernel/debug", NULL, bind_mount_flags, NULL) && errno != ENOENT) exit(1); if (mount("/sys/fs/smackfs", "./syz-tmp/newroot/sys/fs/smackfs", NULL, bind_mount_flags, NULL) && errno != ENOENT) exit(1); if (mount("/proc/sys/fs/binfmt_misc", "./syz-tmp/newroot/proc/sys/fs/binfmt_misc", NULL, bind_mount_flags, NULL) && errno != ENOENT) exit(1); if (mkdir("./syz-tmp/newroot/syz-inputs", 0700)) exit(1); if (mount("/syz-inputs", "./syz-tmp/newroot/syz-inputs", NULL, bind_mount_flags | MS_RDONLY, NULL) && errno != ENOENT) exit(1); if (mkdir("./syz-tmp/pivot", 0777)) exit(1); if (syscall(SYS_pivot_root, "./syz-tmp", "./syz-tmp/pivot")) { if (chdir("./syz-tmp")) exit(1); } else { if (chdir("/")) exit(1); if (umount2("./pivot", MNT_DETACH)) exit(1); } if (chroot("./newroot")) exit(1); if (chdir("/")) exit(1); setup_gadgetfs(); setup_binderfs(); setup_fusectl(); } static void setup_gadgetfs() { if (mkdir("/dev/gadgetfs", 0777)) { } if (mount("gadgetfs", "/dev/gadgetfs", "gadgetfs", 0, NULL)) { } } static void setup_fusectl() { if (mount(0, "/sys/fs/fuse/connections", "fusectl", 0, 0)) { } } static void setup_binderfs() { if (mkdir("/dev/binderfs", 0777)) { } if (mount("binder", "/dev/binderfs", "binder", 0, NULL)) { } if (symlink("/dev/binderfs", "./binderfs")) { } } static void loop(); static void sandbox_common() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); if (getppid() == 1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = (200 << 20); setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 32 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 136 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); if (unshare(CLONE_NEWNS)) { } if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL)) { } if (unshare(CLONE_NEWIPC)) { } if (unshare(0x02000000)) { } if (unshare(CLONE_NEWUTS)) { } if (unshare(CLONE_SYSVSEM)) { } typedef struct { const char* name; const char* value; } sysctl_t; static const sysctl_t sysctls[] = { {"/proc/sys/kernel/shmmax", "16777216"}, {"/proc/sys/kernel/shmall", "536870912"}, {"/proc/sys/kernel/shmmni", "1024"}, {"/proc/sys/kernel/msgmax", "8192"}, {"/proc/sys/kernel/msgmni", "1024"}, {"/proc/sys/kernel/msgmnb", "1024"}, {"/proc/sys/kernel/sem", "1024 1048576 500 1024"}, }; unsigned i; for (i = 0; i < sizeof(sysctls) / sizeof(sysctls[0]); i++) write_file(sysctls[i].name, sysctls[i].value); } static int wait_for_loop(int pid) { if (pid < 0) exit(1); int status = 0; while (waitpid(-1, &status, __WALL) != pid) { } return WEXITSTATUS(status); } static void drop_caps(void) { struct __user_cap_header_struct cap_hdr = {}; struct __user_cap_data_struct cap_data[2] = {}; cap_hdr.version = _LINUX_CAPABILITY_VERSION_3; cap_hdr.pid = getpid(); if (syscall(SYS_capget, &cap_hdr, &cap_data)) exit(1); const int drop = (1 << CAP_SYS_PTRACE) | (1 << CAP_SYS_NICE); cap_data[0].effective &= ~drop; cap_data[0].permitted &= ~drop; cap_data[0].inheritable &= ~drop; if (syscall(SYS_capset, &cap_hdr, &cap_data)) exit(1); } static int do_sandbox_none(void) { if (unshare(CLONE_NEWPID)) { } int pid = fork(); if (pid != 0) return wait_for_loop(pid); sandbox_common(); drop_caps(); if (unshare(CLONE_NEWNET)) { } write_file("/proc/sys/net/ipv4/ping_group_range", "0 65535"); sandbox_common_mount_tmpfs(); loop(); exit(1); } static void kill_and_wait(int pid, int* status) { kill(-pid, SIGKILL); kill(pid, SIGKILL); for (int i = 0; i < 100; i++) { if (waitpid(-1, status, WNOHANG | __WALL) == pid) return; usleep(1000); } DIR* dir = opendir("/sys/fs/fuse/connections"); if (dir) { for (;;) { struct dirent* ent = readdir(dir); if (!ent) break; if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) continue; char abort[300]; snprintf(abort, sizeof(abort), "/sys/fs/fuse/connections/%s/abort", ent->d_name); int fd = open(abort, O_WRONLY); if (fd == -1) { continue; } if (write(fd, abort, 1) < 0) { } close(fd); } closedir(dir); } else { } while (waitpid(-1, status, __WALL) != pid) { } } static void setup_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); write_file("/proc/self/oom_score_adj", "1000"); } static void close_fds() { for (int fd = 3; fd < MAX_FDS; fd++) close(fd); } static const char* setup_usb() { if (chmod("/dev/raw-gadget", 0666)) return "failed to chmod /dev/raw-gadget"; return NULL; } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { int iter = 0; for (;; iter++) { int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { setup_test(); execute_one(); close_fds(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } } } uint64_t r[2] = {0x0, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // bpf$MAP_CREATE arguments: [ // cmd: const = 0x0 (8 bytes) // arg: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {} (length 0x0) // } // } // } // size: len = 0x50 (8 bytes) // ] // returns fd_bpf_map syscall(__NR_bpf, /*cmd=*/0ul, /*arg=*/0x2000000009c0ul, /*size=*/0x50ul); // bpf$PROG_LOAD arguments: [ // cmd: const = 0x5 (8 bytes) // arg: ptr[in, bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], fd_bpf_prog[opt]]] { // bpf_prog_t[flags[bpf_prog_type, int32], bpf_prog_attach_types, // bpf_btf_id[opt], fd_bpf_prog[opt]] { // type: bpf_prog_type = 0x0 (4 bytes) // ninsn: bytesize8 = 0xc (4 bytes) // insns: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // } // } // license: nil // loglev: int32 = 0x0 (4 bytes) // logsize: len = 0x0 (4 bytes) // log: nil // kern_version: bpf_kern_version = 0x0 (4 bytes) // flags: bpf_prog_load_flags = 0x0 (4 bytes) // prog_name: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} // (length 0x10) prog_ifindex: ifindex (resource) expected_attach_type: // union bpf_prog_attach_types { // fallback: bpf_attach_types = 0x31 (4 bytes) // } // btf_fd: fd_btf (resource) // func_info_rec_size: const = 0x0 (4 bytes) // func_info: nil // func_info_cnt: len = 0x0 (4 bytes) // line_info_rec_size: const = 0x0 (4 bytes) // line_info: nil // line_info_cnt: len = 0x0 (4 bytes) // attach_btf_id: bpf_btf_id (resource) // attach_prog_fd: fd_bpf_prog (resource) // core_relo_cnt: len = 0x45 (4 bytes) // fd_array: nil // core_relos: nil // core_relo_rec_size: const = 0x0 (4 bytes) // log_true_size: int32 = 0x0 (4 bytes) // prog_token_fd: union _bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], // fd_bpf_prog[opt]]_prog_token_fd_wrapper { // void: buffer: {} (length 0x0) // } // pad: union _bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], // fd_bpf_prog[opt]]_pad_wrapper { // value: const = 0x0 (4 bytes) // } // } // } // size: len = 0x94 (8 bytes) // ] // returns fd_bpf_prog NONFAILING(*(uint32_t*)0x200000000380 = 0); NONFAILING(*(uint32_t*)0x200000000384 = 0xc); NONFAILING(*(uint64_t*)0x200000000388 = 0x200000000540); NONFAILING(*(uint64_t*)0x200000000390 = 0); NONFAILING(*(uint32_t*)0x200000000398 = 0); NONFAILING(*(uint32_t*)0x20000000039c = 0); NONFAILING(*(uint64_t*)0x2000000003a0 = 0); NONFAILING(*(uint32_t*)0x2000000003a8 = 0); NONFAILING(*(uint32_t*)0x2000000003ac = 0); NONFAILING(memset((void*)0x2000000003b0, 0, 16)); NONFAILING(*(uint32_t*)0x2000000003c0 = 0); NONFAILING(*(uint32_t*)0x2000000003c4 = 0x31); NONFAILING(*(uint32_t*)0x2000000003c8 = -1); NONFAILING(*(uint32_t*)0x2000000003cc = 0); NONFAILING(*(uint64_t*)0x2000000003d0 = 0); NONFAILING(*(uint32_t*)0x2000000003d8 = 0); NONFAILING(*(uint32_t*)0x2000000003dc = 0); NONFAILING(*(uint64_t*)0x2000000003e0 = 0); NONFAILING(*(uint32_t*)0x2000000003e8 = 0); NONFAILING(*(uint32_t*)0x2000000003ec = 0); NONFAILING(*(uint32_t*)0x2000000003f0 = 0); NONFAILING(*(uint32_t*)0x2000000003f4 = 0x45); NONFAILING(*(uint64_t*)0x2000000003f8 = 0); NONFAILING(*(uint64_t*)0x200000000400 = 0); NONFAILING(*(uint32_t*)0x200000000408 = 0); NONFAILING(*(uint32_t*)0x20000000040c = 0); NONFAILING(*(uint32_t*)0x200000000410 = 0); syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0x200000000380ul, /*size=*/0x94ul); // bpf$BPF_RAW_TRACEPOINT_OPEN arguments: [ // cmd: const = 0x11 (8 bytes) // arg: nil // size: len = 0x0 (8 bytes) // ] // returns fd_perf_base syscall(__NR_bpf, /*cmd=*/0x11ul, /*arg=*/0ul, /*size=*/0ul); // bpf$BPF_RAW_TRACEPOINT_OPEN arguments: [ // cmd: const = 0x11 (8 bytes) // arg: ptr[in, bpf_raw_tracepoint] { // bpf_raw_tracepoint { // name: nil // prog_fd: fd_bpf_prog_raw_tracepoint (resource) // pad: const = 0x0 (4 bytes) // cookie: int64 = 0x0 (8 bytes) // } // } // size: len = 0x18 (8 bytes) // ] // returns fd_perf_base NONFAILING(*(uint64_t*)0x200000000200 = 0); NONFAILING(*(uint32_t*)0x200000000208 = -1); NONFAILING(*(uint32_t*)0x20000000020c = 0); NONFAILING(*(uint64_t*)0x200000000210 = 0); syscall(__NR_bpf, /*cmd=*/0x11ul, /*arg=*/0x200000000200ul, /*size=*/0x18ul); // bpf$BPF_RAW_TRACEPOINT_OPEN arguments: [ // cmd: const = 0x11 (8 bytes) // arg: ptr[in, bpf_raw_tracepoint] { // bpf_raw_tracepoint { // name: ptr[in, buffer] { // buffer: {70 65 72 63 70 75 5f 66 72 65 65 5f 70 65 72 63 70 75 00} // (length 0x13) // } // prog_fd: fd_bpf_prog_raw_tracepoint (resource) // pad: const = 0x0 (4 bytes) // cookie: int64 = 0x0 (8 bytes) // } // } // size: len = 0x10 (8 bytes) // ] // returns fd_perf_base NONFAILING(*(uint64_t*)0x200000000200 = 0x200000000500); NONFAILING(memcpy((void*)0x200000000500, "percpu_free_percpu\000", 19)); NONFAILING(*(uint32_t*)0x200000000208 = -1); NONFAILING(*(uint32_t*)0x20000000020c = 0); NONFAILING(*(uint64_t*)0x200000000210 = 0); syscall(__NR_bpf, /*cmd=*/0x11ul, /*arg=*/0x200000000200ul, /*size=*/0x10ul); // bpf$MAP_CREATE arguments: [ // cmd: const = 0x2000000000000000 (8 bytes) // arg: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {06 00 00 00 04 00 00 00 ff 01 00 00 5c 00 00 20 // 00 00 00 00} (length 0x14) // } // union ANYUNION { // ANYRES32: ANYRES32 (resource) // } // union ANYUNION { // ANYBLOB: buffer: {04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00} (length 0x14) // } // union ANYUNION { // ANYRES32: ANYRES32 (resource) // } // union ANYUNION { // ANYRES32: ANYRES32 (resource) // } // union ANYUNION { // ANYBLOB: buffer: {00 00 00 00 fe ff ff ff 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x1c) // } // } // } // size: len = 0x50 (8 bytes) // ] // returns fd_bpf_map NONFAILING(memcpy((void*)0x200000000140, "\x06\x00\x00\x00\x04\x00\x00\x00\xff\x01\x00\x00\x5c\x00" "\x00\x20\x00\x00\x00\x00", 20)); NONFAILING(*(uint32_t*)0x200000000154 = -1); NONFAILING(memcpy((void*)0x200000000158, "\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00", 20)); NONFAILING(*(uint32_t*)0x20000000016c = 0); NONFAILING(*(uint32_t*)0x200000000170 = -1); NONFAILING(memcpy((void*)0x200000000174, "\x00\x00\x00\x00\xfe\xff\xff\xff\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 28)); syscall(__NR_bpf, /*cmd=*/0x2000000000000000ul, /*arg=*/0x200000000140ul, /*size=*/0x50ul); // bpf$PROG_LOAD arguments: [ // cmd: const = 0x5 (8 bytes) // arg: ptr[in, bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], fd_bpf_prog[opt]]] { // bpf_prog_t[flags[bpf_prog_type, int32], bpf_prog_attach_types, // bpf_btf_id[opt], fd_bpf_prog[opt]] { // type: bpf_prog_type = 0x0 (4 bytes) // ninsn: bytesize8 = 0xc (4 bytes) // insns: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // } // } // license: nil // loglev: int32 = 0x0 (4 bytes) // logsize: len = 0x0 (4 bytes) // log: nil // kern_version: bpf_kern_version = 0x0 (4 bytes) // flags: bpf_prog_load_flags = 0x0 (4 bytes) // prog_name: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} // (length 0x10) prog_ifindex: ifindex (resource) expected_attach_type: // union bpf_prog_attach_types { // fallback: bpf_attach_types = 0x0 (4 bytes) // } // btf_fd: fd_btf (resource) // func_info_rec_size: const = 0x0 (4 bytes) // func_info: nil // func_info_cnt: len = 0x0 (4 bytes) // line_info_rec_size: const = 0x0 (4 bytes) // line_info: nil // line_info_cnt: len = 0x0 (4 bytes) // attach_btf_id: bpf_btf_id (resource) // attach_prog_fd: fd_bpf_prog (resource) // core_relo_cnt: len = 0x0 (4 bytes) // fd_array: nil // core_relos: nil // core_relo_rec_size: const = 0x0 (4 bytes) // log_true_size: int32 = 0x0 (4 bytes) // prog_token_fd: union _bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], // fd_bpf_prog[opt]]_prog_token_fd_wrapper { // void: buffer: {} (length 0x0) // } // pad: union _bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], // fd_bpf_prog[opt]]_pad_wrapper { // value: const = 0x0 (4 bytes) // } // } // } // size: len = 0x94 (8 bytes) // ] // returns fd_bpf_prog NONFAILING(*(uint32_t*)0x2000000000c0 = 0); NONFAILING(*(uint32_t*)0x2000000000c4 = 0xc); NONFAILING(*(uint64_t*)0x2000000000c8 = 0x200000000440); NONFAILING(*(uint64_t*)0x2000000000d0 = 0); NONFAILING(*(uint32_t*)0x2000000000d8 = 0); NONFAILING(*(uint32_t*)0x2000000000dc = 0); NONFAILING(*(uint64_t*)0x2000000000e0 = 0); NONFAILING(*(uint32_t*)0x2000000000e8 = 0); NONFAILING(*(uint32_t*)0x2000000000ec = 0); NONFAILING(memset((void*)0x2000000000f0, 0, 16)); NONFAILING(*(uint32_t*)0x200000000100 = 0); NONFAILING(*(uint32_t*)0x200000000104 = 0); NONFAILING(*(uint32_t*)0x200000000108 = -1); NONFAILING(*(uint32_t*)0x20000000010c = 0); NONFAILING(*(uint64_t*)0x200000000110 = 0); NONFAILING(*(uint32_t*)0x200000000118 = 0); NONFAILING(*(uint32_t*)0x20000000011c = 0); NONFAILING(*(uint64_t*)0x200000000120 = 0); NONFAILING(*(uint32_t*)0x200000000128 = 0); NONFAILING(*(uint32_t*)0x20000000012c = 0); NONFAILING(*(uint32_t*)0x200000000130 = 0); NONFAILING(*(uint32_t*)0x200000000134 = 0); NONFAILING(*(uint64_t*)0x200000000138 = 0); NONFAILING(*(uint64_t*)0x200000000140 = 0); NONFAILING(*(uint32_t*)0x200000000148 = 0); NONFAILING(*(uint32_t*)0x20000000014c = 0); NONFAILING(*(uint32_t*)0x200000000150 = 0); syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0x2000000000c0ul, /*size=*/0x94ul); // bpf$MAP_CREATE arguments: [ // cmd: const = 0x0 (8 bytes) // arg: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {} (length 0x0) // } // union ANYUNION { // ANYRES32: ANYRES32 (resource) // } // union ANYUNION { // ANYBLOB: buffer: {00 00 00 00 00 00 04 00 00 00 de ff ff ff ff ff // ff ff 00 00} (length 0x14) // } // union ANYUNION { // ANYRES32: ANYRES32 (resource) // } // union ANYUNION { // ANYRES32: ANYRES32 (resource) // } // union ANYUNION { // ANYBLOB: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00} (length 0x1c) // } // } // } // size: len = 0x48 (8 bytes) // ] // returns fd_bpf_map NONFAILING(*(uint32_t*)0x2000000000c0 = -1); NONFAILING(memcpy((void*)0x2000000000c4, "\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\xde\xff\xff\xff" "\xff\xff\xff\xff\x00\x00", 20)); NONFAILING(*(uint32_t*)0x2000000000d8 = 0); NONFAILING(*(uint32_t*)0x2000000000dc = -1); NONFAILING(memset((void*)0x2000000000e0, 0, 28)); syscall(__NR_bpf, /*cmd=*/0ul, /*arg=*/0x2000000000c0ul, /*size=*/0x48ul); // bpf$PROG_LOAD arguments: [ // cmd: const = 0x5 (8 bytes) // arg: ptr[in, bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], fd_bpf_prog[opt]]] { // bpf_prog_t[flags[bpf_prog_type, int32], bpf_prog_attach_types, // bpf_btf_id[opt], fd_bpf_prog[opt]] { // type: bpf_prog_type = 0x0 (4 bytes) // ninsn: bytesize8 = 0xc (4 bytes) // insns: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // } // } // license: nil // loglev: int32 = 0x0 (4 bytes) // logsize: len = 0x0 (4 bytes) // log: nil // kern_version: bpf_kern_version = 0x0 (4 bytes) // flags: bpf_prog_load_flags = 0x39 (4 bytes) // prog_name: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} // (length 0x10) prog_ifindex: ifindex (resource) expected_attach_type: // union bpf_prog_attach_types { // fallback: bpf_attach_types = 0x2c (4 bytes) // } // btf_fd: fd_btf (resource) // func_info_rec_size: const = 0x0 (4 bytes) // func_info: nil // func_info_cnt: len = 0x56 (4 bytes) // line_info_rec_size: const = 0x0 (4 bytes) // line_info: nil // line_info_cnt: len = 0x0 (4 bytes) // attach_btf_id: bpf_btf_id (resource) // attach_prog_fd: fd_bpf_prog (resource) // core_relo_cnt: len = 0x0 (4 bytes) // fd_array: nil // core_relos: nil // core_relo_rec_size: const = 0x0 (4 bytes) // log_true_size: int32 = 0x0 (4 bytes) // prog_token_fd: union _bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], // fd_bpf_prog[opt]]_prog_token_fd_wrapper { // void: buffer: {} (length 0x0) // } // pad: union _bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], // fd_bpf_prog[opt]]_pad_wrapper { // value: const = 0x0 (4 bytes) // } // } // } // size: len = 0x94 (8 bytes) // ] // returns fd_bpf_prog NONFAILING(*(uint32_t*)0x200000000200 = 0); NONFAILING(*(uint32_t*)0x200000000204 = 0xc); NONFAILING(*(uint64_t*)0x200000000208 = 0x200000000440); NONFAILING(*(uint64_t*)0x200000000210 = 0); NONFAILING(*(uint32_t*)0x200000000218 = 0); NONFAILING(*(uint32_t*)0x20000000021c = 0); NONFAILING(*(uint64_t*)0x200000000220 = 0); NONFAILING(*(uint32_t*)0x200000000228 = 0); NONFAILING(*(uint32_t*)0x20000000022c = 0x39); NONFAILING(memset((void*)0x200000000230, 0, 16)); NONFAILING(*(uint32_t*)0x200000000240 = 0); NONFAILING(*(uint32_t*)0x200000000244 = 0x2c); NONFAILING(*(uint32_t*)0x200000000248 = -1); NONFAILING(*(uint32_t*)0x20000000024c = 0); NONFAILING(*(uint64_t*)0x200000000250 = 0); NONFAILING(*(uint32_t*)0x200000000258 = 0x56); NONFAILING(*(uint32_t*)0x20000000025c = 0); NONFAILING(*(uint64_t*)0x200000000260 = 0); NONFAILING(*(uint32_t*)0x200000000268 = 0); NONFAILING(*(uint32_t*)0x20000000026c = 0); NONFAILING(*(uint32_t*)0x200000000270 = -1); NONFAILING(*(uint32_t*)0x200000000274 = 0); NONFAILING(*(uint64_t*)0x200000000278 = 0); NONFAILING(*(uint64_t*)0x200000000280 = 0); NONFAILING(*(uint32_t*)0x200000000288 = 0); NONFAILING(*(uint32_t*)0x20000000028c = 0); NONFAILING(*(uint32_t*)0x200000000290 = 0); syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0x200000000200ul, /*size=*/0x94ul); // bpf$MAP_GET_NEXT_KEY arguments: [ // cmd: const = 0x2 (8 bytes) // arg: ptr[in, bpf_map_get_next_arg] { // bpf_map_get_next_arg { // map: fd_bpf_map (resource) // pad = 0x0 (4 bytes) // key: ptr[in, buffer] { // buffer: {} (length 0x0) // } // next: ptr[out, buffer] { // buffer: (DirOut) // } // flags: const = 0x0 (8 bytes) // } // } // size: len = 0x20 (8 bytes) // ] NONFAILING(*(uint32_t*)0x200000000080 = -1); NONFAILING(*(uint64_t*)0x200000000088 = 0x200000000080); NONFAILING(*(uint64_t*)0x200000000090 = 0x200000000880); NONFAILING(*(uint64_t*)0x200000000098 = 0); syscall(__NR_bpf, /*cmd=*/2ul, /*arg=*/0x200000000080ul, /*size=*/0x20ul); // ioctl$sock_ipv6_tunnel_SIOCGET6RD arguments: [ // fd: sock_udp (resource) // cmd: const = 0x89f8 (4 bytes) // arg: ptr[inout, ifreq_dev_t[ipv4_tunnel_names, ptr[inout, // ip_tunnel_parm]]] { // ifreq_dev_t[ipv4_tunnel_names, ptr[inout, ip_tunnel_parm]] { // ifr_ifrn: buffer: {67 72 65 74 61 70 30 00 00 00 00 00 00 00 00 00} // (length 0x10) elem: ptr[inout, ip_tunnel_parm] { // ip_tunnel_parm { // name: buffer: {73 79 7a 74 6e 6c 31 00 00 00 00 00 00 00 00 00} // (length 0x10) link: ifindex (resource) i_flags: // ip_tunnel_io_flags = 0x7 (2 bytes) o_flags: ip_tunnel_io_flags = // 0x89 (2 bytes) i_key: int32be = 0x7fff (4 bytes) o_key: int32be // = 0xfffffff6 (4 bytes) iph: // ipv4_packet_t[flags[ip_tunnel_protocols, int8], void] { // header: ipv4_header[flags[ip_tunnel_protocols, int8]] { // ihl: bytesize4 = 0x5 (0 bytes) // version: const = 0x4 (1 bytes) // ecn: int8 = 0x0 (0 bytes) // dscp: int8 = 0x2 (1 bytes) // total_len: len = 0x14 (2 bytes) // id: int16be = 0x65 (2 bytes) // frag_off: int16be = 0x0 (2 bytes) // ttl: int8 = 0xc9 (1 bytes) // protocol: ip_tunnel_protocols = 0x21 (1 bytes) // csum: csum = 0x0 (2 bytes) // src_ip: union ipv4_addr { // remote: ipv4_addr_t[const[187, int8]] { // a0: const = 0xac (1 bytes) // a1: const = 0x14 (1 bytes) // a2: const = 0x14 (1 bytes) // a3: const = 0xbb (1 bytes) // } // } // dst_ip: union ipv4_addr { // initdev: ipv4_addr_initdev { // a0: const = 0xac (1 bytes) // a1: const = 0x1e (1 bytes) // a2: int8 = 0x0 (1 bytes) // a3: proc = 0x0 (1 bytes) // } // } // options: ipv4_options { // options: array[ipv4_option] { // } // } // } // payload: buffer: {} (length 0x0) // } // } // } // pad = 0x0 (16 bytes) // } // } // ] NONFAILING(memcpy((void*)0x2000000002c0, "gretap0\000\000\000\000\000\000\000\000\000", 16)); NONFAILING(*(uint64_t*)0x2000000002d0 = 0x200000000600); NONFAILING(memcpy((void*)0x200000000600, "syztnl1\000\000\000\000\000\000\000\000\000", 16)); NONFAILING(*(uint32_t*)0x200000000610 = 0); NONFAILING(*(uint16_t*)0x200000000614 = htobe16(7)); NONFAILING(*(uint16_t*)0x200000000616 = htobe16(0x89)); NONFAILING(*(uint32_t*)0x200000000618 = htobe32(0x7fff)); NONFAILING(*(uint32_t*)0x20000000061c = htobe32(0xfffffff6)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x200000000620, 5, 0, 4)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x200000000620, 4, 4, 4)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x200000000621, 0, 0, 2)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x200000000621, 2, 2, 6)); NONFAILING(*(uint16_t*)0x200000000622 = htobe16(0x14)); NONFAILING(*(uint16_t*)0x200000000624 = htobe16(0x65)); NONFAILING(*(uint16_t*)0x200000000626 = htobe16(0)); NONFAILING(*(uint8_t*)0x200000000628 = 0xc9); NONFAILING(*(uint8_t*)0x200000000629 = 0x21); NONFAILING(*(uint16_t*)0x20000000062a = htobe16(0)); NONFAILING(*(uint8_t*)0x20000000062c = 0xac); NONFAILING(*(uint8_t*)0x20000000062d = 0x14); NONFAILING(*(uint8_t*)0x20000000062e = 0x14); NONFAILING(*(uint8_t*)0x20000000062f = 0xbb); NONFAILING(*(uint8_t*)0x200000000630 = 0xac); NONFAILING(*(uint8_t*)0x200000000631 = 0x1e); NONFAILING(*(uint8_t*)0x200000000632 = 0); NONFAILING(*(uint8_t*)0x200000000633 = 1); struct csum_inet csum_1; csum_inet_init(&csum_1); NONFAILING(csum_inet_update(&csum_1, (const uint8_t*)0x200000000620, 20)); NONFAILING(*(uint16_t*)0x20000000062a = csum_inet_digest(&csum_1)); res = syscall(__NR_ioctl, /*fd=*/(intptr_t)-1, /*cmd=*/0x89f8, /*arg=*/0x2000000002c0ul); if (res != -1) NONFAILING(r[0] = *(uint32_t*)0x200000000610); // bpf$PROG_LOAD arguments: [ // cmd: const = 0x5 (8 bytes) // arg: ptr[in, bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], fd_bpf_prog[opt]]] { // bpf_prog_t[flags[bpf_prog_type, int32], bpf_prog_attach_types, // bpf_btf_id[opt], fd_bpf_prog[opt]] { // type: bpf_prog_type = 0x11 (4 bytes) // ninsn: bytesize8 = 0xc (4 bytes) // insns: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // } // } // license: nil // loglev: int32 = 0x0 (4 bytes) // logsize: len = 0x0 (4 bytes) // log: nil // kern_version: bpf_kern_version = 0x0 (4 bytes) // flags: bpf_prog_load_flags = 0x0 (4 bytes) // prog_name: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} // (length 0x10) prog_ifindex: ifindex (resource) expected_attach_type: // union bpf_prog_attach_types { // fallback: bpf_attach_types = 0x3e (4 bytes) // } // btf_fd: fd_btf (resource) // func_info_rec_size: const = 0x0 (4 bytes) // func_info: nil // func_info_cnt: len = 0x0 (4 bytes) // line_info_rec_size: const = 0x0 (4 bytes) // line_info: nil // line_info_cnt: len = 0x0 (4 bytes) // attach_btf_id: bpf_btf_id (resource) // attach_prog_fd: fd_bpf_prog (resource) // core_relo_cnt: len = 0x0 (4 bytes) // fd_array: nil // core_relos: nil // core_relo_rec_size: const = 0x0 (4 bytes) // log_true_size: int32 = 0x0 (4 bytes) // prog_token_fd: union _bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], // fd_bpf_prog[opt]]_prog_token_fd_wrapper { // void: buffer: {} (length 0x0) // } // pad: union _bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], // fd_bpf_prog[opt]]_pad_wrapper { // value: const = 0x0 (4 bytes) // } // } // } // size: len = 0x94 (8 bytes) // ] // returns fd_bpf_prog NONFAILING(*(uint32_t*)0x2000000000c0 = 0x11); NONFAILING(*(uint32_t*)0x2000000000c4 = 0xc); NONFAILING(*(uint64_t*)0x2000000000c8 = 0x200000000440); NONFAILING(*(uint64_t*)0x2000000000d0 = 0); NONFAILING(*(uint32_t*)0x2000000000d8 = 0); NONFAILING(*(uint32_t*)0x2000000000dc = 0); NONFAILING(*(uint64_t*)0x2000000000e0 = 0); NONFAILING(*(uint32_t*)0x2000000000e8 = 0); NONFAILING(*(uint32_t*)0x2000000000ec = 0); NONFAILING(memset((void*)0x2000000000f0, 0, 16)); NONFAILING(*(uint32_t*)0x200000000100 = r[0]); NONFAILING(*(uint32_t*)0x200000000104 = 0x3e); NONFAILING(*(uint32_t*)0x200000000108 = -1); NONFAILING(*(uint32_t*)0x20000000010c = 0); NONFAILING(*(uint64_t*)0x200000000110 = 0); NONFAILING(*(uint32_t*)0x200000000118 = 0); NONFAILING(*(uint32_t*)0x20000000011c = 0); NONFAILING(*(uint64_t*)0x200000000120 = 0); NONFAILING(*(uint32_t*)0x200000000128 = 0); NONFAILING(*(uint32_t*)0x20000000012c = 0); NONFAILING(*(uint32_t*)0x200000000130 = 0); NONFAILING(*(uint32_t*)0x200000000134 = 0); NONFAILING(*(uint64_t*)0x200000000138 = 0); NONFAILING(*(uint64_t*)0x200000000140 = 0); NONFAILING(*(uint32_t*)0x200000000148 = 0); NONFAILING(*(uint32_t*)0x20000000014c = 0); NONFAILING(*(uint32_t*)0x200000000150 = 0); res = syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0x2000000000c0ul, /*size=*/0x94ul); if (res != -1) r[1] = res; // mlock arguments: [ // addr: VMA[0x1000] // size: len = 0x1000 (8 bytes) // ] syscall(__NR_mlock, /*addr=*/0x200000ffe000ul, /*size=*/0x1000ul); // mlock arguments: [ // addr: VMA[0x1000] // size: len = 0x1000 (8 bytes) // ] syscall(__NR_mlock, /*addr=*/0x200000ffe000ul, /*size=*/0x1000ul); // bpf$BPF_RAW_TRACEPOINT_OPEN arguments: [ // cmd: const = 0x11 (8 bytes) // arg: ptr[in, bpf_raw_tracepoint] { // bpf_raw_tracepoint { // name: ptr[in, buffer] { // buffer: {73 63 68 65 64 5f 73 77 69 74 63 68 00} (length 0xd) // } // prog_fd: fd_bpf_prog_raw_tracepoint (resource) // pad: const = 0x0 (4 bytes) // cookie: int64 = 0x0 (8 bytes) // } // } // size: len = 0x10 (8 bytes) // ] // returns fd_perf_base NONFAILING(*(uint64_t*)0x200000000740 = 0x200000000300); NONFAILING(memcpy((void*)0x200000000300, "sched_switch\000", 13)); NONFAILING(*(uint32_t*)0x200000000748 = r[1]); NONFAILING(*(uint32_t*)0x20000000074c = 0); NONFAILING(*(uint64_t*)0x200000000750 = 0); syscall(__NR_bpf, /*cmd=*/0x11ul, /*arg=*/0x200000000740ul, /*size=*/0x10ul); } 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); const char* reason; (void)reason; if ((reason = setup_usb())) printf("the reproducer may not work as expected: USB injection setup " "failed: %s\n", reason); install_segv_handler(); do_sandbox_none(); return 0; }