| // possible deadlock in perf_trace_init |
| // https://syzkaller.appspot.com/bug?id=1b5b608011e71ffbba62f5686c2c7682c8371383 |
| // status:invalid |
| // autogenerated by syzkaller (http://github.com/google/syzkaller) |
| |
| #define _GNU_SOURCE |
| |
| #include <arpa/inet.h> |
| #include <errno.h> |
| #include <fcntl.h> |
| #include <linux/capability.h> |
| #include <linux/if.h> |
| #include <linux/if_ether.h> |
| #include <linux/if_tun.h> |
| #include <linux/ip.h> |
| #include <linux/tcp.h> |
| #include <net/if_arp.h> |
| #include <pthread.h> |
| #include <sched.h> |
| #include <setjmp.h> |
| #include <signal.h> |
| #include <stdarg.h> |
| #include <stdbool.h> |
| #include <stdint.h> |
| #include <stdio.h> |
| #include <stdlib.h> |
| #include <string.h> |
| #include <sys/ioctl.h> |
| #include <sys/mman.h> |
| #include <sys/mount.h> |
| #include <sys/prctl.h> |
| #include <sys/resource.h> |
| #include <sys/stat.h> |
| #include <sys/syscall.h> |
| #include <sys/time.h> |
| #include <sys/wait.h> |
| #include <unistd.h> |
| |
| 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); |
| } |
| |
| 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 uintptr_t syz_open_dev(uintptr_t a0, uintptr_t a1, uintptr_t a2) |
| { |
| if (a0 == 0xc || a0 == 0xb) { |
| char buf[128]; |
| sprintf(buf, "/dev/%s/%d:%d", a0 == 0xc ? "char" : "block", |
| (uint8_t)a1, (uint8_t)a2); |
| return open(buf, O_RDWR, 0); |
| } else { |
| char buf[1024]; |
| char* hash; |
| NONFAILING(strncpy(buf, (char*)a0, sizeof(buf))); |
| buf[sizeof(buf) - 1] = 0; |
| while ((hash = strchr(buf, '#'))) { |
| *hash = '0' + (char)(a1 % 10); |
| a1 /= 10; |
| } |
| return open(buf, a2, 0); |
| } |
| } |
| |
| 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); |
| } |
| |
| long r[164]; |
| void* thr(void* arg) |
| { |
| switch ((long)arg) { |
| case 0: |
| r[0] = syscall(__NR_getpgrp, 0xfffffffffffffffful); |
| break; |
| case 1: |
| NONFAILING(*(uint32_t*)0x20c00f88 = (uint32_t)0x2); |
| NONFAILING(*(uint32_t*)0x20c00f8c = (uint32_t)0x78); |
| NONFAILING(*(uint8_t*)0x20c00f90 = (uint8_t)0xdf); |
| NONFAILING(*(uint8_t*)0x20c00f91 = (uint8_t)0x0); |
| NONFAILING(*(uint8_t*)0x20c00f92 = (uint8_t)0x0); |
| NONFAILING(*(uint8_t*)0x20c00f93 = (uint8_t)0x100000000); |
| NONFAILING(*(uint32_t*)0x20c00f94 = (uint32_t)0x0); |
| NONFAILING(*(uint64_t*)0x20c00f98 = (uint64_t)0x7f); |
| NONFAILING(*(uint64_t*)0x20c00fa0 = (uint64_t)0x0); |
| NONFAILING(*(uint64_t*)0x20c00fa8 = (uint64_t)0x0); |
| NONFAILING(*(uint8_t*)0x20c00fb0 = (uint8_t)0xfe); |
| NONFAILING(*(uint8_t*)0x20c00fb1 = (uint8_t)0x2); |
| NONFAILING(*(uint8_t*)0x20c00fb2 = (uint8_t)0x0); |
| NONFAILING(*(uint8_t*)0x20c00fb3 = (uint8_t)0x0); |
| NONFAILING(*(uint32_t*)0x20c00fb4 = (uint32_t)0x0); |
| NONFAILING(*(uint32_t*)0x20c00fb8 = (uint32_t)0x40000000000000); |
| NONFAILING(*(uint32_t*)0x20c00fbc = (uint32_t)0x1); |
| NONFAILING(*(uint64_t*)0x20c00fc0 = (uint64_t)0x0); |
| NONFAILING(*(uint64_t*)0x20c00fc8 = (uint64_t)0x0); |
| NONFAILING(*(uint64_t*)0x20c00fd0 = (uint64_t)0x0); |
| NONFAILING(*(uint64_t*)0x20c00fd8 = (uint64_t)0x0); |
| NONFAILING(*(uint64_t*)0x20c00fe0 = (uint64_t)0x0); |
| NONFAILING(*(uint32_t*)0x20c00fe8 = (uint32_t)0x0); |
| NONFAILING(*(uint64_t*)0x20c00ff0 = (uint64_t)0x0); |
| NONFAILING(*(uint32_t*)0x20c00ff8 = (uint32_t)0x0); |
| NONFAILING(*(uint16_t*)0x20c00ffc = (uint16_t)0x0); |
| NONFAILING(*(uint16_t*)0x20c00ffe = (uint16_t)0x0); |
| r[28] = syscall(__NR_perf_event_open, 0x20c00f88ul, r[0], |
| 0xfffffffffffffffful, 0xfffffffffffffffful, 0x0ul); |
| break; |
| case 2: |
| NONFAILING(memcpy((void*)0x207c1ff0, |
| "\x2f\x64\x65\x76\x2f\x69\x6e\x70\x75\x74\x2f\x6d" |
| "\x69\x63\x65\x00", |
| 16)); |
| r[30] = syz_open_dev(0x207c1ff0ul, 0x0ul, 0x4004005ul); |
| break; |
| case 3: |
| r[31] = syscall(__NR_gettid); |
| break; |
| case 4: |
| r[32] = syscall(__NR_semget, 0x798e2633ul, 0x2ul, 0x270ul); |
| break; |
| case 5: |
| r[33] = syscall(__NR_semctl, r[32], 0x0ul, 0x3ul, 0x201b6fa5ul); |
| break; |
| case 6: |
| NONFAILING(*(uint32_t*)0x20f7dffc = (uint32_t)0xb); |
| r[35] = syscall(__NR_getsockopt, 0xfffffffffffffffful, 0x84ul, |
| 0xbul, 0x20fde000ul, 0x20f7dffcul); |
| break; |
| case 7: |
| r[36] = syscall(__NR_mmap, 0x20000000ul, 0x1000ul, 0x3ul, 0x32ul, |
| 0xfffffffffffffffful, 0x0ul); |
| break; |
| case 8: |
| r[37] = syscall(__NR_geteuid); |
| break; |
| case 9: |
| NONFAILING(memcpy((void*)0x2049aff8, |
| "\x2e\x2f\x66\x69\x6c\x65\x30\x00", 8)); |
| r[39] = syscall(__NR_lstat, 0x2049aff8ul, 0x2028bfbcul); |
| break; |
| case 10: |
| r[40] = |
| syscall(__NR_fcntl, 0xfffffffffffffffful, 0x10ul, 0x20a39ff8ul); |
| break; |
| case 11: |
| r[41] = syscall(__NR_socket, 0x1aul, 0x3ul, 0x0ul); |
| break; |
| case 12: |
| NONFAILING(*(uint32_t*)0x20a4b000 = (uint32_t)0x0); |
| NONFAILING(*(uint16_t*)0x20a4b004 = (uint16_t)0x9); |
| NONFAILING(*(uint16_t*)0x20a4b006 = (uint16_t)0x0); |
| r[45] = syscall(__NR_setsockopt, 0xfffffffffffffffful, 0x84ul, |
| 0x17ul, 0x20a4b000ul, 0x8ul); |
| break; |
| case 13: |
| NONFAILING(*(uint64_t*)0x207fafc8 = (uint64_t)0x0); |
| NONFAILING(*(uint32_t*)0x207fafd0 = (uint32_t)0x0); |
| NONFAILING(*(uint64_t*)0x207fafd8 = (uint64_t)0x20941fc0); |
| NONFAILING(*(uint64_t*)0x207fafe0 = (uint64_t)0x4); |
| NONFAILING(*(uint64_t*)0x207fafe8 = (uint64_t)0x20941fb8); |
| NONFAILING(*(uint64_t*)0x207faff0 = (uint64_t)0x0); |
| NONFAILING(*(uint32_t*)0x207faff8 = (uint32_t)0x40); |
| NONFAILING(*(uint64_t*)0x20941fc0 = (uint64_t)0x2050c000); |
| NONFAILING(*(uint64_t*)0x20941fc8 = (uint64_t)0x0); |
| NONFAILING(*(uint64_t*)0x20941fd0 = (uint64_t)0x2036af52); |
| NONFAILING(*(uint64_t*)0x20941fd8 = (uint64_t)0x0); |
| NONFAILING(*(uint64_t*)0x20941fe0 = (uint64_t)0x20877f9f); |
| NONFAILING(*(uint64_t*)0x20941fe8 = (uint64_t)0x0); |
| NONFAILING(*(uint64_t*)0x20941ff0 = (uint64_t)0x2020f000); |
| NONFAILING(*(uint64_t*)0x20941ff8 = (uint64_t)0x0); |
| r[61] = syscall(__NR_sendmsg, 0xfffffffffffffffful, 0x207fafc8ul, |
| 0x80ul); |
| break; |
| case 14: |
| r[62] = syscall(__NR_ioctl, 0xfffffffffffffffful, 0x4c00ul, |
| 0xfffffffffffffffful); |
| break; |
| case 15: |
| r[63] = syscall(__NR_mmap, 0x20000000ul, 0xfff000ul, 0x3ul, 0x32ul, |
| 0xfffffffffffffffful, 0x0ul); |
| break; |
| case 16: |
| NONFAILING(memcpy((void*)0x2000cff8, |
| "\x2e\x2f\x66\x69\x6c\x65\x30\x00", 8)); |
| r[65] = syscall(__NR_openat, 0xffffffffffffff9cul, 0x2000cff8ul, |
| 0x1ul, 0x49ul); |
| break; |
| case 17: |
| NONFAILING(*(uint32_t*)0x20828f0c = (uint32_t)0x0); |
| NONFAILING(*(uint32_t*)0x20828f10 = (uint32_t)0x0); |
| NONFAILING(*(uint32_t*)0x20743000 = (uint32_t)0x8); |
| r[69] = syscall(__NR_getsockopt, 0xfffffffffffffffful, 0x84ul, |
| 0x1aul, 0x20828f0cul, 0x20743000ul); |
| break; |
| case 18: |
| NONFAILING(*(uint32_t*)0x20475ffc = (uint32_t)0x2); |
| r[71] = syscall(__NR_ioctl, 0xfffffffffffffffful, 0x400454cdul, |
| 0x20475ffcul); |
| break; |
| case 19: |
| r[72] = syscall(__NR_prctl, 0x4ul, 0x1ul); |
| break; |
| case 20: |
| NONFAILING( |
| memcpy((void*)0x20c59000, "\x7a\x6e\x6c\x00\x07\x00\x25", 7)); |
| r[74] = syscall(__NR_prctl, 0xful, 0x20c59000ul); |
| break; |
| case 21: |
| r[75] = syscall(__NR_pipe, 0x20a28ff8ul); |
| if (r[75] != -1) |
| NONFAILING(r[76] = *(uint32_t*)0x20a28ff8); |
| if (r[75] != -1) |
| NONFAILING(r[77] = *(uint32_t*)0x20a28ffc); |
| break; |
| case 22: |
| NONFAILING(memcpy((void*)0x20ed2000, |
| "\x2f\x64\x65\x76\x2f\x76\x63\x73\x23\x00", 10)); |
| r[79] = syz_open_dev(0x20ed2000ul, 0x10001ul, 0x3fdul); |
| break; |
| case 23: |
| NONFAILING(*(uint32_t*)0x20fa0000 = (uint32_t)0x2); |
| NONFAILING(*(uint32_t*)0x20fa0004 = (uint32_t)0x78); |
| NONFAILING(*(uint8_t*)0x20fa0008 = (uint8_t)0xde); |
| NONFAILING(*(uint8_t*)0x20fa0009 = (uint8_t)0x0); |
| NONFAILING(*(uint8_t*)0x20fa000a = (uint8_t)0x0); |
| NONFAILING(*(uint8_t*)0x20fa000b = (uint8_t)0x0); |
| NONFAILING(*(uint32_t*)0x20fa000c = (uint32_t)0x0); |
| NONFAILING(*(uint64_t*)0x20fa0010 = (uint64_t)0x0); |
| NONFAILING(*(uint64_t*)0x20fa0018 = (uint64_t)0x0); |
| NONFAILING(*(uint64_t*)0x20fa0020 = (uint64_t)0x0); |
| NONFAILING(*(uint8_t*)0x20fa0028 = (uint8_t)0xfe); |
| NONFAILING(*(uint8_t*)0x20fa0029 = (uint8_t)0x0); |
| NONFAILING(*(uint8_t*)0x20fa002a = (uint8_t)0x0); |
| NONFAILING(*(uint8_t*)0x20fa002b = (uint8_t)0x0); |
| NONFAILING(*(uint32_t*)0x20fa002c = (uint32_t)0x0); |
| NONFAILING(*(uint32_t*)0x20fa0030 = (uint32_t)0x0); |
| NONFAILING(*(uint32_t*)0x20fa0034 = (uint32_t)0x0); |
| NONFAILING(*(uint64_t*)0x20fa0038 = (uint64_t)0x0); |
| NONFAILING(*(uint64_t*)0x20fa0040 = (uint64_t)0x0); |
| NONFAILING(*(uint64_t*)0x20fa0048 = (uint64_t)0x0); |
| NONFAILING(*(uint64_t*)0x20fa0050 = (uint64_t)0x0); |
| NONFAILING(*(uint64_t*)0x20fa0058 = (uint64_t)0x0); |
| NONFAILING(*(uint32_t*)0x20fa0060 = (uint32_t)0x0); |
| NONFAILING(*(uint64_t*)0x20fa0068 = (uint64_t)0x0); |
| NONFAILING(*(uint32_t*)0x20fa0070 = (uint32_t)0x0); |
| NONFAILING(*(uint16_t*)0x20fa0074 = (uint16_t)0x0); |
| NONFAILING(*(uint16_t*)0x20fa0076 = (uint16_t)0x0); |
| r[107] = syscall(__NR_perf_event_open, 0x20fa0000ul, 0x0ul, |
| 0xfffffffffffffffful, 0xfffffffffffffffful, 0x0ul); |
| break; |
| case 24: |
| r[108] = syscall(__NR_ioctl, 0xfffffffffffffffful, 0x8903ul, |
| 0x20537ffcul); |
| if (r[108] != -1) |
| NONFAILING(r[109] = *(uint32_t*)0x20537ffc); |
| break; |
| case 25: |
| NONFAILING(*(uint32_t*)0x20da1000 = r[109]); |
| r[111] = syscall(__NR_ioctl, 0xfffffffffffffffful, 0x540ful, |
| 0x20da1000ul); |
| break; |
| case 26: |
| NONFAILING(memcpy((void*)0x204ab000, |
| "\x2f\x64\x65\x76\x2f\x73\x65\x71\x75\x65\x6e\x63" |
| "\x65\x72\x32\x00", |
| 16)); |
| r[113] = syscall(__NR_openat, 0xffffffffffffff9cul, 0x204ab000ul, |
| 0x7ffful, 0x0ul); |
| break; |
| case 27: |
| r[114] = syscall(__NR_socket, 0x1ful, 0xffffffdffffffffcul, 0x3ul); |
| break; |
| case 28: |
| r[115] = syscall(__NR_socket, 0xaul, 0x803ul, 0xfful); |
| break; |
| case 29: |
| NONFAILING(*(uint64_t*)0x20a0cfc0 = (uint64_t)0x20569f80); |
| NONFAILING(*(uint32_t*)0x20a0cfc8 = (uint32_t)0x80); |
| NONFAILING(*(uint64_t*)0x20a0cfd0 = (uint64_t)0x200ea000); |
| NONFAILING(*(uint64_t*)0x20a0cfd8 = (uint64_t)0x6); |
| NONFAILING(*(uint64_t*)0x20a0cfe0 = (uint64_t)0x20acb000); |
| NONFAILING(*(uint64_t*)0x20a0cfe8 = (uint64_t)0x6); |
| NONFAILING(*(uint32_t*)0x20a0cff0 = (uint32_t)0xfffffffffffffffe); |
| NONFAILING(*(uint32_t*)0x20a0cff8 = (uint32_t)0x0); |
| NONFAILING(*(uint16_t*)0x20569f80 = (uint16_t)0x0); |
| NONFAILING(memcpy( |
| (void*)0x20569f82, |
| "\x00\xff\xee\x00\x00\x00\x85\xb0\xc5\xf5\xe0\x3a\x4b\xa9\x41" |
| "\x87\xe3\x0d\x9d\x72\x0c\x5a\x4d\xf7\xc7\xce\x04\x54\xa4\x43" |
| "\x16\xf6\xb7\xb5\x3d\x2e\x1c\x3e\xec\xa7\x90\x0c\xfc\x36\xc6" |
| "\x70\x2c\xe6\x27\xb4\x2d\xce\xb5\xd7\x43\x0c\x8e\x34\x8d\xa4" |
| "\x38\x71\x6f\x77\x92\x9a\x21\xcc\xc6\x64\xe4\x58\x82\x10\x7d" |
| "\x80\x9f\xb9\x38\xfb\x85\x71\x2a\x77\x85\x89\x8c\x35\x7f\x82" |
| "\x86\xca\xf7\x08\x27\x5e\x38\x40\xca\xa8\x3d\x01\x3e\x19\xac" |
| "\xbf\xd3\x57\x80\xfb\x56\xbd\x41\x2f\x4d\x80\x3c\x17\x6a\x77" |
| "\x47\x25\x9d\x28\xad\xb2", |
| 126)); |
| NONFAILING(*(uint64_t*)0x200ea000 = (uint64_t)0x208c6000); |
| NONFAILING(*(uint64_t*)0x200ea008 = (uint64_t)0x0); |
| NONFAILING(*(uint64_t*)0x200ea010 = (uint64_t)0x20e5e000); |
| NONFAILING(*(uint64_t*)0x200ea018 = (uint64_t)0x0); |
| NONFAILING(*(uint64_t*)0x200ea020 = (uint64_t)0x20088000); |
| NONFAILING(*(uint64_t*)0x200ea028 = (uint64_t)0x0); |
| NONFAILING(*(uint64_t*)0x200ea030 = (uint64_t)0x20b13f67); |
| NONFAILING(*(uint64_t*)0x200ea038 = (uint64_t)0x0); |
| NONFAILING(*(uint64_t*)0x200ea040 = (uint64_t)0x2034d000); |
| NONFAILING(*(uint64_t*)0x200ea048 = (uint64_t)0x0); |
| NONFAILING(*(uint64_t*)0x200ea050 = (uint64_t)0x20c5df36); |
| NONFAILING(*(uint64_t*)0x200ea058 = (uint64_t)0xca); |
| NONFAILING(memcpy( |
| (void*)0x20c5df36, |
| "\xeb\x5a\x3c\x58\x06\x4f\x31\x27\xd5\x21\xad\x82\xec\xb6\x1e" |
| "\xa6\xf3\x6d\xbd\x06\xa3\xdb\x4f\x4a\xa4\x60\x9a\x8a\x8b\x6e" |
| "\x60\x6c\x88\x9b\xe3\x72\x7e\x5e\xf5\x65\x5e\xea\x19\x94\x03" |
| "\xbe\x8e\x92\x48\x09\xe6\x3b\xbf\x04\x66\x55\x95\x98\x7e\xd4" |
| "\xe4\x73\x13\x18\x42\xc6\xe4\x5c\x97\xad\x54\x5a\xae\x7e\xf4" |
| "\x7e\x18\x05\xc6\xd1\x22\x4c\xe8\xf0\xac\x2d\x42\x94\xc0\x66" |
| "\x06\xee\xe2\x68\x83\x0a\x73\x0f\x2f\x0f\x69\xf1\x57\x91\x48" |
| "\x26\xca\x57\xa3\xd4\xfb\x61\xd0\x3c\x5e\x5a\x08\x1c\x0b\x28" |
| "\xa1\x89\x82\x28\x0b\x3f\x3d\x7e\x42\x3b\x81\xdf\x4d\x14\x4d" |
| "\x1a\x6b\xff\xc7\xee\xca\x03\xcc\xad\x35\x5e\x43\xef\xc0\xfe" |
| "\x53\xa8\x34\xa8\x44\x07\x26\x11\xa3\xb3\x55\xf8\x19\x8f\xf3" |
| "\x50\xe9\x8a\x9a\x65\x6b\x89\x51\xef\x10\xc5\xa9\x90\x8a\x9f" |
| "\x35\xee\xe9\xc5\x24\x3a\x26\x05\xc4\xb9\x47\x1b\x18\x0a\xd6" |
| "\x1b\xfc\x2c\x5e\xbd\xa8\x8f", |
| 202)); |
| NONFAILING(*(uint64_t*)0x20acb000 = (uint64_t)0x10); |
| NONFAILING(*(uint32_t*)0x20acb008 = (uint32_t)0x110); |
| NONFAILING(*(uint32_t*)0x20acb00c = (uint32_t)0x0); |
| NONFAILING(*(uint64_t*)0x20acb010 = (uint64_t)0x10); |
| NONFAILING(*(uint32_t*)0x20acb018 = (uint32_t)0x115); |
| NONFAILING(*(uint32_t*)0x20acb01c = (uint32_t)0x77f); |
| NONFAILING(*(uint64_t*)0x20acb020 = (uint64_t)0x10); |
| NONFAILING(*(uint32_t*)0x20acb028 = (uint32_t)0x11c); |
| NONFAILING(*(uint32_t*)0x20acb02c = (uint32_t)0x1); |
| NONFAILING(*(uint64_t*)0x20acb030 = (uint64_t)0x10); |
| NONFAILING(*(uint32_t*)0x20acb038 = (uint32_t)0x115); |
| NONFAILING(*(uint32_t*)0x20acb03c = (uint32_t)0xf2); |
| NONFAILING(*(uint64_t*)0x20acb040 = (uint64_t)0xe0); |
| NONFAILING(*(uint32_t*)0x20acb048 = (uint32_t)0x114); |
| NONFAILING(*(uint32_t*)0x20acb04c = (uint32_t)0x9); |
| NONFAILING(memcpy( |
| (void*)0x20acb050, |
| "\xee\xc5\x66\x16\x01\x04\x49\xba\xc5\xb4\x44\x78\x81\x8a\xe2" |
| "\x90\x1b\x89\x31\xb8\xcd\x82\x86\xee\x57\xca\xcd\x34\xfe\xe5" |
| "\x4f\x7a\x19\xc2\x06\xbd\xa9\x9e\x55\x2a\x31\xf9\xdd\x47\x43" |
| "\x37\x75\xcb\x89\x3a\x56\x77\x71\x62\x1b\x99\x4d\xee\xdc\x2b" |
| "\xf3\xe6\x7f\xd8\xf3\x30\xc2\x77\x38\xf6\x45\xc6\x8f\x22\xb9" |
| "\xb4\x81\xf1\x5b\xc5\x74\xbc\x58\x11\x4e\x6e\xc9\xa8\x4b\xcb" |
| "\x5f\xd6\x63\x84\x8e\x90\xa5\x3f\x47\xcd\x46\x2d\x96\xa3\x3d" |
| "\xa2\xf0\x80\xf1\x40\x54\x6e\x26\xc5\x69\x78\x1e\x7c\xdd\x13" |
| "\x0c\x0b\x99\x38\x7c\x27\x11\x20\x66\xa9\x3e\x9c\x9b\xc2\xd9" |
| "\x5d\xfe\x2e\x6b\x61\xbb\xa8\x84\xe2\xf0\xb3\x6c\x69\x60\x49" |
| "\xe8\x2e\x49\xb2\xad\x26\x17\x9c\xd7\x6c\x7f\x5c\xbc\x06\x9a" |
| "\x7d\x31\xad\xd4\x8b\x57\xe8\x98\xc0\x19\x3f\xa4\xbf\x15\xe2" |
| "\x9e\xb6\x5b\xa3\x24\xc5\xd3\x79\xc4\xdd\xc0\x03\x85\xb5\xb9" |
| "\xe2\x2c\xc0\xe2\xbc\xd3", |
| 201)); |
| NONFAILING(*(uint64_t*)0x20acb120 = (uint64_t)0x10); |
| NONFAILING(*(uint32_t*)0x20acb128 = (uint32_t)0x0); |
| NONFAILING(*(uint32_t*)0x20acb12c = (uint32_t)0x2); |
| r[158] = syscall(__NR_sendmmsg, r[115], 0x20a0cfc0ul, 0x1ul, 0x0ul); |
| break; |
| case 30: |
| r[159] = syscall(__NR_splice, r[107], 0x0ul, r[77], 0x0ul, |
| 0x100000000ul, 0x4ul); |
| break; |
| case 31: |
| r[160] = syscall(__NR_splice, r[76], 0x0ul, r[79], 0x800000ul, |
| 0xfffffdfful, 0x0ul); |
| break; |
| case 32: |
| r[161] = syscall(__NR_socket, 0x1ful, 0x3ul, 0x4ul); |
| break; |
| case 33: |
| NONFAILING(memcpy((void*)0x20007ff7, |
| "\x2f\x64\x65\x76\x2f\x73\x67\x23\x00", 9)); |
| r[163] = syz_open_dev(0x20007ff7ul, 0x0ul, 0x0ul); |
| break; |
| } |
| return 0; |
| } |
| |
| void loop() |
| { |
| long i; |
| pthread_t th[68]; |
| |
| memset(r, -1, sizeof(r)); |
| srand(getpid()); |
| for (i = 0; i < 34; i++) { |
| pthread_create(&th[i], 0, thr, (void*)i); |
| usleep(rand() % 10000); |
| } |
| for (i = 0; i < 34; i++) { |
| pthread_create(&th[34 + i], 0, thr, (void*)i); |
| if (rand() % 2) |
| usleep(rand() % 10000); |
| } |
| usleep(rand() % 100000); |
| } |
| |
| int main() |
| { |
| install_segv_handler(); |
| use_temporary_dir(); |
| int pid = do_sandbox_namespace(0, true); |
| int status = 0; |
| while (waitpid(pid, &status, __WALL) != pid) { |
| } |
| return 0; |
| } |