// https://syzkaller.appspot.com/bug?id=bff61d87129afb198021fa0a2d4d09706a14ada8 // 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 const int kFailStatus = 67; const int kRetryStatus = 69; __attribute__((noreturn)) static void doexit(int status) { volatile unsigned i; syscall(__NR_exit_group, status); for (i = 0;; i++) { } } __attribute__((noreturn)) static void fail(const char* msg, ...) { int e = errno; fflush(stdout); 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); } __attribute__((noreturn)) static void exitf(const char* msg, ...) { int e = errno; fflush(stdout); va_list args; va_start(args, msg); vfprintf(stderr, msg, args); va_end(args); fprintf(stderr, " (errno %d)\n", e); doexit(kRetryStatus); } static __thread int skip_segv; static __thread jmp_buf segv_env; static void segv_handler(int sig, siginfo_t* info, void* uctx) { uintptr_t addr = (uintptr_t)info->si_addr; const uintptr_t prog_start = 1 << 20; const uintptr_t prog_end = 100 << 20; if (__atomic_load_n(&skip_segv, __ATOMIC_RELAXED) && (addr < prog_start || addr > prog_end)) { _longjmp(segv_env, 1); } doexit(sig); for (;;) { } } static void install_segv_handler() { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = SIG_IGN; syscall(SYS_rt_sigaction, 0x20, &sa, NULL, 8); syscall(SYS_rt_sigaction, 0x21, &sa, NULL, 8); memset(&sa, 0, sizeof(sa)); sa.sa_sigaction = segv_handler; sa.sa_flags = SA_NODEFER | SA_SIGINFO; sigaction(SIGSEGV, &sa, NULL); sigaction(SIGBUS, &sa, NULL); } #define NONFAILING(...) \ { \ __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); \ if (_setjmp(segv_env) == 0) { \ __VA_ARGS__; \ } \ __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); \ } 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); } 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); } #define COMMAND_MAX_LEN 128 static void execute_command(const char* format, ...) { va_list args; char command[COMMAND_MAX_LEN]; int rv; va_start(args, format); vsnprintf_check(command, sizeof(command), format, args); rv = system(command); if (rv != 0) fail("tun: command \"%s\" failed with code %d", &command[0], rv); va_end(args); } static int tunfd = -1; #define SYZ_TUN_MAX_PACKET_SIZE 1000 #define MAX_PIDS 32 #define ADDR_MAX_LEN 32 #define LOCAL_MAC "aa:aa:aa:aa:aa:%02hx" #define REMOTE_MAC "bb:bb:bb:bb:bb:%02hx" #define LOCAL_IPV4 "172.20.%d.170" #define REMOTE_IPV4 "172.20.%d.187" #define LOCAL_IPV6 "fe80::%02hxaa" #define REMOTE_IPV6 "fe80::%02hxbb" static void initialize_tun(uint64_t pid) { if (pid >= MAX_PIDS) fail("tun: no more than %d executors", MAX_PIDS); int id = pid; tunfd = open("/dev/net/tun", O_RDWR | O_NONBLOCK); if (tunfd == -1) fail("tun: can't open /dev/net/tun"); char iface[IFNAMSIZ]; snprintf_check(iface, sizeof(iface), "syz%d", id); struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, iface, IFNAMSIZ); ifr.ifr_flags = IFF_TAP | IFF_NO_PI; if (ioctl(tunfd, TUNSETIFF, (void*)&ifr) < 0) fail("tun: ioctl(TUNSETIFF) failed"); char local_mac[ADDR_MAX_LEN]; snprintf_check(local_mac, sizeof(local_mac), LOCAL_MAC, id); char remote_mac[ADDR_MAX_LEN]; snprintf_check(remote_mac, sizeof(remote_mac), REMOTE_MAC, id); char local_ipv4[ADDR_MAX_LEN]; snprintf_check(local_ipv4, sizeof(local_ipv4), LOCAL_IPV4, id); char remote_ipv4[ADDR_MAX_LEN]; snprintf_check(remote_ipv4, sizeof(remote_ipv4), REMOTE_IPV4, id); char local_ipv6[ADDR_MAX_LEN]; snprintf_check(local_ipv6, sizeof(local_ipv6), LOCAL_IPV6, id); char remote_ipv6[ADDR_MAX_LEN]; snprintf_check(remote_ipv6, sizeof(remote_ipv6), REMOTE_IPV6, id); execute_command("sysctl -w net.ipv6.conf.%s.accept_dad=0", iface); execute_command("sysctl -w net.ipv6.conf.%s.router_solicitations=0", iface); execute_command("ip link set dev %s address %s", iface, local_mac); execute_command("ip addr add %s/24 dev %s", local_ipv4, iface); execute_command("ip -6 addr add %s/120 dev %s", local_ipv6, iface); execute_command("ip neigh add %s lladdr %s dev %s nud permanent", remote_ipv4, remote_mac, iface); execute_command("ip -6 neigh add %s lladdr %s dev %s nud permanent", remote_ipv6, remote_mac, iface); execute_command("ip link set dev %s up", iface); } static void setup_tun(uint64_t pid, bool enable_tun) { if (enable_tun) initialize_tun(pid); } static int read_tun(char* data, int size) { int rv = read(tunfd, data, size); if (rv < 0) { if (errno == EAGAIN) return -1; fail("tun: read failed with %d, errno: %d", rv, errno); } return rv; } static void flush_tun() { char data[SYZ_TUN_MAX_PACKET_SIZE]; while (read_tun(&data[0], sizeof(data)) != -1) ; } 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 = 128 << 20; setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 8 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 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); unshare(CLONE_NEWNS); unshare(CLONE_NEWIPC); unshare(CLONE_IO); } 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) { close(fd); return false; } close(fd); return true; } static int real_uid; static int real_gid; static int epid; static bool etun; __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"); setup_tun(epid, etun); 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"); if (mount("/dev", "./syz-tmp/newroot/dev", NULL, MS_BIND | MS_REC | MS_PRIVATE, 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/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(int executor_pid, bool enable_tun) { real_uid = getuid(); real_gid = getgid(); epid = executor_pid; etun = enable_tun; mprotect(sandbox_stack, 4096, PROT_NONE); return clone( namespace_sandbox_proc, &sandbox_stack[sizeof(sandbox_stack) - 64], CLONE_NEWUSER | CLONE_NEWPID | CLONE_NEWUTS | CLONE_NEWNET, NULL); } static void remove_dir(const char* dir) { DIR* dp; struct dirent* ep; int iter = 0; retry: dp = opendir(dir); if (dp == NULL) { if (errno == EMFILE) { exitf("opendir(%s) failed due to NOFILE, exiting"); } 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 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 test(); void loop() { int iter; for (iter = 0;; iter++) { char cwdbuf[256]; 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"); flush_tun(); test(); 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 > 5 * 1000) { kill(-pid, SIGKILL); kill(pid, SIGKILL); while (waitpid(-1, &status, __WALL) != pid) { } break; } } remove_dir(cwdbuf); } } long r[93]; void* thr(void* arg) { switch ((long)arg) { case 0: r[0] = syscall(__NR_mmap, 0x20000000ul, 0xfff000ul, 0x3ul, 0x32ul, 0xfffffffffffffffful, 0x0ul); break; case 1: r[1] = syscall(__NR_socket, 0x26ul, 0x5ul, 0x0ul); break; case 2: NONFAILING(*(uint64_t*)0x204cf000 = (uint64_t)0x20761000); NONFAILING(*(uint32_t*)0x204cf008 = (uint32_t)0x8); NONFAILING(*(uint64_t*)0x204cf010 = (uint64_t)0x20290fb0); NONFAILING(*(uint64_t*)0x204cf018 = (uint64_t)0x5); NONFAILING(*(uint64_t*)0x204cf020 = (uint64_t)0x200fc000); NONFAILING(*(uint64_t*)0x204cf028 = (uint64_t)0x1); NONFAILING(*(uint32_t*)0x204cf030 = (uint32_t)0x40000); NONFAILING(*(uint16_t*)0x20761000 = (uint16_t)0x0); NONFAILING(*(uint8_t*)0x20761002 = (uint8_t)0x0); NONFAILING(*(uint32_t*)0x20761004 = (uint32_t)0x4e21); NONFAILING(*(uint64_t*)0x20290fb0 = (uint64_t)0x20612000); NONFAILING(*(uint64_t*)0x20290fb8 = (uint64_t)0x0); NONFAILING(*(uint64_t*)0x20290fc0 = (uint64_t)0x206c0000); NONFAILING(*(uint64_t*)0x20290fc8 = (uint64_t)0x71); NONFAILING(*(uint64_t*)0x20290fd0 = (uint64_t)0x209cdf36); NONFAILING(*(uint64_t*)0x20290fd8 = (uint64_t)0x0); NONFAILING(*(uint64_t*)0x20290fe0 = (uint64_t)0x20c72fdd); NONFAILING(*(uint64_t*)0x20290fe8 = (uint64_t)0x0); NONFAILING(*(uint64_t*)0x20290ff0 = (uint64_t)0x20eec000); NONFAILING(*(uint64_t*)0x20290ff8 = (uint64_t)0x0); NONFAILING(memcpy( (void*)0x206c0000, "\x0c\x9c\xbb\x10\x51\x76\x0f\xd4\x55\xb2\x7d\xec\xea\x4d\xce" "\x04\x0a\xf5\xb7\xdf\x77\x30\xb3\xbd\xc4\x8b\x6d\x72\x4a\x83" "\x7b\x6b\xd0\x77\x7d\x35\xb9\x33\xaf\x8c\x4c\x9a\xea\xe1\x9f" "\x5c\x23\x1c\xea\x51\x89\xc8\x89\x3b\x72\xe6\xdb\xb5\xc7\x83" "\xa8\x7b\x09\xd7\x2b\x05\x78\xef\x30\xab\x8b\x84\x2f\x68\x3c" "\x20\xb7\xc3\x19\xd9\xb5\x05\xd1\x7f\x01\xb6\x43\x26\xec\x13" "\xad\x24\x26\x6a\xa4\xcf\x82\x86\x48\x66\x15\x63\x0c\xc6\x5e" "\xb4\xe1\xbe\x6c\xd7\x90\xb9\xc2", 113)); NONFAILING(*(uint64_t*)0x200fc000 = (uint64_t)0x20); NONFAILING(*(uint32_t*)0x200fc008 = (uint32_t)0x1); NONFAILING(*(uint32_t*)0x200fc00c = (uint32_t)0x1); NONFAILING(*(uint32_t*)0x200fc010 = (uint32_t)0xffffffffffffffff); NONFAILING(*(uint32_t*)0x200fc014 = (uint32_t)0xffffffffffffffff); NONFAILING(*(uint32_t*)0x200fc018 = (uint32_t)0xffffffffffffffff); r[29] = syscall(__NR_sendmsg, 0xfffffffffffffffful, 0x204cf000ul, 0x10ul); break; case 3: r[30] = syscall(__NR_socket, 0x2ul, 0x1ul, 0x0ul); break; case 4: NONFAILING(*(uint16_t*)0x20a43000 = (uint16_t)0x26); NONFAILING(memcpy( (void*)0x20a43002, "\x73\x6b\x63\x69\x70\x68\x65\x72\x00\x00\x00\x00\x00\x00", 14)); NONFAILING(*(uint32_t*)0x20a43010 = (uint32_t)0x3); NONFAILING(*(uint32_t*)0x20a43014 = (uint32_t)0x6); NONFAILING(memcpy((void*)0x20a43018, "\x63\x74\x72\x28\x63\x61\x6d\x65\x6c\x6c\x69\x61" "\x29\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00", 64)); r[36] = syscall(__NR_bind, r[1], 0x20a43000ul, 0x58ul); break; case 5: NONFAILING(memcpy((void*)0x20161000, "\xde\x77\x28\x5f\xc7\x40\x4f" "\xa5\xcc\x25\x51\x23\xfd\x39" "\x9f\x79\xf3\x25\x35\xd9\x33" "\x1e\x3c\xc2", 24)); r[38] = syscall(__NR_setsockopt, r[1], 0x117ul, 0x1ul, 0x20161000ul, 0x18ul); break; case 6: NONFAILING(*(uint32_t*)0x20786ffc = (uint32_t)0x0); r[40] = syscall(__NR_accept, r[1], 0x20000000ul, 0x20786ffcul); break; case 7: NONFAILING(*(uint64_t*)0x20691000 = (uint64_t)0x0); NONFAILING(*(uint32_t*)0x20691008 = (uint32_t)0x0); NONFAILING(*(uint64_t*)0x20691010 = (uint64_t)0x202d9fa0); NONFAILING(*(uint64_t*)0x20691018 = (uint64_t)0x6); NONFAILING(*(uint64_t*)0x20691020 = (uint64_t)0x20d1d000); NONFAILING(*(uint64_t*)0x20691028 = (uint64_t)0x30); NONFAILING(*(uint32_t*)0x20691030 = (uint32_t)0x81); NONFAILING(*(uint64_t*)0x202d9fa0 = (uint64_t)0x2078984f); NONFAILING(*(uint64_t*)0x202d9fa8 = (uint64_t)0x0); NONFAILING(*(uint64_t*)0x202d9fb0 = (uint64_t)0x206e4000); NONFAILING(*(uint64_t*)0x202d9fb8 = (uint64_t)0x0); NONFAILING(*(uint64_t*)0x202d9fc0 = (uint64_t)0x2044cfc1); NONFAILING(*(uint64_t*)0x202d9fc8 = (uint64_t)0x0); NONFAILING(*(uint64_t*)0x202d9fd0 = (uint64_t)0x20196000); NONFAILING(*(uint64_t*)0x202d9fd8 = (uint64_t)0x0); NONFAILING(*(uint64_t*)0x202d9fe0 = (uint64_t)0x206b2000); NONFAILING(*(uint64_t*)0x202d9fe8 = (uint64_t)0x0); NONFAILING(*(uint64_t*)0x202d9ff0 = (uint64_t)0x20002f24); NONFAILING(*(uint64_t*)0x202d9ff8 = (uint64_t)0xdc); NONFAILING(memcpy( (void*)0x20002f24, "\x9a\x01\xee\x4c\x07\xe0\x9f\xf0\xbb\xd0\x3c\x35\x7f\x15\xf6" "\x59\x69\xd1\x68\x03\xe6\xdb\xfa\xc6\xde\x8d\x98\xbb\xe8\xd0" "\x64\x00\x3e\x95\xd4\xcd\xae\x81\x88\xeb\x1e\xe3\x9c\x41\x5c" "\xc6\x46\x4e\xda\xf9\xb1\x14\xef\xb5\x27\xb6\x23\x8a\x2d\x5f" "\xad\xca\xa9\x19\x67\xfb\x02\xee\x81\x7e\x15\x89\xc3\x75\x8a" "\xe9\x58\x4e\xbe\x4c\x60\x55\x26\x13\xf5\x0f\xcb\x7d\x2b\x39" "\x3b\x4f\x7a\x33\x38\x1a\x6d\xd4\xad\xd2\x0c\xfe\xf8\xd1\x68" "\x9b\xec\x18\xb9\x6b\xab\xd1\x80\xb8\xb2\x46\x13\x7b\x46\xc2" "\x50\x90\xc8\xb4\x0c\xbc\xf0\x80\xb3\x04\x71\xf9\x7f\x79\x30" "\xe9\xa7\xca\xb9\xd1\x42\x4c\x31\x66\x8f\x0b\x1b\x8d\x05\xf3" "\x8d\x09\x21\x80\xba\x86\x4c\xbb\x65\x83\x47\x7a\x8f\x71\x94" "\x5d\x28\x7a\x1c\x07\x28\x23\x18\xc3\x78\x40\x59\x6a\xdc\x0c" "\xcc\x96\x8f\x7c\x4d\x72\x4b\xed\xe0\x21\xf5\xa5\x75\x95\xd4" "\x7e\xf4\x56\x80\xd7\xee\x96\x62\xb9\x79\x0f\xc9\x50\x3a\x1c" "\xe2\x5b\xde\x4f\x18\xdf\x4c\xb4\x01\x79", 220)); NONFAILING(*(uint64_t*)0x20d1d000 = (uint64_t)0x18); NONFAILING(*(uint32_t*)0x20d1d008 = (uint32_t)0x117); NONFAILING(*(uint32_t*)0x20d1d00c = (uint32_t)0x3); NONFAILING(*(uint32_t*)0x20d1d010 = (uint32_t)0x0); NONFAILING(*(uint64_t*)0x20d1d018 = (uint64_t)0x18); NONFAILING(*(uint32_t*)0x20d1d020 = (uint32_t)0x117); NONFAILING(*(uint32_t*)0x20d1d024 = (uint32_t)0x4); NONFAILING(*(uint32_t*)0x20d1d028 = (uint32_t)0x1000); r[69] = syscall(__NR_sendmsg, r[40], 0x20691000ul, 0x0ul); break; case 8: NONFAILING(*(uint64_t*)0x209dffc8 = (uint64_t)0x20000000); NONFAILING(*(uint32_t*)0x209dffd0 = (uint32_t)0x0); NONFAILING(*(uint64_t*)0x209dffd8 = (uint64_t)0x20bdbfc0); NONFAILING(*(uint64_t*)0x209dffe0 = (uint64_t)0x4); NONFAILING(*(uint64_t*)0x209dffe8 = (uint64_t)0x20d7a000); NONFAILING(*(uint64_t*)0x209dfff0 = (uint64_t)0x1000); NONFAILING(*(uint32_t*)0x209dfff8 = (uint32_t)0x2); NONFAILING(*(uint64_t*)0x20bdbfc0 = (uint64_t)0x20fc4f14); NONFAILING(*(uint64_t*)0x20bdbfc8 = (uint64_t)0x0); NONFAILING(*(uint64_t*)0x20bdbfd0 = (uint64_t)0x20d78f9b); NONFAILING(*(uint64_t*)0x20bdbfd8 = (uint64_t)0x0); NONFAILING(*(uint64_t*)0x20bdbfe0 = (uint64_t)0x20672000); NONFAILING(*(uint64_t*)0x20bdbfe8 = (uint64_t)0x0); NONFAILING(*(uint64_t*)0x20bdbff0 = (uint64_t)0x20ec2f46); NONFAILING(*(uint64_t*)0x20bdbff8 = (uint64_t)0xba); r[85] = syscall(__NR_recvmsg, r[40], 0x209dffc8ul, 0x1ul); break; case 9: NONFAILING( memcpy((void*)0x200fbff4, "\x2f\x64\x65\x76\x2f\x72\x66\x6b\x69\x6c\x6c\x00", 12)); r[87] = syscall(__NR_openat, 0xffffffffffffff9cul, 0x200fbff4ul, 0x0ul, 0x0ul); break; case 10: NONFAILING(*(uint32_t*)0x205c1ffc = (uint32_t)0x0); r[89] = syscall(__NR_getsockopt, r[87], 0x21ul, 0xcful, 0x20905000ul, 0x205c1ffcul); break; case 11: NONFAILING(*(uint32_t*)0x20d0affc = (uint32_t)0x0); NONFAILING(*(uint32_t*)0x203f0000 = (uint32_t)0x4); r[92] = syscall(__NR_getsockopt, r[87], 0x103ul, 0x2ul, 0x20d0affcul, 0x203f0000ul); break; } return 0; } void test() { long i; pthread_t th[24]; memset(r, -1, sizeof(r)); srand(getpid()); for (i = 0; i < 12; i++) { pthread_create(&th[i], 0, thr, (void*)i); usleep(rand() % 10000); } for (i = 0; i < 12; i++) { pthread_create(&th[12 + i], 0, thr, (void*)i); if (rand() % 2) usleep(rand() % 10000); } usleep(rand() % 100000); } int main() { int i; for (i = 0; i < 8; i++) { if (fork() == 0) { install_segv_handler(); use_temporary_dir(); int pid = do_sandbox_namespace(i, true); int status = 0; while (waitpid(pid, &status, __WALL) != pid) { } return 0; } } sleep(1000000); return 0; }