// https://syzkaller.appspot.com/bug?id=5ce19e72127687f9d5436c01755276fae6913494 // 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 #include #ifndef __NR_bpf #define __NR_bpf 321 #endif #ifndef __NR_fsconfig #define __NR_fsconfig 431 #endif #ifndef __NR_fsmount #define __NR_fsmount 432 #endif #ifndef __NR_fsopen #define __NR_fsopen 430 #endif static unsigned long long procid; 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; } 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; } #define MAX_FDS 30 static void mount_cgroups(const char* dir, const char** controllers, int count) { if (mkdir(dir, 0777)) { return; } char enabled[128] = {0}; int i = 0; for (; i < count; i++) { if (mount("none", dir, "cgroup", 0, controllers[i])) { continue; } umount(dir); strcat(enabled, ","); strcat(enabled, controllers[i]); } if (enabled[0] == 0) { if (rmdir(dir) && errno != EBUSY) exit(1); return; } if (mount("none", dir, "cgroup", 0, enabled + 1)) { if (rmdir(dir) && errno != EBUSY) exit(1); } if (chmod(dir, 0777)) { } } static void mount_cgroups2(const char** controllers, int count) { if (mkdir("/syzcgroup/unified", 0777)) { return; } if (mount("none", "/syzcgroup/unified", "cgroup2", 0, NULL)) { if (rmdir("/syzcgroup/unified") && errno != EBUSY) exit(1); return; } if (chmod("/syzcgroup/unified", 0777)) { } int control = open("/syzcgroup/unified/cgroup.subtree_control", O_WRONLY); if (control == -1) return; int i; for (i = 0; i < count; i++) if (write(control, controllers[i], strlen(controllers[i])) < 0) { } close(control); } static void setup_cgroups() { const char* unified_controllers[] = {"+cpu", "+io", "+pids"}; const char* net_controllers[] = {"net", "net_prio", "devices", "blkio", "freezer"}; const char* cpu_controllers[] = {"cpuset", "cpuacct", "hugetlb", "rlimit", "memory"}; if (mkdir("/syzcgroup", 0777)) { return; } mount_cgroups2(unified_controllers, sizeof(unified_controllers) / sizeof(unified_controllers[0])); mount_cgroups("/syzcgroup/net", net_controllers, sizeof(net_controllers) / sizeof(net_controllers[0])); mount_cgroups("/syzcgroup/cpu", cpu_controllers, sizeof(cpu_controllers) / sizeof(cpu_controllers[0])); write_file("/syzcgroup/cpu/cgroup.clone_children", "1"); write_file("/syzcgroup/cpu/cpuset.memory_pressure_enabled", "1"); } static void setup_cgroups_loop() { int pid = getpid(); char file[128]; char cgroupdir[64]; snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/unified/syz%llu", procid); if (mkdir(cgroupdir, 0777)) { } snprintf(file, sizeof(file), "%s/pids.max", cgroupdir); write_file(file, "32"); snprintf(file, sizeof(file), "%s/cgroup.procs", cgroupdir); write_file(file, "%d", pid); snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/cpu/syz%llu", procid); if (mkdir(cgroupdir, 0777)) { } snprintf(file, sizeof(file), "%s/cgroup.procs", cgroupdir); write_file(file, "%d", pid); snprintf(file, sizeof(file), "%s/memory.soft_limit_in_bytes", cgroupdir); write_file(file, "%d", 299 << 20); snprintf(file, sizeof(file), "%s/memory.limit_in_bytes", cgroupdir); write_file(file, "%d", 300 << 20); snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/net/syz%llu", procid); if (mkdir(cgroupdir, 0777)) { } snprintf(file, sizeof(file), "%s/cgroup.procs", cgroupdir); write_file(file, "%d", pid); } static void setup_cgroups_test() { char cgroupdir[64]; snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/unified/syz%llu", procid); if (symlink(cgroupdir, "./cgroup")) { } snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/cpu/syz%llu", procid); if (symlink(cgroupdir, "./cgroup.cpu")) { } snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/net/syz%llu", procid); if (symlink(cgroupdir, "./cgroup.net")) { } } static void initialize_cgroups() { if (mkdir("./syz-tmp/newroot/syzcgroup", 0700)) exit(1); if (mkdir("./syz-tmp/newroot/syzcgroup/unified", 0700)) exit(1); if (mkdir("./syz-tmp/newroot/syzcgroup/cpu", 0700)) exit(1); if (mkdir("./syz-tmp/newroot/syzcgroup/net", 0700)) exit(1); unsigned bind_mount_flags = MS_BIND | MS_REC | MS_PRIVATE; if (mount("/syzcgroup/unified", "./syz-tmp/newroot/syzcgroup/unified", NULL, bind_mount_flags, NULL)) { } if (mount("/syzcgroup/cpu", "./syz-tmp/newroot/syzcgroup/cpu", NULL, bind_mount_flags, NULL)) { } if (mount("/syzcgroup/net", "./syz-tmp/newroot/syzcgroup/net", NULL, bind_mount_flags, NULL)) { } } 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); initialize_cgroups(); 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)) { } } 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); } #define FS_IOC_SETFLAGS _IOW('f', 2, long) static void remove_dir(const char* dir) { int iter = 0; DIR* dp = 0; const int umount_flags = MNT_FORCE | UMOUNT_NOFOLLOW; retry: while (umount2(dir, umount_flags) == 0) { } dp = opendir(dir); if (dp == NULL) { if (errno == EMFILE) { exit(1); } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); while (umount2(filename, umount_flags) == 0) { } struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } int i; for (i = 0;; i++) { if (unlink(filename) == 0) break; if (errno == EPERM) { int fd = open(filename, O_RDONLY); if (fd != -1) { long flags = 0; if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) { } close(fd); continue; } } if (errno == EROFS) { break; } if (errno != EBUSY || i > 100) exit(1); if (umount2(filename, umount_flags)) exit(1); } } closedir(dp); for (int i = 0;; i++) { if (rmdir(dir) == 0) break; if (i < 100) { if (errno == EPERM) { int fd = open(dir, O_RDONLY); if (fd != -1) { long flags = 0; if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) { } close(fd); continue; } } if (errno == EROFS) { break; } if (errno == EBUSY) { if (umount2(dir, umount_flags)) exit(1); continue; } if (errno == ENOTEMPTY) { if (iter < 100) { iter++; goto retry; } } } 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_loop() { setup_cgroups_loop(); } static void setup_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); setup_cgroups_test(); write_file("/proc/self/oom_score_adj", "1000"); if (symlink("/dev/binderfs", "./binderfs")) { } } static void close_fds() { for (int fd = 3; fd < MAX_FDS; fd++) close(fd); } static const char* setup_binfmt_misc() { if (mount(0, "/proc/sys/fs/binfmt_misc", "binfmt_misc", 0, 0) && errno != EBUSY) { return NULL; } if (!write_file("/proc/sys/fs/binfmt_misc/register", ":syz0:M:0:\x01::./file0:") || !write_file("/proc/sys/fs/binfmt_misc/register", ":syz1:M:1:\x02::./file0:POC")) return "write(/proc/sys/fs/binfmt_misc/register) failed"; return NULL; } 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) ; } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { setup_loop(); int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); 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; } remove_dir(cwdbuf); } } uint64_t r[5] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // socket$packet arguments: [ // domain: const = 0x11 (8 bytes) // type: packet_socket_type = 0x2 (8 bytes) // proto: const = 0x300 (4 bytes) // ] // returns sock_packet syscall(__NR_socket, /*domain=*/0x11ul, /*type=SOCK_DGRAM*/ 2ul, /*proto=*/0x300); // bpf$MAP_CREATE arguments: [ // cmd: const = 0x0 (8 bytes) // arg: ptr[in, bpf_map_create_arg] { // union bpf_map_create_arg { // base: bpf_map_create_arg_t[flags[bpf_map_type, int32], int32, int32, // int32, flags[map_flags, int32], const[0, int64]] { // type: bpf_map_type = 0xf (4 bytes) // ksize: int32 = 0x4 (4 bytes) // vsize: int32 = 0x8 (4 bytes) // max: int32 = 0x8 (4 bytes) // flags: map_flags = 0x0 (4 bytes) // inner: fd_bpf_map (resource) // node: int32 = 0x2 (4 bytes) // map_name: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00} (length 0x10) map_ifindex: ifindex (resource) btf_fd: fd_btf // (resource) btf_key_type_id: int32 = 0x0 (4 bytes) // btf_value_type_id: int32 = 0x0 (4 bytes) // btf_vmlinux_type_id: int32 = 0x0 (4 bytes) // map_extra: const = 0x0 (8 bytes) // value_type_btf_obj_fd: union // _bpf_map_create_arg_t[flags[bpf_map_type, int32], int32, int32, // int32, flags[map_flags, int32], const[0, // int64]]_value_type_btf_obj_fd_wrapper { // void: buffer: {} (length 0x0) // } // pad1: union _bpf_map_create_arg_t[flags[bpf_map_type, int32], // int32, int32, int32, flags[map_flags, int32], const[0, // int64]]_pad1_wrapper { // value: const = 0x0 (4 bytes) // } // map_token_fd: union _bpf_map_create_arg_t[flags[bpf_map_type, // int32], int32, int32, int32, flags[map_flags, int32], const[0, // int64]]_map_token_fd_wrapper { // void: buffer: {} (length 0x0) // } // pad2: union _bpf_map_create_arg_t[flags[bpf_map_type, int32], // int32, int32, int32, flags[map_flags, int32], const[0, // int64]]_pad2_wrapper { // value: const = 0x0 (4 bytes) // } // } // } // } // size: len = 0x50 (8 bytes) // ] // returns fd_bpf_map NONFAILING(*(uint32_t*)0x2000000009c0 = 0xf); NONFAILING(*(uint32_t*)0x2000000009c4 = 4); NONFAILING(*(uint32_t*)0x2000000009c8 = 8); NONFAILING(*(uint32_t*)0x2000000009cc = 8); NONFAILING(*(uint32_t*)0x2000000009d0 = 0); NONFAILING(*(uint32_t*)0x2000000009d4 = -1); NONFAILING(*(uint32_t*)0x2000000009d8 = 2); NONFAILING(memset((void*)0x2000000009dc, 0, 16)); NONFAILING(*(uint32_t*)0x2000000009ec = 0); NONFAILING(*(uint32_t*)0x2000000009f0 = -1); NONFAILING(*(uint32_t*)0x2000000009f4 = 0); NONFAILING(*(uint32_t*)0x2000000009f8 = 0); NONFAILING(*(uint32_t*)0x2000000009fc = 0); NONFAILING(*(uint64_t*)0x200000000a00 = 0); NONFAILING(*(uint32_t*)0x200000000a08 = 0); NONFAILING(*(uint32_t*)0x200000000a0c = 0); syscall(__NR_bpf, /*cmd=*/0ul, /*arg=*/0x2000000009c0ul, /*size=*/0x50ul); // socket$inet6 arguments: [ // domain: const = 0xa (8 bytes) // type: socket_type = 0x800000000000002 (8 bytes) // proto: int32 = 0x0 (4 bytes) // ] // returns sock_in6 syscall(__NR_socket, /*domain=*/0xaul, /*type=SOCK_DGRAM|0x800000000000000*/ 0x800000000000002ul, /*proto=*/0); // bpf$MAP_CREATE arguments: [ // cmd: const = 0x0 (8 bytes) // arg: ptr[in, bpf_map_create_arg] { // union bpf_map_create_arg { // base: bpf_map_create_arg_t[flags[bpf_map_type, int32], int32, int32, // int32, flags[map_flags, int32], const[0, int64]] { // type: bpf_map_type = 0x13 (4 bytes) // ksize: int32 = 0x10 (4 bytes) // vsize: int32 = 0x8dae (4 bytes) // max: int32 = 0x0 (4 bytes) // flags: map_flags = 0x100 (4 bytes) // inner: fd_bpf_map (resource) // node: int32 = 0x0 (4 bytes) // map_name: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00} (length 0x10) map_ifindex: ifindex (resource) btf_fd: fd_btf // (resource) btf_key_type_id: int32 = 0x0 (4 bytes) // btf_value_type_id: int32 = 0x0 (4 bytes) // btf_vmlinux_type_id: int32 = 0x0 (4 bytes) // map_extra: const = 0x0 (8 bytes) // value_type_btf_obj_fd: union // _bpf_map_create_arg_t[flags[bpf_map_type, int32], int32, int32, // int32, flags[map_flags, int32], const[0, // int64]]_value_type_btf_obj_fd_wrapper { // void: buffer: {} (length 0x0) // } // pad1: union _bpf_map_create_arg_t[flags[bpf_map_type, int32], // int32, int32, int32, flags[map_flags, int32], const[0, // int64]]_pad1_wrapper { // value: const = 0x0 (4 bytes) // } // map_token_fd: union _bpf_map_create_arg_t[flags[bpf_map_type, // int32], int32, int32, int32, flags[map_flags, int32], const[0, // int64]]_map_token_fd_wrapper { // void: buffer: {} (length 0x0) // } // pad2: union _bpf_map_create_arg_t[flags[bpf_map_type, int32], // int32, int32, int32, flags[map_flags, int32], const[0, // int64]]_pad2_wrapper { // value: const = 0x0 (4 bytes) // } // } // } // } // size: len = 0x50 (8 bytes) // ] // returns fd_bpf_map NONFAILING(*(uint32_t*)0x200000000100 = 0x13); NONFAILING(*(uint32_t*)0x200000000104 = 0x10); NONFAILING(*(uint32_t*)0x200000000108 = 0x8dae); NONFAILING(*(uint32_t*)0x20000000010c = 0); NONFAILING(*(uint32_t*)0x200000000110 = 0x100); NONFAILING(*(uint32_t*)0x200000000114 = -1); NONFAILING(*(uint32_t*)0x200000000118 = 0); NONFAILING(memset((void*)0x20000000011c, 0, 16)); NONFAILING(*(uint32_t*)0x20000000012c = 0); NONFAILING(*(uint32_t*)0x200000000130 = -1); NONFAILING(*(uint32_t*)0x200000000134 = 0); NONFAILING(*(uint32_t*)0x200000000138 = 0); NONFAILING(*(uint32_t*)0x20000000013c = 0); NONFAILING(*(uint64_t*)0x200000000140 = 0); NONFAILING(*(uint32_t*)0x200000000148 = 0); NONFAILING(*(uint32_t*)0x20000000014c = 0); res = syscall(__NR_bpf, /*cmd=*/0ul, /*arg=*/0x200000000100ul, /*size=*/0x50ul); if (res != -1) r[0] = res; // bpf$BPF_PROG_RAW_TRACEPOINT_LOAD arguments: [ // cmd: const = 0x5 (8 bytes) // arg: ptr[in, bpf_prog_t[flags[bpf_raw_tracepoint_prog_types, int32], // const[0, int32], const[0, int32], const[0, int32]]] { // bpf_prog_t[flags[bpf_raw_tracepoint_prog_types, int32], const[0, // int32], const[0, int32], const[0, int32]] { // type: bpf_raw_tracepoint_prog_types = 0x8 (4 bytes) // ninsn: bytesize8 = 0xf (4 bytes) // insns: ptr[in, bpf_instructions] { // union bpf_instructions { // ringbuf: bpf_program_ringbuf { // initr0: bpf_insn_init_r0 { // code: const = 0x18 (1 bytes) // dst: const = 0x0 (0 bytes) // src: const = 0x0 (1 bytes) // off: const = 0x0 (2 bytes) // imm: int32 = 0x0 (4 bytes) // code2: const = 0x0 (1 bytes) // regs2: const = 0x0 (1 bytes) // off2: const = 0x0 (2 bytes) // imm2: int32 = 0x0 (4 bytes) // } // reserve: bpf_insn_ringbuf_reserve { // insn1: bpf_insn_map_fd_t[const[BPF_REG_1, int8:4], // ringbuf_map_fd] { // code: const = 0x18 (1 bytes) // dst: const = 0x1 (0 bytes) // src: const = 0x1 (1 bytes) // off: const = 0x0 (2 bytes) // imm: ringbuf_map_fd (resource) // code2: const = 0x0 (1 bytes) // regs2: const = 0x0 (1 bytes) // off2: const = 0x0 (2 bytes) // imm2: const = 0x0 (4 bytes) // } // insn2: bpf_insn_alu_t[BPF_ALU64, BPF_K0, BPF_MOV0, // const[BPF_REG_2, int8:4], const[0, int8:4], const[0, int16], // const[20, int32]] { // code_class: int8 = 0x7 (0 bytes) // code_s: int8 = 0x0 (0 bytes) // code_op: int8 = 0xb (1 bytes) // dst: const = 0x2 (0 bytes) // src: const = 0x0 (1 bytes) // off: const = 0x0 (2 bytes) // imm: const = 0x14 (4 bytes) // } // insn3: bpf_insn_alu_t[BPF_ALU64, BPF_K0, BPF_MOV0, // const[BPF_REG_3, int8:4], const[0, int8:4], const[0, int16], // const[0, int32]] { // code_class: int8 = 0x7 (0 bytes) // code_s: int8 = 0x0 (0 bytes) // code_op: int8 = 0xb (1 bytes) // dst: const = 0x2 (0 bytes) // src: const = 0x0 (1 bytes) // off: const = 0x0 (2 bytes) // imm: const = 0x0 (4 bytes) // } // insn4: // bpf_insn_call_helper_t[const[BPF_FUNC_ringbuf_reserve, // int32]] { // code: const = 0x85 (1 bytes) // regs: const = 0x0 (1 bytes) // off: const = 0x0 (2 bytes) // func: const = 0x51 (4 bytes) // } // insn5: bpf_insn_alu_t[BPF_ALU64, BPF_X0, BPF_MOV0, // const[BPF_REG_9, int8:4], const[BPF_REG_0, int8:4], const[0, // int16], const[0, int32]] { // code_class: int8 = 0x7 (0 bytes) // code_s: int8 = 0x1 (0 bytes) // code_op: int8 = 0xb (1 bytes) // dst: const = 0x9 (0 bytes) // src: const = 0x0 (1 bytes) // off: const = 0x0 (2 bytes) // imm: const = 0x0 (4 bytes) // } // } // null_check: bpf_insn_null_check[BPF_REG_9] { // cond_jump: bpf_insn_not_null_jmp[BPF_REG_9] { // code_class: const = 0x5 (0 bytes) // code_s: const = 0x0 (0 bytes) // code_op: const = 0x5 (1 bytes) // dst: const = 0x9 (0 bytes) // src: const = 0x0 (1 bytes) // off: const = 0x1 (2 bytes) // imm: const = 0x0 (4 bytes) // } // exit: bpf_insn_exit { // code: const = 0x95 (1 bytes) // regs: const = 0x0 (1 bytes) // off: const = 0x0 (2 bytes) // imm: const = 0x0 (4 bytes) // } // } // body: array[bpf_insn] { // } // free: bpf_insn_ringbuf_free { // insn1: bpf_insn_alu_t[BPF_ALU64, BPF_X0, BPF_MOV0, // const[BPF_REG_1, int8:4], const[BPF_REG_9, int8:4], const[0, // int16], const[0, int32]] { // code_class: int8 = 0x7 (0 bytes) // code_s: int8 = 0x1 (0 bytes) // code_op: int8 = 0xb (1 bytes) // dst: const = 0x1 (0 bytes) // src: const = 0x9 (1 bytes) // off: const = 0x0 (2 bytes) // imm: const = 0x0 (4 bytes) // } // insn2: bpf_insn_alu_t[BPF_ALU64, BPF_K0, BPF_MOV0, // const[BPF_REG_2, int8:4], const[0, int8:4], const[0, int16], // flags[bpf_ringbuf_wakeup_flags, int32]] { // code_class: int8 = 0x7 (0 bytes) // code_s: int8 = 0x0 (0 bytes) // code_op: int8 = 0xb (1 bytes) // dst: const = 0x2 (0 bytes) // src: const = 0x0 (1 bytes) // off: const = 0x0 (2 bytes) // imm: bpf_ringbuf_wakeup_flags = 0x1 (4 bytes) // } // insn3: // bpf_insn_call_helper_t[flags[bpf_helpers_ringbuf_free, // int32]] { // code: const = 0x85 (1 bytes) // regs: const = 0x0 (1 bytes) // off: const = 0x0 (2 bytes) // func: bpf_helpers_ringbuf_free = 0x5 (4 bytes) // } // insn4: bpf_insn_alu_t[BPF_ALU64, BPF_K0, BPF_MOV0, // const[BPF_REG_0, int8:4], const[0, int8:4], const[0, int16], // const[0, int32]] { // code_class: int8 = 0x7 (0 bytes) // code_s: int8 = 0x0 (0 bytes) // code_op: int8 = 0xb (1 bytes) // dst: const = 0x0 (0 bytes) // src: const = 0x0 (1 bytes) // off: const = 0x0 (2 bytes) // imm: const = 0x0 (4 bytes) // } // } // exit: bpf_insn_exit { // code: const = 0x95 (1 bytes) // regs: const = 0x0 (1 bytes) // off: const = 0x0 (2 bytes) // imm: const = 0x0 (4 bytes) // } // } // } // } // license: ptr[in, buffer] { // buffer: {73 79 7a 6b 61 6c 6c 65 72 00} (length 0xa) // } // 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: // const = 0x0 (4 bytes) btf_fd: fd_btf (resource) func_info_rec_size: // const = 0x8 (4 bytes) func_info: nil func_info_cnt: len = 0x0 (4 // bytes) line_info_rec_size: const = 0x10 (4 bytes) line_info: nil // line_info_cnt: len = 0x0 (4 bytes) // attach_btf_id: const = 0x0 (4 bytes) // attach_prog_fd: const = 0x0 (4 bytes) // core_relo_cnt: len = 0x0 (4 bytes) // fd_array: nil // core_relos: nil // core_relo_rec_size: const = 0x10 (4 bytes) // log_true_size: int32 = 0x0 (4 bytes) // prog_token_fd: union // _bpf_prog_t[flags[bpf_raw_tracepoint_prog_types, int32], const[0, // int32], const[0, int32], const[0, int32]]_prog_token_fd_wrapper { // void: buffer: {} (length 0x0) // } // pad: union _bpf_prog_t[flags[bpf_raw_tracepoint_prog_types, int32], // const[0, int32], const[0, int32], const[0, int32]]_pad_wrapper { // value: const = 0x0 (4 bytes) // } // } // } // size: len = 0x94 (8 bytes) // ] // returns fd_bpf_prog_raw_tracepoint NONFAILING(*(uint32_t*)0x200000000440 = 8); NONFAILING(*(uint32_t*)0x200000000444 = 0xf); NONFAILING(*(uint64_t*)0x200000000448 = 0x200000000580); NONFAILING(*(uint8_t*)0x200000000580 = 0x18); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x200000000581, 0, 0, 4)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x200000000581, 0, 4, 4)); NONFAILING(*(uint16_t*)0x200000000582 = 0); NONFAILING(*(uint32_t*)0x200000000584 = 0); NONFAILING(*(uint8_t*)0x200000000588 = 0); NONFAILING(*(uint8_t*)0x200000000589 = 0); NONFAILING(*(uint16_t*)0x20000000058a = 0); NONFAILING(*(uint32_t*)0x20000000058c = 0); NONFAILING(*(uint8_t*)0x200000000590 = 0x18); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x200000000591, 1, 0, 4)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x200000000591, 1, 4, 4)); NONFAILING(*(uint16_t*)0x200000000592 = 0); NONFAILING(*(uint32_t*)0x200000000594 = r[0]); NONFAILING(*(uint8_t*)0x200000000598 = 0); NONFAILING(*(uint8_t*)0x200000000599 = 0); NONFAILING(*(uint16_t*)0x20000000059a = 0); NONFAILING(*(uint32_t*)0x20000000059c = 0); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005a0, 7, 0, 3)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005a0, 0, 3, 1)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005a0, 0xb, 4, 4)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005a1, 2, 0, 4)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005a1, 0, 4, 4)); NONFAILING(*(uint16_t*)0x2000000005a2 = 0); NONFAILING(*(uint32_t*)0x2000000005a4 = 0x14); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005a8, 7, 0, 3)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005a8, 0, 3, 1)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005a8, 0xb, 4, 4)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005a9, 2, 0, 4)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005a9, 0, 4, 4)); NONFAILING(*(uint16_t*)0x2000000005aa = 0); NONFAILING(*(uint32_t*)0x2000000005ac = 0); NONFAILING(*(uint8_t*)0x2000000005b0 = 0x85); NONFAILING(*(uint8_t*)0x2000000005b1 = 0); NONFAILING(*(uint16_t*)0x2000000005b2 = 0); NONFAILING(*(uint32_t*)0x2000000005b4 = 0x51); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005b8, 7, 0, 3)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005b8, 1, 3, 1)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005b8, 0xb, 4, 4)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005b9, 9, 0, 4)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005b9, 0, 4, 4)); NONFAILING(*(uint16_t*)0x2000000005ba = 0); NONFAILING(*(uint32_t*)0x2000000005bc = 0); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005c0, 5, 0, 3)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005c0, 0, 3, 1)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005c0, 5, 4, 4)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005c1, 9, 0, 4)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005c1, 0, 4, 4)); NONFAILING(*(uint16_t*)0x2000000005c2 = 1); NONFAILING(*(uint32_t*)0x2000000005c4 = 0); NONFAILING(*(uint8_t*)0x2000000005c8 = 0x95); NONFAILING(*(uint8_t*)0x2000000005c9 = 0); NONFAILING(*(uint16_t*)0x2000000005ca = 0); NONFAILING(*(uint32_t*)0x2000000005cc = 0); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005d0, 7, 0, 3)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005d0, 1, 3, 1)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005d0, 0xb, 4, 4)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005d1, 1, 0, 4)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005d1, 9, 4, 4)); NONFAILING(*(uint16_t*)0x2000000005d2 = 0); NONFAILING(*(uint32_t*)0x2000000005d4 = 0); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005d8, 7, 0, 3)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005d8, 0, 3, 1)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005d8, 0xb, 4, 4)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005d9, 2, 0, 4)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005d9, 0, 4, 4)); NONFAILING(*(uint16_t*)0x2000000005da = 0); NONFAILING(*(uint32_t*)0x2000000005dc = 1); NONFAILING(*(uint8_t*)0x2000000005e0 = 0x85); NONFAILING(*(uint8_t*)0x2000000005e1 = 0); NONFAILING(*(uint16_t*)0x2000000005e2 = 0); NONFAILING(*(uint32_t*)0x2000000005e4 = 5); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005e8, 7, 0, 3)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005e8, 0, 3, 1)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005e8, 0xb, 4, 4)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005e9, 0, 0, 4)); NONFAILING(STORE_BY_BITMASK(uint8_t, , 0x2000000005e9, 0, 4, 4)); NONFAILING(*(uint16_t*)0x2000000005ea = 0); NONFAILING(*(uint32_t*)0x2000000005ec = 0); NONFAILING(*(uint8_t*)0x2000000005f0 = 0x95); NONFAILING(*(uint8_t*)0x2000000005f1 = 0); NONFAILING(*(uint16_t*)0x2000000005f2 = 0); NONFAILING(*(uint32_t*)0x2000000005f4 = 0); NONFAILING(*(uint64_t*)0x200000000450 = 0x200000000040); NONFAILING(memcpy((void*)0x200000000040, "syzkaller\000", 10)); NONFAILING(*(uint32_t*)0x200000000458 = 0); NONFAILING(*(uint32_t*)0x20000000045c = 0); NONFAILING(*(uint64_t*)0x200000000460 = 0); NONFAILING(*(uint32_t*)0x200000000468 = 0); NONFAILING(*(uint32_t*)0x20000000046c = 0); NONFAILING(memset((void*)0x200000000470, 0, 16)); NONFAILING(*(uint32_t*)0x200000000480 = 0); NONFAILING(*(uint32_t*)0x200000000484 = 0); NONFAILING(*(uint32_t*)0x200000000488 = -1); NONFAILING(*(uint32_t*)0x20000000048c = 8); NONFAILING(*(uint64_t*)0x200000000490 = 0); NONFAILING(*(uint32_t*)0x200000000498 = 0); NONFAILING(*(uint32_t*)0x20000000049c = 0x10); NONFAILING(*(uint64_t*)0x2000000004a0 = 0); NONFAILING(*(uint32_t*)0x2000000004a8 = 0); NONFAILING(*(uint32_t*)0x2000000004ac = 0); NONFAILING(*(uint32_t*)0x2000000004b0 = 0); NONFAILING(*(uint32_t*)0x2000000004b4 = 0); NONFAILING(*(uint64_t*)0x2000000004b8 = 0); NONFAILING(*(uint64_t*)0x2000000004c0 = 0); NONFAILING(*(uint32_t*)0x2000000004c8 = 0x10); NONFAILING(*(uint32_t*)0x2000000004cc = 0); NONFAILING(*(uint32_t*)0x2000000004d0 = 0); syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0x200000000440ul, /*size=*/0x94ul); // bpf$BPF_PROG_RAW_TRACEPOINT_LOAD arguments: [ // cmd: const = 0x5 (8 bytes) // arg: ptr[in, bpf_prog_t[flags[bpf_raw_tracepoint_prog_types, int32], // const[0, int32], const[0, int32], const[0, int32]]] { // bpf_prog_t[flags[bpf_raw_tracepoint_prog_types, int32], const[0, // int32], const[0, int32], const[0, int32]] { // type: bpf_raw_tracepoint_prog_types = 0x8 (4 bytes) // ninsn: bytesize8 = 0x3 (4 bytes) // insns: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 95} (length 0x11) // } // } // } // license: ptr[in, buffer] { // buffer: {73 79 7a 6b 61 6c 6c 65 72 00} (length 0xa) // } // 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: // const = 0x0 (4 bytes) btf_fd: fd_btf (resource) func_info_rec_size: // const = 0x8 (4 bytes) func_info: nil func_info_cnt: len = 0x0 (4 // bytes) line_info_rec_size: const = 0x10 (4 bytes) line_info: nil // line_info_cnt: len = 0x0 (4 bytes) // attach_btf_id: const = 0x0 (4 bytes) // attach_prog_fd: const = 0x0 (4 bytes) // core_relo_cnt: len = 0x0 (4 bytes) // fd_array: nil // core_relos: nil // core_relo_rec_size: const = 0x10 (4 bytes) // log_true_size: int32 = 0x0 (4 bytes) // prog_token_fd: union // _bpf_prog_t[flags[bpf_raw_tracepoint_prog_types, int32], const[0, // int32], const[0, int32], const[0, int32]]_prog_token_fd_wrapper { // void: buffer: {} (length 0x0) // } // pad: union _bpf_prog_t[flags[bpf_raw_tracepoint_prog_types, int32], // const[0, int32], const[0, int32], const[0, int32]]_pad_wrapper { // value: const = 0x0 (4 bytes) // } // } // } // size: len = 0x94 (8 bytes) // ] // returns fd_bpf_prog_raw_tracepoint NONFAILING(*(uint32_t*)0x200000001c40 = 8); NONFAILING(*(uint32_t*)0x200000001c44 = 3); NONFAILING(*(uint64_t*)0x200000001c48 = 0x200000001300); NONFAILING(memcpy( (void*)0x200000001300, "\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x95", 17)); NONFAILING(*(uint64_t*)0x200000001c50 = 0x200000001200); NONFAILING(memcpy((void*)0x200000001200, "syzkaller\000", 10)); NONFAILING(*(uint32_t*)0x200000001c58 = 0); NONFAILING(*(uint32_t*)0x200000001c5c = 0); NONFAILING(*(uint64_t*)0x200000001c60 = 0); NONFAILING(*(uint32_t*)0x200000001c68 = 0); NONFAILING(*(uint32_t*)0x200000001c6c = 0); NONFAILING(memset((void*)0x200000001c70, 0, 16)); NONFAILING(*(uint32_t*)0x200000001c80 = 0); NONFAILING(*(uint32_t*)0x200000001c84 = 0); NONFAILING(*(uint32_t*)0x200000001c88 = -1); NONFAILING(*(uint32_t*)0x200000001c8c = 8); NONFAILING(*(uint64_t*)0x200000001c90 = 0); NONFAILING(*(uint32_t*)0x200000001c98 = 0); NONFAILING(*(uint32_t*)0x200000001c9c = 0x10); NONFAILING(*(uint64_t*)0x200000001ca0 = 0); NONFAILING(*(uint32_t*)0x200000001ca8 = 0); NONFAILING(*(uint32_t*)0x200000001cac = 0); NONFAILING(*(uint32_t*)0x200000001cb0 = 0); NONFAILING(*(uint32_t*)0x200000001cb4 = 0); NONFAILING(*(uint64_t*)0x200000001cb8 = 0); NONFAILING(*(uint64_t*)0x200000001cc0 = 0); NONFAILING(*(uint32_t*)0x200000001cc8 = 0x10); NONFAILING(*(uint32_t*)0x200000001ccc = 0); NONFAILING(*(uint32_t*)0x200000001cd0 = 0); res = syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0x200000001c40ul, /*size=*/0x94ul); if (res != -1) r[1] = res; // fsopen arguments: [ // type: ptr[in, buffer] { // buffer: {63 67 72 6f 75 70 32 00} (length 0x8) // } // flags: fsopen_flags = 0x0 (8 bytes) // ] // returns fd_fscontext NONFAILING(memcpy((void*)0x200000000000, "cgroup2\000", 8)); res = syscall(__NR_fsopen, /*type=*/0x200000000000ul, /*flags=*/0ul); if (res != -1) r[2] = res; // fsconfig$FSCONFIG_CMD_CREATE arguments: [ // fd: fd_fscontext (resource) // cmd: const = 0x6 (8 bytes) // key: const = 0x0 (8 bytes) // value: const = 0x0 (8 bytes) // aux: const = 0x0 (8 bytes) // ] syscall(__NR_fsconfig, /*fd=*/r[2], /*cmd=*/6ul, /*key=*/0ul, /*value=*/0ul, /*aux=*/0ul); // fsmount arguments: [ // fs_fd: fd_fscontext (resource) // flags: fsmount_flags = 0x0 (8 bytes) // attr_flags: fsmount_attr_flags = 0x0 (8 bytes) // ] // returns fd res = syscall(__NR_fsmount, /*fs_fd=*/r[2], /*flags=*/0ul, /*attr_flags=*/0ul); if (res != -1) r[3] = res; // bpf$BPF_LINK_CREATE arguments: [ // cmd: const = 0x1c (8 bytes) // arg: ptr[in, bpf_link_create_arg_t[fd_bpf_prog, fd_cgroup, // flags[bpf_attach_types_link_create, int32], const[0, int32]]] { // bpf_link_create_arg_t[fd_bpf_prog, fd_cgroup, // flags[bpf_attach_types_link_create, int32], const[0, int32]] { // prog_fd: fd_bpf_prog (resource) // target_fd: fd_cgroup (resource) // attach_type: bpf_attach_types_link_create = 0x1 (4 bytes) // flags: const = 0x0 (4 bytes) // extra: union optional[link_create_arg_extra] { // val: union link_create_arg_extra { // tracing: link_create_tracing { // target_btf_id: bpf_btf_id (resource) // pad = 0x0 (4 bytes) // cookie: int64 = 0x8001 (8 bytes) // } // } // } // } // } // size: len = 0x20 (8 bytes) // ] // returns fd_bpf_link NONFAILING(*(uint32_t*)0x200000000640 = r[1]); NONFAILING(*(uint32_t*)0x200000000644 = r[3]); NONFAILING(*(uint32_t*)0x200000000648 = 1); NONFAILING(*(uint32_t*)0x20000000064c = 0); NONFAILING(*(uint32_t*)0x200000000650 = 0); NONFAILING(*(uint64_t*)0x200000000658 = 0x8001); res = syscall(__NR_bpf, /*cmd=*/0x1cul, /*arg=*/0x200000000640ul, /*size=*/0x20ul); if (res != -1) r[4] = res; // bpf$ITER_CREATE arguments: [ // cmd: const = 0x1d (8 bytes) // arg: ptr[in, bpf_iter_create_arg] { // bpf_iter_create_arg { // link_fd: fd_bpf_link (resource) // flags: const = 0x7 (4 bytes) // } // } // size: len = 0x8 (8 bytes) // ] // returns fd NONFAILING(*(uint32_t*)0x200000000040 = r[4]); NONFAILING(*(uint32_t*)0x200000000044 = 7); syscall(__NR_bpf, /*cmd=*/0x1dul, /*arg=*/0x200000000040ul, /*size=*/8ul); } 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(); setup_cgroups(); const char* reason; (void)reason; if ((reason = setup_binfmt_misc())) printf("the reproducer may not work as expected: binfmt_misc setup failed: " "%s\n", reason); install_segv_handler(); use_temporary_dir(); do_sandbox_none(); return 0; }