// https://syzkaller.appspot.com/bug?id=d84a94e93317c622d65ba62c572dc12898272fd1 // autogenerated by syzkaller (http://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 #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 #include #include #include #include __attribute__((noreturn)) static void doexit(int status) { volatile unsigned i; syscall(__NR_exit_group, status); for (i = 0;; i++) { } } #include #include #include #include #include #include #include const int kFailStatus = 67; const int kRetryStatus = 69; static void fail(const char* msg, ...) { int e = errno; va_list args; va_start(args, msg); vfprintf(stderr, msg, args); va_end(args); fprintf(stderr, " (errno %d)\n", e); doexit((e == ENOMEM || e == EAGAIN) ? kRetryStatus : kFailStatus); } static void exitf(const char* msg, ...) { int e = errno; va_list args; va_start(args, msg); vfprintf(stderr, msg, args); va_end(args); fprintf(stderr, " (errno %d)\n", e); doexit(kRetryStatus); } static uint64_t current_time_ms() { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) fail("clock_gettime failed"); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir() { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) fail("failed to mkdtemp"); if (chmod(tmpdir, 0777)) fail("failed to chmod"); if (chdir(tmpdir)) fail("failed to chdir"); } static void vsnprintf_check(char* str, size_t size, const char* format, va_list args) { int rv; rv = vsnprintf(str, size, format, args); if (rv < 0) fail("tun: snprintf failed"); if ((size_t)rv >= size) fail("tun: string '%s...' doesn't fit into buffer", str); } #define COMMAND_MAX_LEN 128 #define PATH_PREFIX \ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin " #define PATH_PREFIX_LEN (sizeof(PATH_PREFIX) - 1) static void execute_command(bool panic, const char* format, ...) { va_list args; char command[PATH_PREFIX_LEN + COMMAND_MAX_LEN]; int rv; va_start(args, format); memcpy(command, PATH_PREFIX, PATH_PREFIX_LEN); vsnprintf_check(command + PATH_PREFIX_LEN, COMMAND_MAX_LEN, format, args); va_end(args); rv = system(command); if (rv) { if (panic) fail("command '%s' failed: %d", &command[0], rv); } } static int tunfd = -1; static int tun_frags_enabled; #define SYZ_TUN_MAX_PACKET_SIZE 1000 #define TUN_IFACE "syz_tun" #define LOCAL_MAC "aa:aa:aa:aa:aa:aa" #define REMOTE_MAC "aa:aa:aa:aa:aa:bb" #define LOCAL_IPV4 "172.20.20.170" #define REMOTE_IPV4 "172.20.20.187" #define LOCAL_IPV6 "fe80::aa" #define REMOTE_IPV6 "fe80::bb" #define IFF_NAPI 0x0010 #define IFF_NAPI_FRAGS 0x0020 static void initialize_tun(void) { tunfd = open("/dev/net/tun", O_RDWR | O_NONBLOCK); if (tunfd == -1) { printf("tun: can't open /dev/net/tun: please enable CONFIG_TUN=y\n"); printf("otherwise fuzzing or reproducing might not work as intended\n"); return; } const int kTunFd = 252; if (dup2(tunfd, kTunFd) < 0) fail("dup2(tunfd, kTunFd) failed"); close(tunfd); tunfd = kTunFd; struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, TUN_IFACE, IFNAMSIZ); ifr.ifr_flags = IFF_TAP | IFF_NO_PI | IFF_NAPI | IFF_NAPI_FRAGS; if (ioctl(tunfd, TUNSETIFF, (void*)&ifr) < 0) { ifr.ifr_flags = IFF_TAP | IFF_NO_PI; if (ioctl(tunfd, TUNSETIFF, (void*)&ifr) < 0) fail("tun: ioctl(TUNSETIFF) failed"); } if (ioctl(tunfd, TUNGETIFF, (void*)&ifr) < 0) fail("tun: ioctl(TUNGETIFF) failed"); tun_frags_enabled = (ifr.ifr_flags & IFF_NAPI_FRAGS) != 0; execute_command(1, "sysctl -w net.ipv6.conf.%s.accept_dad=0", TUN_IFACE); execute_command(1, "sysctl -w net.ipv6.conf.%s.router_solicitations=0", TUN_IFACE); execute_command(1, "ip link set dev %s address %s", TUN_IFACE, LOCAL_MAC); execute_command(1, "ip addr add %s/24 dev %s", LOCAL_IPV4, TUN_IFACE); execute_command(1, "ip -6 addr add %s/120 dev %s", LOCAL_IPV6, TUN_IFACE); execute_command(1, "ip neigh add %s lladdr %s dev %s nud permanent", REMOTE_IPV4, REMOTE_MAC, TUN_IFACE); execute_command(1, "ip -6 neigh add %s lladdr %s dev %s nud permanent", REMOTE_IPV6, REMOTE_MAC, TUN_IFACE); execute_command(1, "ip link set dev %s up", TUN_IFACE); } #define DEV_IPV4 "172.20.20.%d" #define DEV_IPV6 "fe80::%02hx" #define DEV_MAC "aa:aa:aa:aa:aa:%02hx" static void snprintf_check(char* str, size_t size, const char* format, ...) { va_list args; va_start(args, format); vsnprintf_check(str, size, format, args); va_end(args); } static void initialize_netdevices(void) { unsigned i; const char* devtypes[] = {"ip6gretap", "bridge", "vcan", "bond", "team"}; const char* devnames[] = {"lo", "sit0", "bridge0", "vcan0", "tunl0", "gre0", "gretap0", "ip_vti0", "ip6_vti0", "ip6tnl0", "ip6gre0", "ip6gretap0", "erspan0", "bond0", "veth0", "veth1", "team0", "veth0_to_bridge", "veth1_to_bridge", "veth0_to_bond", "veth1_to_bond", "veth0_to_team", "veth1_to_team"}; const char* devmasters[] = {"bridge", "bond", "team"}; for (i = 0; i < sizeof(devtypes) / (sizeof(devtypes[0])); i++) execute_command(0, "ip link add dev %s0 type %s", devtypes[i], devtypes[i]); execute_command(0, "ip link add type veth"); for (i = 0; i < sizeof(devmasters) / (sizeof(devmasters[0])); i++) { execute_command( 0, "ip link add name %s_slave_0 type veth peer name veth0_to_%s", devmasters[i], devmasters[i]); execute_command( 0, "ip link add name %s_slave_1 type veth peer name veth1_to_%s", devmasters[i], devmasters[i]); execute_command(0, "ip link set %s_slave_0 master %s0", devmasters[i], devmasters[i]); execute_command(0, "ip link set %s_slave_1 master %s0", devmasters[i], devmasters[i]); execute_command(0, "ip link set veth0_to_%s up", devmasters[i]); execute_command(0, "ip link set veth1_to_%s up", devmasters[i]); } execute_command(0, "ip link set bridge_slave_0 up"); execute_command(0, "ip link set bridge_slave_1 up"); for (i = 0; i < sizeof(devnames) / (sizeof(devnames[0])); i++) { char addr[32]; snprintf_check(addr, sizeof(addr), DEV_IPV4, i + 10); execute_command(0, "ip -4 addr add %s/24 dev %s", addr, devnames[i]); snprintf_check(addr, sizeof(addr), DEV_IPV6, i + 10); execute_command(0, "ip -6 addr add %s/120 dev %s", addr, devnames[i]); snprintf_check(addr, sizeof(addr), DEV_MAC, i + 10); execute_command(0, "ip link set dev %s address %s", devnames[i], addr); execute_command(0, "ip link set dev %s up", devnames[i]); } } static int read_tun(char* data, int size) { if (tunfd < 0) return -1; int rv = read(tunfd, data, size); if (rv < 0) { if (errno == EAGAIN) return -1; if (errno == EBADFD) return -1; fail("tun: read failed with %d", rv); } return rv; } static void flush_tun() { char data[SYZ_TUN_MAX_PACKET_SIZE]; while (read_tun(&data[0], sizeof(data)) != -1) ; } static uintptr_t syz_open_procfs(uintptr_t a0, uintptr_t a1) { char buf[128]; memset(buf, 0, sizeof(buf)); if (a0 == 0) { snprintf(buf, sizeof(buf), "/proc/self/%s", (char*)a1); } else if (a0 == (uintptr_t)-1) { snprintf(buf, sizeof(buf), "/proc/thread-self/%s", (char*)a1); } else { snprintf(buf, sizeof(buf), "/proc/self/task/%d/%s", (int)a0, (char*)a1); } int fd = open(buf, O_RDWR); if (fd == -1) fd = open(buf, O_RDONLY); return fd; } 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_cgroups() { if (mkdir("/syzcgroup", 0777)) { } if (mkdir("/syzcgroup/unified", 0777)) { } if (mount("none", "/syzcgroup/unified", "cgroup2", 0, NULL)) { } if (chmod("/syzcgroup/unified", 0777)) { } if (!write_file("/syzcgroup/unified/cgroup.subtree_control", "+cpu +memory +io +pids +rdma")) { } if (mkdir("/syzcgroup/cpu", 0777)) { } if (mount("none", "/syzcgroup/cpu", "cgroup", 0, "cpuset,cpuacct,perf_event,hugetlb")) { } if (!write_file("/syzcgroup/cpu/cgroup.clone_children", "1")) { } if (chmod("/syzcgroup/cpu", 0777)) { } if (mkdir("/syzcgroup/net", 0777)) { } if (mount("none", "/syzcgroup/net", "cgroup", 0, "net_cls,net_prio,devices,freezer")) { } if (chmod("/syzcgroup/net", 0777)) { } } static void setup_binfmt_misc() { if (!write_file("/proc/sys/fs/binfmt_misc/register", ":syz0:M:0:syz0::./file0:")) { } if (!write_file("/proc/sys/fs/binfmt_misc/register", ":syz1:M:1:yz1::./file0:POC")) { } } static void loop(); static void sandbox_common() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); setsid(); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = 160 << 20; setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 8 << 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 = 0; setrlimit(RLIMIT_CORE, &rlim); if (unshare(CLONE_NEWNS)) { } if (unshare(CLONE_NEWIPC)) { } if (unshare(0x02000000)) { } if (unshare(CLONE_NEWUTS)) { } if (unshare(CLONE_SYSVSEM)) { } } static int real_uid; static int real_gid; __attribute__((aligned(64 << 10))) static char sandbox_stack[1 << 20]; static int namespace_sandbox_proc(void* arg) { sandbox_common(); write_file("/proc/self/setgroups", "deny"); if (!write_file("/proc/self/uid_map", "0 %d 1\n", real_uid)) fail("write of /proc/self/uid_map failed"); if (!write_file("/proc/self/gid_map", "0 %d 1\n", real_gid)) fail("write of /proc/self/gid_map failed"); if (unshare(CLONE_NEWNET)) fail("unshare(CLONE_NEWNET)"); initialize_tun(); initialize_netdevices(); if (mkdir("./syz-tmp", 0777)) fail("mkdir(syz-tmp) failed"); if (mount("", "./syz-tmp", "tmpfs", 0, NULL)) fail("mount(tmpfs) failed"); if (mkdir("./syz-tmp/newroot", 0777)) fail("mkdir failed"); if (mkdir("./syz-tmp/newroot/dev", 0700)) fail("mkdir failed"); unsigned mount_flags = MS_BIND | MS_REC | MS_PRIVATE; if (mount("/dev", "./syz-tmp/newroot/dev", NULL, mount_flags, NULL)) fail("mount(dev) failed"); if (mkdir("./syz-tmp/newroot/proc", 0700)) fail("mkdir failed"); if (mount(NULL, "./syz-tmp/newroot/proc", "proc", 0, NULL)) fail("mount(proc) failed"); if (mkdir("./syz-tmp/newroot/selinux", 0700)) fail("mkdir failed"); const char* selinux_path = "./syz-tmp/newroot/selinux"; if (mount("/selinux", selinux_path, NULL, mount_flags, NULL)) { if (errno != ENOENT) fail("mount(/selinux) failed"); if (mount("/sys/fs/selinux", selinux_path, NULL, mount_flags, NULL) && errno != ENOENT) fail("mount(/sys/fs/selinux) failed"); } if (mkdir("./syz-tmp/newroot/sys", 0700)) fail("mkdir failed"); if (mount(NULL, "./syz-tmp/newroot/sys", "sysfs", 0, NULL)) fail("mount(sysfs) failed"); if (mkdir("./syz-tmp/newroot/syzcgroup", 0700)) fail("mkdir failed"); if (mkdir("./syz-tmp/newroot/syzcgroup/unified", 0700)) fail("mkdir failed"); if (mkdir("./syz-tmp/newroot/syzcgroup/cpu", 0700)) fail("mkdir failed"); if (mkdir("./syz-tmp/newroot/syzcgroup/net", 0700)) fail("mkdir failed"); if (mount("/syzcgroup/unified", "./syz-tmp/newroot/syzcgroup/unified", NULL, mount_flags, NULL)) { } if (mount("/syzcgroup/cpu", "./syz-tmp/newroot/syzcgroup/cpu", NULL, mount_flags, NULL)) { } if (mount("/syzcgroup/net", "./syz-tmp/newroot/syzcgroup/net", NULL, mount_flags, NULL)) { } if (mkdir("./syz-tmp/pivot", 0777)) fail("mkdir failed"); if (syscall(SYS_pivot_root, "./syz-tmp", "./syz-tmp/pivot")) { if (chdir("./syz-tmp")) fail("chdir failed"); } else { if (chdir("/")) fail("chdir failed"); if (umount2("./pivot", MNT_DETACH)) fail("umount failed"); } if (chroot("./newroot")) fail("chroot failed"); if (chdir("/")) fail("chdir failed"); 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)) fail("capget failed"); cap_data[0].effective &= ~(1 << CAP_SYS_PTRACE); cap_data[0].permitted &= ~(1 << CAP_SYS_PTRACE); cap_data[0].inheritable &= ~(1 << CAP_SYS_PTRACE); if (syscall(SYS_capset, &cap_hdr, &cap_data)) fail("capset failed"); loop(); doexit(1); } static int do_sandbox_namespace(void) { int pid; setup_cgroups(); setup_binfmt_misc(); real_uid = getuid(); real_gid = getgid(); mprotect(sandbox_stack, 4096, PROT_NONE); pid = clone(namespace_sandbox_proc, &sandbox_stack[sizeof(sandbox_stack) - 64], CLONE_NEWUSER | CLONE_NEWPID, 0); if (pid < 0) fail("sandbox clone failed"); return pid; } static void remove_dir(const char* dir) { DIR* dp; struct dirent* ep; int iter = 0; retry: while (umount2(dir, MNT_DETACH) == 0) { } dp = opendir(dir); if (dp == NULL) { if (errno == EMFILE) { exitf("opendir(%s) failed due to NOFILE, exiting", dir); } exitf("opendir(%s) failed", dir); } 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); struct stat st; if (lstat(filename, &st)) exitf("lstat(%s) failed", filename); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } int i; for (i = 0;; i++) { if (unlink(filename) == 0) break; if (errno == EROFS) { break; } if (errno != EBUSY || i > 100) exitf("unlink(%s) failed", filename); if (umount2(filename, MNT_DETACH)) exitf("umount(%s) failed", filename); } } closedir(dp); int i; for (i = 0;; i++) { if (rmdir(dir) == 0) break; if (i < 100) { if (errno == EROFS) { break; } if (errno == EBUSY) { if (umount2(dir, MNT_DETACH)) exitf("umount(%s) failed", dir); continue; } if (errno == ENOTEMPTY) { if (iter < 100) { iter++; goto retry; } } } exitf("rmdir(%s) failed", dir); } } static void execute_one(); extern unsigned long long procid; static void loop() { char cgroupdir[64]; snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/unified/syz%llu", procid); char cgroupdir_cpu[64]; snprintf(cgroupdir_cpu, sizeof(cgroupdir_cpu), "/syzcgroup/cpu/syz%llu", procid); char cgroupdir_net[64]; snprintf(cgroupdir_net, sizeof(cgroupdir_net), "/syzcgroup/net/syz%llu", procid); if (mkdir(cgroupdir, 0777)) { } if (mkdir(cgroupdir_cpu, 0777)) { } if (mkdir(cgroupdir_net, 0777)) { } int pid = getpid(); char procs_file[128]; snprintf(procs_file, sizeof(procs_file), "%s/cgroup.procs", cgroupdir); if (!write_file(procs_file, "%d", pid)) { } snprintf(procs_file, sizeof(procs_file), "%s/cgroup.procs", cgroupdir_cpu); if (!write_file(procs_file, "%d", pid)) { } snprintf(procs_file, sizeof(procs_file), "%s/cgroup.procs", cgroupdir_net); if (!write_file(procs_file, "%d", pid)) { } int iter; for (iter = 0;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) fail("failed to mkdir"); int pid = fork(); if (pid < 0) fail("clone failed"); if (pid == 0) { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); if (chdir(cwdbuf)) fail("failed to chdir"); if (symlink(cgroupdir, "./cgroup")) { } if (symlink(cgroupdir_cpu, "./cgroup.cpu")) { } if (symlink(cgroupdir_net, "./cgroup.net")) { } flush_tun(); execute_one(); doexit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { int res = waitpid(-1, &status, __WALL | WNOHANG); if (res == pid) { break; } usleep(1000); if (current_time_ms() - start < 3 * 1000) continue; kill(-pid, SIGKILL); kill(pid, SIGKILL); while (waitpid(-1, &status, __WALL) != pid) { } break; } remove_dir(cwdbuf); } } struct thread_t { int created, running, call; pthread_t th; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { while (!__atomic_load_n(&th->running, __ATOMIC_ACQUIRE)) syscall(SYS_futex, &th->running, FUTEX_WAIT, 0, 0); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); __atomic_store_n(&th->running, 0, __ATOMIC_RELEASE); syscall(SYS_futex, &th->running, FUTEX_WAKE); } return 0; } static void execute(int num_calls) { int call, thread; running = 0; for (call = 0; call < num_calls; call++) { for (thread = 0; thread < sizeof(threads) / sizeof(threads[0]); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); pthread_create(&th->th, &attr, thr, th); } if (!__atomic_load_n(&th->running, __ATOMIC_ACQUIRE)) { th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); __atomic_store_n(&th->running, 1, __ATOMIC_RELEASE); syscall(SYS_futex, &th->running, FUTEX_WAKE); struct timespec ts; ts.tv_sec = 0; ts.tv_nsec = 20 * 1000 * 1000; syscall(SYS_futex, &th->running, FUTEX_WAIT, 1, &ts); if (running) usleep((call == num_calls - 1) ? 10000 : 1000); break; } } } } uint64_t r[1] = {0xffffffffffffffff}; unsigned long long procid; void execute_call(int call) { long res; switch (call) { case 0: syscall(__NR_mlockall, 2); break; case 1: syscall(__NR_clone, 0, 0x20b53000, 0x2084effc, 0x20c35ffc, 0x20b3bfff); break; case 2: syscall(__NR_ioctl, -1, 0x4b70, 0x20000240); break; case 3: syscall(__NR_ioctl, -1, 0x541b, 0x20000280); break; case 4: syscall(__NR_socket, 0x10, 3, 0); break; case 5: memcpy((void*)0x20000580, "/dev/full", 10); syscall(__NR_openat, 0xffffffffffffff9c, 0x20000580, 0x400000, 0); break; case 6: *(uint32_t*)0x20000980 = 7; *(uint32_t*)0x20000984 = 0; *(uint32_t*)0x20000988 = 0x1ff; *(uint32_t*)0x2000098c = 0x1d1a; *(uint32_t*)0x20000990 = 0; *(uint32_t*)0x20000994 = 7; *(uint8_t*)0x20000998 = 0; *(uint8_t*)0x20000999 = 0; *(uint8_t*)0x2000099a = 0; *(uint8_t*)0x2000099b = 0; *(uint8_t*)0x2000099c = 0; *(uint8_t*)0x2000099d = 0; *(uint8_t*)0x2000099e = 0; *(uint8_t*)0x2000099f = 0; *(uint8_t*)0x200009a0 = 0; *(uint8_t*)0x200009a1 = 0; *(uint8_t*)0x200009a2 = 0; *(uint8_t*)0x200009a3 = 0; *(uint8_t*)0x200009a4 = 0; *(uint8_t*)0x200009a5 = 0; *(uint8_t*)0x200009a6 = 0; *(uint8_t*)0x200009a7 = 0; *(uint8_t*)0x200009a8 = 0; *(uint8_t*)0x200009a9 = 0; *(uint8_t*)0x200009aa = 0; *(uint8_t*)0x200009ab = 0; *(uint8_t*)0x200009ac = 0; *(uint8_t*)0x200009ad = 0; *(uint8_t*)0x200009ae = 0; *(uint8_t*)0x200009af = 0; *(uint8_t*)0x200009b0 = 0; *(uint8_t*)0x200009b1 = 0; *(uint8_t*)0x200009b2 = 0; *(uint8_t*)0x200009b3 = 0; *(uint8_t*)0x200009b4 = 0; *(uint8_t*)0x200009b5 = 0; *(uint8_t*)0x200009b6 = 0; *(uint8_t*)0x200009b7 = 0; *(uint8_t*)0x200009b8 = 0; *(uint8_t*)0x200009b9 = 0; *(uint8_t*)0x200009ba = 0; *(uint8_t*)0x200009bb = 0; *(uint8_t*)0x200009bc = 0; *(uint8_t*)0x200009bd = 0; *(uint8_t*)0x200009be = 0; *(uint8_t*)0x200009bf = 0; *(uint8_t*)0x200009c0 = 0; *(uint8_t*)0x200009c1 = 0; *(uint8_t*)0x200009c2 = 0; *(uint8_t*)0x200009c3 = 0; *(uint8_t*)0x200009c4 = 0; *(uint8_t*)0x200009c5 = 0; *(uint8_t*)0x200009c6 = 0; *(uint8_t*)0x200009c7 = 0; *(uint8_t*)0x200009c8 = 0; *(uint8_t*)0x200009c9 = 0; *(uint8_t*)0x200009ca = 0; *(uint8_t*)0x200009cb = 0; *(uint8_t*)0x200009cc = 0; *(uint8_t*)0x200009cd = 0; *(uint8_t*)0x200009ce = 0; *(uint8_t*)0x200009cf = 0; *(uint8_t*)0x200009d0 = 0; *(uint8_t*)0x200009d1 = 0; *(uint8_t*)0x200009d2 = 0; *(uint8_t*)0x200009d3 = 0; *(uint8_t*)0x200009d4 = 0; *(uint8_t*)0x200009d5 = 0; *(uint8_t*)0x200009d6 = 0; *(uint8_t*)0x200009d7 = 0; syscall(__NR_ioctl, -1, 0xc058534b, 0x20000980); break; case 7: memcpy((void*)0x20000240, "\x2f\x65\x78\x65\x00\x00\x00\x00\x00\x04\x09\x00\x4b\xdd\xd9\xde" "\x91\xbe\x10\xee\xbf\x00\x0e\xe9\xa9\x0f\x79\x80\x58\x43\x9e\xd5" "\x54\xfa\x07\x42\x4a\xde\xe9\x01\xd2\xda\x75\xaf\x1f\x02\x00\xf5" "\xab\x26\xd7\xa0\x71\xfb\x35\x33\x1c\xe3\x9c\x5a", 60); syz_open_procfs(0, 0x20000240); break; case 8: memcpy( (void*)0x200002c0, "\x08\x01\x05\x0f\xc2\x00\x00\x00\xb9\x00\x00\x00\xb8\x42\x00\x00\xe3" "\x00\x00\x00\x00\x00\x00\x7e\x29\x11\x76\x9a\xf4\xd7\x77\xae\x78\x55" "\x29\x69\xad\x64\xbf\x7c\x41\x96\x1c\xe4\xb5\x78\x0b\x5a\x02\x96\x13" "\x66\x46\x3d\xad\xf7\x04\x80\x0d\xd1\xe7\x34\x55\x43\xd3\x21\xf6\x42" "\x0d\xc9\x31\x30\x9e\x22\xa1\xcb\x7d\x24\x80\x9e\x9e\xfc\x82\xa2\x79" "\x52\xa6\x84\x6c\x86\x03\x15\x8c\xc8\xe1\x0d\x32\x1e\xa7\x2d\xf4\x79" "\x17\x39\xd4\xb8\x69\x02\x6d\xa1\x27\x57\x65\xff\xa0\x55\xfc\x8c\xc6" "\x92\x8f\xa9\x58\x16\x4f\x59\xbf\x91\x74\xb2\x8b\x8e\x6a\xec\xb3\x70" "\xbb\x74\xe1\xfc\x2b\xac\x13\x6a\xb6\x72\x7b\xd2\xcb\x7d\x91\xed\x7f" "\x35\x46\xd1\xa7\x75\x99\x73\x66\x53\x4d\x19\x3f\xa2\x01\x7d\xa0\x6a" "\x1d\x63\x58\x2d\x35\x08\xc3\x8a\x40\xef\xce\xab\xea\xf6\xa4\xc7\x4a" "\x27\xad\xd6\xb2\x63\x4c\xa7\xda\x32\x87\xbd\x69\x3e\x51\x42\x42\xab" "\x27\x94\x17\x8a\x69\x07\x61\xee\xa7\x24\xc3\x46\x70\x70\xb5\xd5\x61" "\xd0\x65\x87\xff\x24\xa9\x77\x6b\x89\x92\xbd\x2d\x8f\x9e\x77\x10\x38" "\xd7\x75\x3a\xb7\xbc\x89\x45\x5b\x9a\x49\x44\xc1\xb6\xc9\xb5\xeb\xa8" "\x9c\x51\x29\x35\xb9\x52\xe6\x48\x83\x5c\x64\x67\xd7\x26\x6a\xc8\x9b" "\x02\x34\x6b\x60\xff\xeb\x4e\x80\x84\x01\xdd\x05\x00\x00\xc7\x11\xb9" "\x3e\xda\xb7\x66\x14\x68\xb8\x68\x26\xb3\x17\x48\xcc\xe9\xb5\x97\x87" "\xbb\x44\x6d\xc4\x9f\x64\x24\xc3\xff\x36\xd6\xcf\x0a\x85\x27\x9b\x1c" "\x01\x47\x2d\xa7\x6c\x6f\x9b\x34\xf6\x90\xb7\xd7\xe8\x9b\x5a\x19\x53" "\x09\x0c\x08\xd0\x27\xe5\xef\x62\x73\xa0\x72\x16\x1a\x08\x96\x5d\x6a" "\x7c\x78\xd0\x86\xd7\xdb\x03\x3b\x05\x67\x6b\x7c\x5b\x30\x5d\xbf\x72" "\x66\x13\x43\xa5\xce\xf7\xbc\x05\x90\xe4\x7f\xfe\x97\xb2\x7b\x17\xd7" "\xee\x5d\x6c\x02\xce\xa8\xc6\x3f\x97\xac\x14\x55\x81\xa1\xb4\xfc\x4a" "\x44\xcd\xc5\x32\x0e\x5f\x1a\x32\x38\xbd\xdc\x99\x84\xd8\x6a\xa2\xe3" "\xfb\xd4\xb1\xc4\x2c\x5b\x7e\xf3\x2d\xae\x0b\x1b\x56\xfa\xe5\x4c\x33" "\x44\x5b\x3b\xbb\x0e\xcb\x48\xc3\xd6\xe9\xf4\x50\x3f\x06\x51\x40\x05" "\xfd\x4f\xad\xdd\x6f\xf1\xa9\xde\x5c\xff\xed\xa6\x17\x07\x71\x67\x2d" "\x8a\x24\x39\x96\x55\xef\xb1\x7e\xd4\xc3\x21\xea\xfd\x34\x3d\x65\x9b" "\x87\xd5\x60\xdd\x55\x7c\x69\x3d\x85\x85\x7f\xa9\x2a\x02\xb4\x53\x7d" "\x39\xab\xd6\x1f\x40\xaf\x91\xa0\x52\xd1\x52\x5b\x8a\x50\x08\x7b\x61" "\xc5\x6e\x6e\xc8\xa1\xcc\x73\x2a\xa4\xc1\x78\xe1\x77\x67\xda\xdc\xa6" "\x84\xdc\xee\x6a\xd0\x69\xe8\x57\x80\xfa\x8e\x36\x33\xcb\x01\x15\x3a" "\x88\x21\x83\x59\xc0\xca\x44\x75\x95\xf5\xd6\x92\x9f\x83\xa2\x47\x49" "\x7e\xc7\xc7\xf6\xd6\xa4\x9e\x06\xe9\x5f\x60\x96\x9e\x31\x2b\xda\xbf" "\xc0\x29\xd2\xcf\xf6\xb2\xb4\x62\x53\x55\xcf\x00\x96\x66\xd3\xa4\xcb" "\x26\x2c\x42\x1d\x98\x9d\x87\x8f\xe2\x40\xe7\xb4\x34\x05\xa8\x89\x19" "\x5b\x1c\xfc\x34\x5f\x66\xc6\x72\x93\x05\x09\x37\xc9\x99\x35\x90\x90" "\x8f\x98\x73\x70\xda\xd3\xc6\x8d\x30\x44\x6a\x46\x49\x0f\xc0\x17\x92" "\xf4\x2b\xa8\x29\x68\xf9\x1e\x34\xa7\x5e\x7e\x3c\x26\x50\xdf\x60\xe8" "\x00\x00\x00\x00\x00\x00\x00\x00\x00", 689); syscall(__NR_write, -1, 0x200002c0, 0x2b1); break; case 9: memcpy((void*)0x20000640, "\x8b\x43\x9a\x9f\xea\x1e\x54\x9f\xce\x25\x3b\x70\x0f", 13); *(uint64_t*)0x20664fc0 = 0; *(uint64_t*)0x20664fc8 = 1; *(uint64_t*)0x20664fd0 = 9; *(uint64_t*)0x20664fd8 = 0; *(uint64_t*)0x20664fe0 = 0x10000000000000; *(uint64_t*)0x20664fe8 = 0; *(uint64_t*)0x20664ff0 = 0; *(uint64_t*)0x20664ff8 = 0; syscall(__NR_mq_open, 0x20000640, 0x6e93ebbbcc0884f2, 0, 0x20664fc0); break; case 10: syscall(__NR_mmap, 0x20000000, 0xe7e000, 3, 0x31, -1, 0); break; case 11: syscall(__NR_ustat, 7, 0x20000080); break; case 12: memcpy((void*)0x20000000, "user", 5); *(uint8_t*)0x20000040 = 0x73; *(uint8_t*)0x20000041 = 0x79; *(uint8_t*)0x20000042 = 0x7a; *(uint8_t*)0x20000043 = 0x23; *(uint8_t*)0x20000044 = 0; syscall(__NR_add_key, 0x20000000, 0x20000040, 0x20000080, 0, 0); break; case 13: syscall(__NR_socket, 0xa, 2, 0); break; case 14: res = syscall(__NR_socket, 0x18, 1, 1); if (res != -1) r[0] = res; break; case 15: *(uint32_t*)0x20000140 = 0; *(uint32_t*)0x20000144 = 0xde3; *(uint32_t*)0x20000148 = 0x400; *(uint32_t*)0x2000014c = 5; *(uint32_t*)0x200005c0 = 0x10; syscall(__NR_getsockopt, r[0], 0x84, 0, 0x20000140, 0x200005c0); break; } } void execute_one() { execute(16); } int main() { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); char* cwd = get_current_dir_name(); for (;;) { if (chdir(cwd)) fail("failed to chdir"); use_temporary_dir(); int pid = do_sandbox_namespace(); int status = 0; while (waitpid(pid, &status, __WALL) != pid) { } } }