// https://syzkaller.appspot.com/bug?id=853bf73c001cbfdeaf7be9bcc67bfd3655e700ea // 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 #include #include #include #include #include #include #include #include #include #include #include #include unsigned long long procid; static __thread int skip_segv; static __thread jmp_buf segv_env; static void segv_handler(int sig, siginfo_t* info, void* ctx) { 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); } 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(...) \ { \ __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 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); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); if (pthread_create(&th, &attr, fn, arg)) exit(1); pthread_attr_destroy(&attr); } typedef struct { int state; } event_t; static void event_init(event_t* ev) { ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { if (ev->state) exit(1); __atomic_store_n(&ev->state, 1, __ATOMIC_RELEASE); syscall(SYS_futex, &ev->state, FUTEX_WAKE | FUTEX_PRIVATE_FLAG); } static void event_wait(event_t* ev) { while (!__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, 0); } static int event_isset(event_t* ev) { return __atomic_load_n(&ev->state, __ATOMIC_ACQUIRE); } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; for (;;) { uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, &ts); if (__atomic_load_n(&ev->state, __ATOMIC_RELAXED)) return 1; now = current_time_ms(); if (now - start > timeout) return 0; } } 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) exit(1); if ((size_t)rv >= size) exit(1); } #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) exit(1); } } 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 = 240; if (dup2(tunfd, kTunFd) < 0) exit(1); 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) exit(1); } if (ioctl(tunfd, TUNGETIFF, (void*)&ifr) < 0) exit(1); tun_frags_enabled = (ifr.ifr_flags & IFF_NAPI_FRAGS) != 0; execute_command(0, "sysctl -w net.ipv6.conf.%s.accept_dad=0", TUN_IFACE); execute_command(0, "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 neigh add %s lladdr %s dev %s nud permanent", REMOTE_IPV4, REMOTE_MAC, TUN_IFACE); execute_command(0, "ip -6 addr add %s/120 dev %s", LOCAL_IPV6, TUN_IFACE); execute_command(0, "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; exit(1); } return rv; } static void flush_tun() { char data[SYZ_TUN_MAX_PACKET_SIZE]; while (read_tun(&data[0], sizeof(data)) != -1) { } } 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 XT_TABLE_SIZE 1536 #define XT_MAX_ENTRIES 10 struct xt_counters { uint64_t pcnt, bcnt; }; struct ipt_getinfo { char name[32]; unsigned int valid_hooks; unsigned int hook_entry[5]; unsigned int underflow[5]; unsigned int num_entries; unsigned int size; }; struct ipt_get_entries { char name[32]; unsigned int size; void* entrytable[XT_TABLE_SIZE / sizeof(void*)]; }; struct ipt_replace { char name[32]; unsigned int valid_hooks; unsigned int num_entries; unsigned int size; unsigned int hook_entry[5]; unsigned int underflow[5]; unsigned int num_counters; struct xt_counters* counters; char entrytable[XT_TABLE_SIZE]; }; struct ipt_table_desc { const char* name; struct ipt_getinfo info; struct ipt_replace replace; }; static struct ipt_table_desc ipv4_tables[] = { {.name = "filter"}, {.name = "nat"}, {.name = "mangle"}, {.name = "raw"}, {.name = "security"}, }; static struct ipt_table_desc ipv6_tables[] = { {.name = "filter"}, {.name = "nat"}, {.name = "mangle"}, {.name = "raw"}, {.name = "security"}, }; #define IPT_BASE_CTL 64 #define IPT_SO_SET_REPLACE (IPT_BASE_CTL) #define IPT_SO_GET_INFO (IPT_BASE_CTL) #define IPT_SO_GET_ENTRIES (IPT_BASE_CTL + 1) struct arpt_getinfo { char name[32]; unsigned int valid_hooks; unsigned int hook_entry[3]; unsigned int underflow[3]; unsigned int num_entries; unsigned int size; }; struct arpt_get_entries { char name[32]; unsigned int size; void* entrytable[XT_TABLE_SIZE / sizeof(void*)]; }; struct arpt_replace { char name[32]; unsigned int valid_hooks; unsigned int num_entries; unsigned int size; unsigned int hook_entry[3]; unsigned int underflow[3]; unsigned int num_counters; struct xt_counters* counters; char entrytable[XT_TABLE_SIZE]; }; struct arpt_table_desc { const char* name; struct arpt_getinfo info; struct arpt_replace replace; }; static struct arpt_table_desc arpt_tables[] = { {.name = "filter"}, }; #define ARPT_BASE_CTL 96 #define ARPT_SO_SET_REPLACE (ARPT_BASE_CTL) #define ARPT_SO_GET_INFO (ARPT_BASE_CTL) #define ARPT_SO_GET_ENTRIES (ARPT_BASE_CTL + 1) static void checkpoint_iptables(struct ipt_table_desc* tables, int num_tables, int family, int level) { struct ipt_get_entries entries; socklen_t optlen; int fd, i; fd = socket(family, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (i = 0; i < num_tables; i++) { struct ipt_table_desc* table = &tables[i]; strcpy(table->info.name, table->name); strcpy(table->replace.name, table->name); optlen = sizeof(table->info); if (getsockopt(fd, level, IPT_SO_GET_INFO, &table->info, &optlen)) { switch (errno) { case EPERM: case ENOENT: case ENOPROTOOPT: continue; } exit(1); } if (table->info.size > sizeof(table->replace.entrytable)) exit(1); if (table->info.num_entries > XT_MAX_ENTRIES) exit(1); memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + table->info.size; if (getsockopt(fd, level, IPT_SO_GET_ENTRIES, &entries, &optlen)) exit(1); table->replace.valid_hooks = table->info.valid_hooks; table->replace.num_entries = table->info.num_entries; table->replace.size = table->info.size; memcpy(table->replace.hook_entry, table->info.hook_entry, sizeof(table->replace.hook_entry)); memcpy(table->replace.underflow, table->info.underflow, sizeof(table->replace.underflow)); memcpy(table->replace.entrytable, entries.entrytable, table->info.size); } close(fd); } static void reset_iptables(struct ipt_table_desc* tables, int num_tables, int family, int level) { struct xt_counters counters[XT_MAX_ENTRIES]; struct ipt_get_entries entries; struct ipt_getinfo info; socklen_t optlen; int fd, i; fd = socket(family, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (i = 0; i < num_tables; i++) { struct ipt_table_desc* table = &tables[i]; if (table->info.valid_hooks == 0) continue; memset(&info, 0, sizeof(info)); strcpy(info.name, table->name); optlen = sizeof(info); if (getsockopt(fd, level, IPT_SO_GET_INFO, &info, &optlen)) exit(1); if (memcmp(&table->info, &info, sizeof(table->info)) == 0) { memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + entries.size; if (getsockopt(fd, level, IPT_SO_GET_ENTRIES, &entries, &optlen)) exit(1); if (memcmp(table->replace.entrytable, entries.entrytable, table->info.size) == 0) continue; } table->replace.num_counters = info.num_entries; table->replace.counters = counters; optlen = sizeof(table->replace) - sizeof(table->replace.entrytable) + table->replace.size; if (setsockopt(fd, level, IPT_SO_SET_REPLACE, &table->replace, optlen)) exit(1); } close(fd); } static void checkpoint_arptables(void) { struct arpt_get_entries entries; socklen_t optlen; unsigned i; int fd; fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (i = 0; i < sizeof(arpt_tables) / sizeof(arpt_tables[0]); i++) { struct arpt_table_desc* table = &arpt_tables[i]; strcpy(table->info.name, table->name); strcpy(table->replace.name, table->name); optlen = sizeof(table->info); if (getsockopt(fd, SOL_IP, ARPT_SO_GET_INFO, &table->info, &optlen)) { switch (errno) { case EPERM: case ENOENT: case ENOPROTOOPT: continue; } exit(1); } if (table->info.size > sizeof(table->replace.entrytable)) exit(1); if (table->info.num_entries > XT_MAX_ENTRIES) exit(1); memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + table->info.size; if (getsockopt(fd, SOL_IP, ARPT_SO_GET_ENTRIES, &entries, &optlen)) exit(1); table->replace.valid_hooks = table->info.valid_hooks; table->replace.num_entries = table->info.num_entries; table->replace.size = table->info.size; memcpy(table->replace.hook_entry, table->info.hook_entry, sizeof(table->replace.hook_entry)); memcpy(table->replace.underflow, table->info.underflow, sizeof(table->replace.underflow)); memcpy(table->replace.entrytable, entries.entrytable, table->info.size); } close(fd); } static void reset_arptables() { struct xt_counters counters[XT_MAX_ENTRIES]; struct arpt_get_entries entries; struct arpt_getinfo info; socklen_t optlen; unsigned i; int fd; fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (i = 0; i < sizeof(arpt_tables) / sizeof(arpt_tables[0]); i++) { struct arpt_table_desc* table = &arpt_tables[i]; if (table->info.valid_hooks == 0) continue; memset(&info, 0, sizeof(info)); strcpy(info.name, table->name); optlen = sizeof(info); if (getsockopt(fd, SOL_IP, ARPT_SO_GET_INFO, &info, &optlen)) exit(1); if (memcmp(&table->info, &info, sizeof(table->info)) == 0) { memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + entries.size; if (getsockopt(fd, SOL_IP, ARPT_SO_GET_ENTRIES, &entries, &optlen)) exit(1); if (memcmp(table->replace.entrytable, entries.entrytable, table->info.size) == 0) continue; } else { } table->replace.num_counters = info.num_entries; table->replace.counters = counters; optlen = sizeof(table->replace) - sizeof(table->replace.entrytable) + table->replace.size; if (setsockopt(fd, SOL_IP, ARPT_SO_SET_REPLACE, &table->replace, optlen)) exit(1); } close(fd); } #define NF_BR_NUMHOOKS 6 #define EBT_TABLE_MAXNAMELEN 32 #define EBT_CHAIN_MAXNAMELEN 32 #define EBT_BASE_CTL 128 #define EBT_SO_SET_ENTRIES (EBT_BASE_CTL) #define EBT_SO_GET_INFO (EBT_BASE_CTL) #define EBT_SO_GET_ENTRIES (EBT_SO_GET_INFO + 1) #define EBT_SO_GET_INIT_INFO (EBT_SO_GET_ENTRIES + 1) #define EBT_SO_GET_INIT_ENTRIES (EBT_SO_GET_INIT_INFO + 1) struct ebt_replace { char name[EBT_TABLE_MAXNAMELEN]; unsigned int valid_hooks; unsigned int nentries; unsigned int entries_size; struct ebt_entries* hook_entry[NF_BR_NUMHOOKS]; unsigned int num_counters; struct ebt_counter* counters; char* entries; }; struct ebt_entries { unsigned int distinguisher; char name[EBT_CHAIN_MAXNAMELEN]; unsigned int counter_offset; int policy; unsigned int nentries; char data[0] __attribute__((aligned(__alignof__(struct ebt_replace)))); }; struct ebt_table_desc { const char* name; struct ebt_replace replace; char entrytable[XT_TABLE_SIZE]; }; static struct ebt_table_desc ebt_tables[] = { {.name = "filter"}, {.name = "nat"}, {.name = "broute"}, }; static void checkpoint_ebtables(void) { socklen_t optlen; unsigned i; int fd; fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (i = 0; i < sizeof(ebt_tables) / sizeof(ebt_tables[0]); i++) { struct ebt_table_desc* table = &ebt_tables[i]; strcpy(table->replace.name, table->name); optlen = sizeof(table->replace); if (getsockopt(fd, SOL_IP, EBT_SO_GET_INIT_INFO, &table->replace, &optlen)) { switch (errno) { case EPERM: case ENOENT: case ENOPROTOOPT: continue; } exit(1); } if (table->replace.entries_size > sizeof(table->entrytable)) exit(1); table->replace.num_counters = 0; table->replace.entries = table->entrytable; optlen = sizeof(table->replace) + table->replace.entries_size; if (getsockopt(fd, SOL_IP, EBT_SO_GET_INIT_ENTRIES, &table->replace, &optlen)) exit(1); } close(fd); } static void reset_ebtables() { struct ebt_replace replace; char entrytable[XT_TABLE_SIZE]; socklen_t optlen; unsigned i, j, h; int fd; fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: return; } exit(1); } for (i = 0; i < sizeof(ebt_tables) / sizeof(ebt_tables[0]); i++) { struct ebt_table_desc* table = &ebt_tables[i]; if (table->replace.valid_hooks == 0) continue; memset(&replace, 0, sizeof(replace)); strcpy(replace.name, table->name); optlen = sizeof(replace); if (getsockopt(fd, SOL_IP, EBT_SO_GET_INFO, &replace, &optlen)) exit(1); replace.num_counters = 0; table->replace.entries = 0; for (h = 0; h < NF_BR_NUMHOOKS; h++) table->replace.hook_entry[h] = 0; if (memcmp(&table->replace, &replace, sizeof(table->replace)) == 0) { memset(&entrytable, 0, sizeof(entrytable)); replace.entries = entrytable; optlen = sizeof(replace) + replace.entries_size; if (getsockopt(fd, SOL_IP, EBT_SO_GET_ENTRIES, &replace, &optlen)) exit(1); if (memcmp(table->entrytable, entrytable, replace.entries_size) == 0) continue; } for (j = 0, h = 0; h < NF_BR_NUMHOOKS; h++) { if (table->replace.valid_hooks & (1 << h)) { table->replace.hook_entry[h] = (struct ebt_entries*)table->entrytable + j; j++; } } table->replace.entries = table->entrytable; optlen = sizeof(table->replace) + table->replace.entries_size; if (setsockopt(fd, SOL_IP, EBT_SO_SET_ENTRIES, &table->replace, optlen)) exit(1); } close(fd); } static void checkpoint_net_namespace(void) { checkpoint_ebtables(); checkpoint_arptables(); checkpoint_iptables(ipv4_tables, sizeof(ipv4_tables) / sizeof(ipv4_tables[0]), AF_INET, SOL_IP); checkpoint_iptables(ipv6_tables, sizeof(ipv6_tables) / sizeof(ipv6_tables[0]), AF_INET6, SOL_IPV6); } static void reset_net_namespace(void) { reset_ebtables(); reset_arptables(); reset_iptables(ipv4_tables, sizeof(ipv4_tables) / sizeof(ipv4_tables[0]), AF_INET, SOL_IP); reset_iptables(ipv6_tables, sizeof(ipv6_tables) / sizeof(ipv6_tables[0]), AF_INET6, SOL_IPV6); } 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 (mount(0, "/proc/sys/fs/binfmt_misc", "binfmt_misc", 0, 0)) { } if (!write_file("/proc/sys/fs/binfmt_misc/register", ":syz0:M:0:\x01::./file0:")) { } if (!write_file("/proc/sys/fs/binfmt_misc/register", ":syz1:M:1:\x02::./file0:POC")) { } } static void setup_common() { if (mount(0, "/sys/fs/fuse/connections", "fusectl", 0, 0)) { } setup_cgroups(); setup_binfmt_misc(); } 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 = 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 = 0; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); if (unshare(CLONE_NEWNS)) { } if (unshare(CLONE_NEWIPC)) { } if (unshare(0x02000000)) { } if (unshare(CLONE_NEWUTS)) { } if (unshare(CLONE_SYSVSEM)) { } } int wait_for_loop(int pid) { if (pid < 0) exit(1); int status = 0; while (waitpid(-1, &status, __WALL) != pid) { } return WEXITSTATUS(status); } static int do_sandbox_none(void) { if (unshare(CLONE_NEWPID)) { } int pid = fork(); if (pid != 0) return wait_for_loop(pid); setup_common(); sandbox_common(); if (unshare(CLONE_NEWNET)) { } initialize_tun(); initialize_netdevices(); loop(); exit(1); } #define FS_IOC_SETFLAGS _IOW('f', 2, long) 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) { exit(1); } exit(1); } 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, MNT_DETACH) == 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, MNT_DETACH)) exit(1); } } closedir(dp); int i; for (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, MNT_DETACH)) 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); int i; for (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) { } } #define SYZ_HAVE_SETUP_LOOP 1 static void setup_loop() { int pid = getpid(); char cgroupdir[64]; char file[128]; snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/unified/syz%llu", procid); if (mkdir(cgroupdir, 0777)) { } snprintf(file, sizeof(file), "%s/pids.max", cgroupdir); if (!write_file(file, "32")) { } snprintf(file, sizeof(file), "%s/memory.low", cgroupdir); if (!write_file(file, "%d", 298 << 20)) { } snprintf(file, sizeof(file), "%s/memory.high", cgroupdir); if (!write_file(file, "%d", 299 << 20)) { } snprintf(file, sizeof(file), "%s/memory.max", cgroupdir); if (!write_file(file, "%d", 300 << 20)) { } snprintf(file, sizeof(file), "%s/cgroup.procs", cgroupdir); if (!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); if (!write_file(file, "%d", pid)) { } snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/net/syz%llu", procid); if (mkdir(cgroupdir, 0777)) { } snprintf(file, sizeof(file), "%s/cgroup.procs", cgroupdir); if (!write_file(file, "%d", pid)) { } checkpoint_net_namespace(); } #define SYZ_HAVE_RESET_LOOP 1 static void reset_loop() { reset_net_namespace(); } #define SYZ_HAVE_SETUP_TEST 1 static void setup_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); 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")) { } if (!write_file("/proc/self/oom_score_adj", "1000")) { } flush_tun(); } #define SYZ_HAVE_RESET_TEST 1 static void reset_test() { int fd; for (fd = 3; fd < 30; fd++) close(fd); } struct thread_t { int created, call; event_t ready, done; }; 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 (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; for (call = 0; call < 7; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 45); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { setup_loop(); int iter; for (iter = 0;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); reset_loop(); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); setup_test(); execute_one(); reset_test(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5 * 1000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } #ifndef __NR_memfd_create #define __NR_memfd_create 319 #endif uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { long res; switch (call) { case 0: NONFAILING(memcpy((void*)0x20000280, "[\'posix_acl_access\x00", 19)); res = syscall(__NR_memfd_create, 0x20000280, 0); if (res != -1) r[0] = res; break; case 1: NONFAILING(*(uint32_t*)0x20004240 = 8); NONFAILING(memcpy( (void*)0x20004244, "\xa4\x69\x5c\x53\x2a\x88\x40\xcd\x6f\xab\x54\x14\xa4\x52\x6f\x2c\x79" "\x70\x2a\xe7\xd3\xc6\x50\x18\x14\xb0\xf7\xc6\x41\x61\xe1\x34\x36\x4c" "\x38\x7e\xd3\x62\x86\x3f\x52\x9d\x09\x03\xde\xef\x78\x6d\x21\x53\x10" "\xea\xa4\xc1\x3c\x41\x25\x0d\xb8\x79\x4e\x3f\x0b\xf1\xbe\x5e\x5d\x1a" "\xac\x35\x7c\x8b\x6d\x3f\x43\xc2\x21\x9d\xe0\x7c\xd2\x21\x9a\xa3\xc3" "\xf2\x51\x25\x2b\x86\xeb\xd7\x58\xfd\xaf\x0e\x15\x6a\xd8\x8b\x2e\x62" "\x4d\x1e\x40\x53\x63\xae\xbe\x4a\xa0\xf3\x1c\xe7\xf0\xe5\x17\x06\x27" "\x3e\xa3\xb7\xc2\xcb\xd7\xd7\x7d\x31\x4a\x4a\xdb\x25\x48\x5c\x5e\x5b" "\xde\x9b\x99\x8a\xe9\x5c\x05\x81\x83\x6f\xa8\x41\xe2\x41\x74\x9c\xa8" "\xb5\x5b\x9c\x47\x05\xc4\xa8\x71\x4b\xd7\x16\x5f\x7d\x09\x99\xad\xb6" "\x58\xa9\x50\x7f\xa6\x4c\x7a\x41\xe5\x8f\xc3\x46\xdc\xa4\x57\x71\x0f" "\x13\xe9\x69\x9b\x0e\x17\x5c\x75\x23\xb5\x5a\xa7\x4a\x54\xe6\xcc\xcf" "\xb4\x63\xa2\xd6\xa8\x94\x51\xf8\x5e\xbd\x96\x2b\x04\x24\x18\xe5\xcc" "\x26\x6a\xbd\x4f\x41\xba\xd1\x8e\xb2\x63\x93\x79\xb5\x5a\xaf\x6e\x89" "\xd9\x2d\x01\xbf\xd9\x95\x27\x47\x11\xf8\xe7\x20\x94\xb4\x5a\x4b\x79" "\xb0\x99\x5e\x38\xb2\x8f\x66\x33\x23\x7f\x10\x5a\x7e\xc0\x50\x89\x6f" "\x83\x3d\xe8\x86\xc1\xd3\x1e\x3c\x14\xf4\x8b\xa1\x85\x04\x3d\x7f\x3e" "\xe7\x23\x1f\xbf\xd2\xcb\xd3\x1e\xf3\x45\x40\x27\xc2\x69\x40\x71\x4d" "\xca\x40\xc7\x4d\xda\x73\x81\x2e\xdb\x9d\x2a\xdc\x73\x54\xce\x26\x33" "\xae\xea\xdb\xc6\xc1\x4e\x16\x9d\x99\x4d\x7a\xc1\xb6\x80\x43\xfc\x1b" "\x37\x27\xb2\xf9\x67\x06\xda\x8c\x3f\x3b\x37\x71\xd5\xbe\xba\x69\x18" "\x8f\xca\x57\x85\x27\x85\xf4\x6c\xb3\x73\xc1\x9a\x33\x74\xd8\xc0\x41" "\xf9\x2a\xb3\x82\x0d\x2a\x1e\xb5\x25\x23\x7c\xce\x0f\x7a\x99\xe0\xc6" "\x6c\xf6\x81\xe7\xea\x95\x0e\x06\x2c\xfa\xf0\xe8\xd8\xd8\x34\xda\x04" "\x43\x70\x3e\xa2\xb6\x35\x68\xd2\x9c\xd2\xd7\x19\x9b\x6e\xf6\x78\x4e" "\x0d\xc8\xa8\x97\x98\x41\xd4\xdd\xea\x77\xb9\x98\x61\x9e\x8e\xae\x45" "\xa9\xea\x9b\xb1\x46\x4a\xd2\xaa\x2d\xf2\x28\xe6\x0a\x65\xb5\xe8\x3a" "\xd3\x69\xbc\x36\x7b\x69\xa8\x20\x7d\x8f\x09\x04\xb4\xc3\x89\xc9\x73" "\xec\x70\x5b\x73\xb6\x66\xe2\xf2\x98\xd1\x0f\x57\xf0\x98\xed\x0a\xf8" "\x10\x23\x13\x58\xdd\x15\x1e\xa5\xbc\x03\x67\x5b\xf1\xc9\xfe\x6a\xc5" "\x70\xad\x62\x81\x52\xc8\xa2\xb8\x57\x0d\x84\x9c\x8a\x04\x60\xb6\x17" "\xfa\xbd\xa4\x99\xcd\x10\xaa\x0e\x36\x6b\x83\x20\xe1\x4b\x1b\xec\x56" "\xc6\xa9\x61\x65\xd2\x3b\x98\x06\xc0\xc4\xf8\x6d\x2d\x46\x77\xa9\x5a" "\x6c\x0e\x62\x7a\xae\x99\xc2\x35\xb0\x6b\xf1\x43\x2e\x7c\x81\xdd\x82" "\x7e\x43\xff\xf9\xec\xd2\x4f\x75\x31\xca\x4c\xfa\xcf\x47\x8f\x66\xed" "\x76\x4f\xcf\x53\xd7\x73\xf4\xb9\xab\xe8\x18\x5a\x66\x1f\xdc\x97\x27" "\xa4\x78\xf4\x22\xa4\xbb\x1a\x7e\xde\xaf\x68\xb1\xe2\xff\xa6\x8e\x30" "\x68\xa7\xde\x07\x7c\xed\xc7\x55\x4d\xe7\xa9\x0d\xd2\xb2\x48\x3a\x47" "\x81\x4c\xc7\xbc\x85\xeb\x1a\x97\x22\x46\x77\x8d\xb8\xb3\x3b\xd5\x22" "\xec\x79\xae\xfa\x35\x29\xa0\x00\xc5\x8b\x57\x0b\x94\x0e\x55\xc0\x48" "\x43\x86\x32\x5f\x40\x97\xb1\x3b\xf3\x37\x75\x9b\x0b\xec\x93\x21\xfe" "\x39\xe5\x21\xa5\x46\xa7\x56\x3e\xb6\x75\xa6\x1c\xe6\x80\xde\xe1\x12" "\xf3\x68\x34\x3c\xa5\x63\x32\xc2\x8f\x44\xf9\x50\x24\xae\x1d\x77\xb4" "\x11\xab\xe6\xed\x80\xc6\x45\xce\x69\xda\xee\x65\xe2\x50\x5d\x13\xb2" "\xd0\xf2\xf1\xdf\xe3\x5e\xa7\xc5\x34\x0c\x6e\xb7\x0c\x4c\x34\x35\x0f" "\xbc\xb9\x94\x5e\x2f\xf4\x75\x9b\xaf\x55\xb0\x1d\xb4\x9b\x1a\x7d\x10" "\x11\xea\xee\x48\x11\x15\x0e\x7f\x5c\xaf\x7e\x93\xb0\x74\x6e\xfb\xc5" "\x2f\x57\x33\xc7\x4e\x27\xb8\xf4\x63\x1d\x38\x52\xd5\x44\xee\xf2\x95" "\xeb\x18\xa2\xbf\x23\x69\x67\x9c\x2b\xd9\xa9\xc5\x93\x98\x03\xc6\xea" "\x15\x3d\x9c\x15\xdd\x41\x12\x78\x90\x60\xda\x7b\x1d\x5b\x7e\x41\xb7" "\x18\xa6\x8a\x10\xf1\xd4\xf3\xe3\x29\x8c\x16\xc5\xab\x69\xa6\xc7\x18" "\x7d\xdc\x82\xf2\xd3\xe8\xcd\x73\x7a\xfb\x71\x87\xde\xa3\x07\x63\x59" "\xfa\xc2\xb4\x09\x17\x30\x5d\x9f\x83\x1b\x2e\xa6\x98\x05\x1f\x65\x60" "\xfc\x3c\xc6\xd2\x4d\xbd\x14\x8a\xbe\x8e\x58\xf7\xd8\x12\x7a\x96\x15" "\xba\x02\x7a\xa3\x5a\xaf\xc8\x8d\xeb\xf0\x6d\xab\x3c\xa3\x8e\x01\x97" "\x71\x02\x16\x47\x47\xb0\xeb\x56\x80\x09\x88\x73\x42\xbb\xc1\x4e\x27" "\x4e\x1d\x12\x72\x9b\x77\x08\x87\xf9\xae\xa1\x8d\x2a\xd6\x44\x18\x49" "\x84\x2d\x51\xd4\x19\x07\x42\x8a\xb2\x8e\x36\xe8\x15\x10\x33\x60\xef" "\x3c\x12\x1d\x5a\x60\x22\x31\x41\x3d\x28\x25\xc0\xbc\x1a\x2f\x04\x61" "\x49\x20\xb1\x13\xe8\x71\xae\x1d\xa7\x9e\xb4\xf3\xa8\x52\x8e\xff\xc9" "\xe7\x38\xc4\x8e\xb2\xba\x78\x43\x33\x2b\x85\xbc\xc4\xd4\xf4\xcb\xce" "\x50\x90\x96\x7f\xd6\xe8\x8c\xd6\x3a\x3d\x03\xf5\xc7\x9f\x36\xcc\xc4" "\x5b\xe3\x94\x1b\x3b\x39\xfb\x19\xe5\x12\x98\xb8\x67\x19\x30\xa5\x77" "\x2e\xd8\x78\xb0\x57\x57\x2b\x6d\xb8\xec\xe6\xac\x3f\x46\xa0\x62\xa8" "\xfc\xcd\x0a\x3b\x91\x33\xc0\x57\x34\x19\xe3\xa2\xd5\xb7\xab\x5c\xa4" "\x00\x33\xe3\x59\x18\x44\x9d\x04\x42\x8e\xcb\x9f\xeb\xca\xbe\xff\x93" "\x7f\xba\x5e\xe2\x1e\x75\x70\x7d\xe7\x89\x43\x2e\xc0\x68\x0d\x3f\x95" "\x29\x27\xeb\xb8\x5e\x56\x09\xae\xbf\x96\xe8\xc8\x4d\x88\x05\x6d\x36" "\x94\x93\xc8\x75\xce\x0f\x9e\x8a\xe5\xfa\xc4\x89\x12\xa7\x68\x99\x14" "\xf9\xbe\x71\x77\x3d\x3f\x00\x43\x06\x40\x6c\xdb\x76\x1c\x12\x73\x82" "\xe7\x0a\x77\xac\x6d\xa6\xaa\x98\xd5\x7a\x57\x5b\x21\x8b\x72\xe2\xd9" "\x0a\x66\xbc\xc1\x30\x60\x0b\x52\x76\x5d\xa0\xb0\x17\xba\xb0\xe3\xf3" "\xe3\x68\x9c\xf1\x22\x03\x29\xea\x86\xa0\x3c\xd2\xf6\xd2\xb5\x4c\x95" "\x36\x4c\x83\x9e\xbb\xc3\x15\x15\x3d\xfb\xc9\x7d\x69\x61\xd7\xf0\xe6" "\xdb\x56\xa9\x3f\xa1\xd7\xaf\xea\xf4\x79\xfe\x47\xac\x35\xc9\x2a\x39" "\x8b\xe9\x21\x76\x9f\x3f\x7c\x42\x2c\xfd\x5f\xfc\x37\x2f\x85\xee\x3f" "\x61\x99\x74\xb8\xc6\x27\x56\x84\x30\xc6\x4d\x84\xf6\xaa\xf6\x9a\x12" "\x76\xa7\xcf\x4c\xf5\x7c\x05\x72\x57\x18\x1f\x15\xe8\x2f\xd3\x72\x71" "\x27\x8d\xa6\x23\x5f\x34\x89\x1f\xc7\x02\x89\x4c\xca\x12\x00\x1e\x26" "\x3d\x74\xa6\xe1\x8a\x45\xbc\x0e\xbd\x16\x00\x98\x7c\x32\x37\x80\x45" "\x07\xa4\x92\x3f\x47\x00\xeb\xcc\xa3\x68\x4e\xf3\x5f\x8e\x4c\x0a\x8b" "\x98\x75\xcf\x92\xae\xc8\x62\x51\x9f\x5c\x0c\xdc\xb1\xd5\xb9\x07\x10" "\xa8\x8d\x39\xbb\x91\x9c\x08\x20\xf2\x56\x85\x08\x5d\x17\x9b\xd4\x8e" "\xbc\xe2\x1c\x4e\xd6\x97\xa9\xde\xf3\xad\x88\x7e\xb4\x65\x2a\xc5\x91" "\x9f\xfb\x2f\xf3\x4e\x78\xd5\x31\x23\xe9\xc1\xae\x9e\x50\x44\x7d\x77" "\x56\x0c\x37\x02\xd8\x18\xba\x1e\x9f\x84\x81\x23\xf3\x1c\xa6\x23\x64" "\x57\xda\xed\xa1\x38\x84\x6b\x55\x01\x7b\x42\x6f\xd8\xfe\x0e\x65\xb5" "\xc1\xd8\xd9\x36\xbd\xa2\xe7\xe9\xf6\x7e\xc0\xfa\xaa\xda\x6e\xba\xfb" "\x24\x40\x07\x1f\x0c\x50\xaa\xc2\xf0\xa5\x05\x9d\xce\x32\x99\x87\x99" "\x52\x4b\xd6\x41\x2c\x13\xbb\xee\x27\xb8\x91\xde\x38\x6b\xdc\x7b\x4a" "\x96\xa3\xe4\x95\x30\x0e\x82\xec\x8d\x83\x7b\x95\xb9\xaf\x4b\x11\x71" "\xea\x76\x40\xa2\x7f\x27\xb3\xbe\xfe\xed\x4b\x86\x4b\x54\x42\xf8\x89" "\xb7\x69\x20\x6d\x67\x67\xb5\x81\x5a\x74\xdf\x96\x08\x24\xfb\xca\xb3" "\x1a\xb9\x32\x81\xdb\x2b\x65\x1a\x83\x8b\x79\x0e\x52\xfb\x4c\x2e\xd2" "\x93\x58\xcf\xe4\x4c\x85\xf5\x45\x3a\xf7\x06\xeb\x96\xeb\xc3\x14\x06" "\x97\xeb\x91\x4e\x80\x3f\x39\x65\x61\x4c\x15\xca\x7f\xb5\xf6\xc6\x32" "\x00\x7f\xe7\xc5\x6a\xcd\xbd\xb0\xa1\x97\x34\x1d\x44\xf0\x24\xcb\xe1" "\x74\x24\x4c\x0a\xcf\xb1\xbd\x29\xf0\xd6\x28\xd0\x37\x95\x6a\xd4\x43" "\x4a\xa3\xa7\x1e\xcd\x29\x55\x6f\x3a\x23\xfb\xfc\x37\x35\x90\x4c\x2c" "\xe5\xe8\x4f\xd5\x3b\xbc\x43\xe9\x24\x94\x0f\x30\x7a\x81\x70\x65\x56" "\xc4\x5f\x53\x63\x0c\x31\x1a\xaa\xe9\xce\x45\x65\xae\xd2\x33\x9d\x95" "\xbb\xf3\x10\x7a\x90\xa3\xb8\xa6\xe9\x5e\x84\x15\xa2\xae\x7b\x88\x41" "\xda\xc7\x58\xd5\x2b\x7b\xb2\x2c\xbe\x0e\xba\xd7\x99\x00\xe9\xc7\xc4" "\x0c\xca\x87\x99\xcc\xa6\x6b\x35\x71\xfb\xec\xf6\x8e\x3e\xa2\xe3\x88" "\x0b\xc2\xcb\xed\x1a\xd1\xda\xbd\x69\x59\x3e\x1a\x96\x8d\xa4\x10\xc5" "\xd8\x53\x8f\xdc\x81\x99\xee\x31\x0a\x3a\x2b\x14\xc6\x42\xe3\x88\xe9" "\xf1\x41\x3b\xb9\x0f\x87\x6a\xa4\x78\x00\x65\x54\xa0\x1f\x6b\x0d\x41" "\xd2\xf5\xc8\xb7\xff\x20\xd7\xcb\x79\xaf\xd1\x3f\x6a\xb3\xf1\x33\x1a" "\x8d\xe1\x54\xa6\x0d\xa3\x3a\xac\x53\x10\xc1\x74\xcd\x54\xa7\x99\x85" "\x77\x2f\xce\x70\x7d\xa4\xa9\xce\x7c\x5b\x7b\x60\xe9\xa9\xa5\x8c\xd0" "\xaa\x43\x43\xc4\x5d\x4a\xcc\xa1\x7b\x04\x21\x40\x76\x80\x0d\x3a\xb3" "\x46\x14\x2e\xbe\x4b\xdf\x3c\x70\x94\xe7\x3a\x55\x2b\x19\x29\xaf\x8c" "\x5a\x56\x03\x18\x8c\xb7\x51\xb3\x5a\x98\x31\x46\x94\xec\xbf\x71\xc0" "\x5e\x79\x97\xa3\x22\xee\xc7\xa6\x59\xc4\x48\x99\xf7\xc5\x3c\x8d\x34" "\x77\xd3\xc3\x6f\x21\x57\x76\x20\x81\x3b\x41\x22\x3a\xab\xdc\x72\xd7" "\x72\xa2\xf6\x0d\xeb\x3b\x55\xbf\x1b\x5c\x14\x55\x37\x1f\x14\xb0\xad" "\x57\xaf\x2c\xf6\xcc\x5b\x25\x79\x39\x35\xd9\xd1\xfe\x24\xa2\xc5\x4b" "\x5d\x1e\x45\xb0\xd6\x9c\x7f\x69\x7b\xa2\x65\x95\xbd\x30\xe8\x36\x1a" "\xde\xe3\xe8\x4b\x2b\xb0\x84\x10\x43\x5a\xe3\x48\x94\x7b\x1c\x38\x9d" "\x5b\xb5\xa9\x7b\x46\x54\x24\x1f\x9b\x9b\xc0\x7d\x96\x8a\x6d\x96\x32" "\x00\xe0\xf4\xee\xd7\xdc\x80\x78\x0d\xad\xd6\xb5\x70\xa2\xc5\xa6\xe9" "\xdd\x93\x71\x2e\x61\x03\xbc\xe2\x4d\xb1\x5d\x90\x6b\xa0\x30\x85\xc0" "\x6d\x5d\x96\x3d\x34\x52\xf7\x42\xa3\x86\x66\x1b\x16\x79\xf9\xa2\xca" "\xe3\xb9\xde\xbf\x35\xc0\x1a\x82\xa5\xe8\x69\xcc\x63\xaa\xbb\x11\x3f" "\x6a\x37\xa3\x45\x4b\x13\x41\x08\xdf\xec\x97\x5a\xc6\x19\x2b\xe9\xc6" "\x99\x32\x1e\xf5\x28\x0e\x82\xe1\x3a\x58\xd6\xc6\xf6\x8d\x8d\x3a\xbc" "\xde\x2d\x2f\xd0\x47\xd8\xe0\x86\x50\xc7\x15\x93\x2b\xed\xc0\xaf\xba" "\xdb\xfa\xd3\x2d\xab\x97\x66\x87\xc4\xd7\xdf\xc4\x0d\x95\x39\x97\x16" "\xf4\x10\xd7\x5e\x8d\x6b\x4e\x5a\xd8\x55\x62\xe5\x60\x4d\x1e\x41\x4c" "\xec\xc3\x94\x1b\x2e\x9c\xfd\x1a\xa2\xa6\xf3\x1b\x2d\x50\x94\x20\xda" "\xb9\x6d\x19\xfe\x66\x27\x42\x0c\x0c\x45\x4f\x48\xb9\x26\x3d\x2a\xf2" "\x16\xab\x08\x58\x59\x00\x05\xd5\x74\x12\x23\x47\x55\xb7\x06\xda\x1a" "\x7a\x14\x5f\xce\x8e\x00\x79\x69\x69\x5d\x00\xbb\x46\x22\x70\xac\x95" "\xfd\x1b\x48\x36\x86\xff\x6d\xb7\xff\xe5\x76\xa8\xdf\x61\xd8\x06\x04" "\x44\x34\x52\x23\x6e\x27\xad\xbb\x46\xd4\xa7\x0f\x2e\x7c\xcb\xf1\x73" "\x5a\x9e\x9f\xce\x0f\x56\x85\x9f\xa0\x0c\x01\x17\x42\xf5\xde\xd1\xa3" "\x63\x1a\x8a\xdd\xbd\x1c\x41\x2f\x4b\x40\x4a\x6c\x71\x64\xb3\x3f\x37" "\x8c\x95\x39\x5b\x8c\xe6\x18\x5f\x90\xc9\x3a\x9f\x6b\x33\xf9\x05\xb0" "\x3c\x20\x89\x55\x4b\xef\x29\x91\x42\x8d\x4d\x2b\x27\xe0\x01\x92\x6e" "\x71\x4e\xef\x50\xba\x21\xb7\xa9\xc0\x48\xcb\xf2\xd7\x25\x76\xa8\x2b" "\x11\x45\xf4\x0c\x9e\x8a\x2d\xd7\x96\x84\xfd\x5c\x33\x19\xa8\x07\x6b" "\x5f\x88\x63\x29\x30\x54\x23\x48\x24\x1e\xe0\xc0\xb7\x37\xc9\x47\x4a" "\x44\x48\xd2\xa7\xd1\xad\x2d\x81\xa5\xbc\xd4\x56\x65\x20\xb6\x78\xae" "\xdb\xb3\xc5\x4c\xdc\x7d\xd6\xd0\x3b\xb6\x0a\xf9\x51\xee\xe9\xdf\xa5" "\xb9\x2e\xbd\x2b\x6e\x4e\xdf\x1c\xae\x7f\xee\xe7\x5c\x90\x1b\x8f\xbe" "\xf1\x95\x92\x10\x76\xaa\xfc\xe7\xc3\x47\x32\xc3\xc6\x70\x93\x58\x7e" "\x25\x86\x0e\x94\x02\x87\x68\xb9\x8c\x19\x80\x03\x8f\xce\x54\xfb\x76" "\xd2\x53\x1b\x9c\x3f\x94\x56\x30\xee\x9e\xc1\xaf\xa2\xac\xba\x1e\x66" "\xd2\xcc\xc8\xb9\x66\xc0\x47\x0d\x55\x28\xcf\xc1\x19\xc0\xba\x14\xcf" "\x84\xc5\xc2\xa2\xfb\xcf\x99\x65\x7c\x3c\x73\xab\x20\xb3\x25\x47\x27" "\x5b\xba\x54\xd4\x5e\xaf\x49\xe8\x66\x22\x46\x7e\x82\xd1\x73\xd8\xdc" "\xae\xaf\x5e\xba\x2a\x24\xab\xbd\xbe\xb5\xbc\xae\x6f\xf2\x22\xd4\x9e" "\xff\x89\x94\xc3\x12\x97\xee\x3f\x53\xed\x05\x95\xca\x90\xaa\x63\x15" "\xd3\x0c\xff\xb5\xfd\xf2\x7b\xd6\x8f\x78\xff\x54\x7d\x4e\x1b\x44\x31" "\x61\xc1\x30\xcd\xb0\x2f\x38\xbd\x0c\x5f\xc5\xeb\x86\xdc\x8a\x7c\xd9" "\xc3\x95\x6d\x8a\xec\x7b\x9f\x4d\x34\x2e\xdf\xfe\xf3\xb8\x19\x65\x7f" "\x08\x91\xbe\x01\xb9\x74\x40\x9e\x7a\x5b\x2a\xe6\x3a\xc6\x8b\xd7\x69" "\x6e\x1b\x6a\xb1\xda\x8e\xe4\x8e\xe9\x55\xa3\xa1\x2d\x14\xce\x06\x7c" "\x9c\x3c\x8b\x75\x2e\x37\xc8\x43\xfa\x9f\x5e\x9f\x3a\x1f\xff\x75\xad" "\x6f\xf6\x36\x6b\x34\x46\x4a\x39\x7b\xf6\xc7\x4a\x64\x88\x91\x2f\x2b" "\xb8\xfb\x37\x9d\x18\x06\xa9\xa6\x35\xd9\x69\xb5\x81\x8e\xaf\x11\xb7" "\xcd\x73\x77\xcc\x68\x4d\x71\xf3\x74\x50\x82\xef\xa2\xf4\x9f\x64\xa0" "\x57\x05\x0c\x5f\x5c\x17\x1b\x93\xa6\x4d\xc9\x3b\xdf\x89\xa1\x81\xa7" "\x0d\x38\xda\xe0\x73\x1e\x58\x63\xc6\x27\x35\xd7\xa4\xb2\x84\x19\xab" "\xd2\x21\x26\xa0\x0f\xc9\xa5\xa7\x5a\x74\x69\x1c\xad\xdc\x54\xd5\x42" "\x6b\x81\xdf\x64\x48\xef\xeb\xc6\xb5\x10\x5c\x4d\x64\x8d\xcc\x23\xae" "\x4f\x9e\xc7\x61\x1a\xae\xf8\x03\x0e\xa4\x4d\x38\x95\x2d\xd9\xcb\x32" "\xdd\xb4\x84\xd3\xcd\x4e\x6b\x01\x74\xc5\x8f\xd7\x28\x83\x52\xf1\x63" "\x9f\x78\xf2\xfd\x21\x13\x52\x34\x62\xc4\x99\x9a\x92\xe5\xd9\xe0\xea" "\x15\x41\xc3\xff\x9b\x74\x9b\x5a\x37\x68\x7f\x04\x99\xb1\xa1\x3f\xb2" "\x59\x0f\x7c\x76\xa1\x57\x3f\x67\x3a\xd8\x50\x38\x45\x25\x7c\x58\x8c" "\x30\x49\x35\x0e\x97\xed\x93\xe2\x43\x12\xff\x82\x62\x0d\x42\xf7\x22" "\x9c\x4a\xc1\x09\x42\x03\xe0\xb2\x02\x2e\x9a\x61\x73\xd0\x00\xe7\x64" "\x4f\x86\x7b\xfb\x7a\x14\x2d\x4f\xc2\xe3\x5a\x54\xde\x4e\x9e\x23\x51" "\x6c\xc5\xcd\xce\x02\x7b\x62\xef\x24\xfc\x32\xcd\x10\x89\x0e\x4f\x2f" "\xcf\x26\xa0\xf7\xb4\x00\x39\x22\x5f\xf1\x9f\xf3\x5b\xa9\x7d\x9e\xcd" "\xb6\xe6\xd2\xcd\x21\x16\x63\xdc\xc0\xde\xe1\xd4\x14\x09\xf2\xd8\x41" "\x0b\xf0\xbc\x9c\xeb\x49\x0d\x29\x2a\x3d\x97\xcc\x34\xeb\xc6\x47\x35" "\x4d\x84\x87\xb2\x1c\x30\x6e\x80\xb4\x5d\xc5\x78\x16\x92\x4f\xee\x5e" "\x24\xe3\x09\x15\x96\x7e\x18\xa9\x52\xb0\x07\xda\x91\xd2\x70\xaf\x88" "\xfa\xb2\x3d\xd4\x20\xfd\xb1\x02\x38\x75\x03\x28\x0d\x43\x6f\x64\x4c" "\xed\x68\x68\xa2\xab\x7a\xb2\xb1\x37\x49\x69\xdb\x72\xea\x9c\x61\x26" "\x36\xb8\x58\x54\x7a\x9b\xb1\x87\xd2\x63\x9f\xc3\x0b\xe9\x48\x76\x0b" "\xc6\x34\xe5\x72\x71\x8e\xfd\x0d\xad\x2f\xe4\xf6\xaa\xf4\x4b\x0c\x58" "\x23\xe6\x85\x47\x26\xf1\xd4\x6b\xf4\x1d\xd8\x69\x1e\x58\xa7\x7b\xdc" "\xb9\xaf\xa6\x3f\x3b\x0e\x1f\xbb\x0e\x5c\xaf\xa7\x60\x54\x06\x76\x9d" "\x62\xa3\xf7\xe3\x99\xe7\xd6\xc1\x38\xad\xb0\x2d\xe7\xf4\x84\x37\x83" "\xb0\xdc\x06\xf4\xc4\x53\x9b\x02\xd5\x65\xe7\x9e\x81\xeb\xa2\x06\x09" "\xba\x8a\x89\x14\xf7\x48\x99\xab\x42\xac\x92\xb0\x35\x80\xcf\xb5\xe4" "\x57\xca\x5d\x0b\x74\x7a\x69\xab\x9e\xdd\x27\x8c\xb5\x9f\x7e\x6b\xd3" "\x81\xa4\x83\xd9\x2d\xc8\x66\xe9\xcc\xaf\x78\x0b\x91\xa6\xf6\x99\x3b" "\xab\x6f\x73\xd5\x25\x93\xfe\x2c\xda\x79\x56\x1f\xfb\xed\x67\x7f\x57" "\x42\xf7\x84\x4d\x28\x4c\xfd\x9d\xa3\x4c\xb6\x4b\x42\x30\x73\xa4\xb3" "\xcf\xf0\x7f\xa6\xf1\x8e\xea\x3a\x3e\xf8\x43\x14\x68\x70\x76\x3c\x76" "\x6d\x16\xc7\x82\x51\x7a\xcf\xa8\x9f\xb3\xd2\x73\xe7\x0d\xc8\xba\x22" "\xa5\x6f\x1d\x84\x0c\x5d\xc8\x7c\x31\xe4\xdf\x33\x93\x8c\x0a\x0d\xc7" "\x8e\xa3\x58\x72\xae\x89\xb2\x32\x90\xe7\x86\xba\xf5\x81\xba\x3b\xcd" "\x99\x5e\x5b\xdd\xf2\x2e\x6a\x54\xa6\xd6\xae\x09\x32\x78\xf6\xfb\xbd" "\x3e\x51\x4c\xfe\xa1\x44\xd6\x90\x10\x73\xe5\x47\xd1\x43\xc3\x29\xea" "\x2a\x1f\x97\xab\x9a\xa7\x66\xa2\xc0\x32\x48\x90\xc8\xcb\x1a\xec\x1b" "\x21\xc8\x8e\xdf\xbb\x8f\x0d\x81\x48\x48\xf3\x1b\xd4\xa0\x37\x0c\xc3" "\xcb\xa4\x76\x5c\x50\x97\x5c\x83\x49\xda\x80\x5d\xf6\xfe\x1b\x67\x90" "\x4b\x5a\xa7\x06\x87\xe6\x1f\x6b\xef\x11\x79\xe3\x0a\x9b\x79\x57\x04" "\xd1\x1b\xdd\x7a\xba\x53\x2b\xc4\x85\x28\x57\x4a\x3d\xfa\xdd\x9f\x28" "\x1c\x0c\xbf\xec\xd9\x91\xe3\x2c\x90\x1b\x8d\x7c\xc5\x77\x44\xce\x51" "\x58\xf2\x25\x94\x73\xf3\x7e\x02\x5c\x3f\x1d\xda\xe6\xc5\x1c\xf5\x0c" "\x2b\xc1\x0b\xbd\xb1\x7d\x01\xac\x0f\x48\x07\x04\x3c\xda\xdb\x05\x30" "\x28\x3e\x52\xb6\xe8\x25\x16\x60\x3a\x1d\x70\x79\xbb\x45\xae\x71\xc1" "\x5b\x23\xa9\x87\x7b\xc2\xae\x70\x6d\xa4\x33\x1b\x9a\xc9\xab\x6e\x1e" "\xc8\xfd\x40\x41\x89\x4c\xe2\xc9\x89\xdc\x1c\x95\x80\x2e\x3d\x44\x3f" "\xf2\xcf\x05\xec\x7e\x83\x48\xdf\x32\xae\x02\x02\x42\x0d\xad\xbf\x6e" "\x23\xde\x91\x7c\x76\xab\x51\x24\x26\xaf\x82\xad\xea\x7a\x5f\xd7\x2f" "\xde\xf2\x80\x18\x51\x90\x5e\xc7\x3b\x83\xbf\xc8\xc6\xe6\x3e\x57\x26" "\x16\xa6\x87\x85\x1b\x8a\xfa\x9e\x3f\x6c\x1e\xe3\x57\xb6\xff\xa9\x17" "\xee\xac\xd1\x00\x5c\x67\xbc\xed\x23\x5f\x61\x43\x6c\xb4\x4d\xd9\xbf" "\x68\x42\xc8\xea\x5b\xa2\x81\xf7\x75\x31\xe1\xd0\x8a\x7a\x09\xef\x0c" "\x19\xd2\xca\xc6\x55\xbf\xb8\x1a\xc4\xb7\xad\x40\x08\x3d\x09\xd9\xb8" "\x3e\x7d\x56\xad\xa5\xb9\x72\xcf\x6e\xe5\x3c\xa6\x93\xaf\x57\x6f\xe2" "\x2c\xfd\xe1\x79\x69\x27\xaa\x2b\x54\x37\x88\x84\xa9\x3e\x80\xec\xc9" "\x92\xcf\x29\x8b\xa9\x9e\x4a\xd5\xb9\xd1\x35\xaf\x6e\x23\x7f\x24\xc5" "\x19\xf0\x78\xb3\x0a\xb1\xfa\x02\x84\x38\x97\x69\x35\x75\x1d\x84\x0a" "\x60\x78\xad\x33\xf1\x22\x9a\xdf\x56\x63\xb5\xba\x3c\x8a\xbc\xff\x8f" "\xf3\x01\x83\x44\x6a\x62\xaa\xe8\xa0\x93\x7f\x8b\xb4\x18\xe0\xd0\xc9" "\x84\xc4\x41\x27\x1c\xcf\xc3\x98\x4c\xdc\x23\x79\x33\x46\xcf\xc3\x68" "\x09\xf5\xce\xec\x33\x0e\x73\xe4\xf1\x3d\x5a\x17\x72\x65\x26\xb6\xe3" "\x99\x31\xa8\xde\x1f\xb1\xd9\x98\x68\x07\x47\xf0\x17\x24\xb1\x17\x71" "\x07\x59\xb9\xd2\x9b\xf6\x8f\xda\x85\x29\x47\x3e\xae\xb2\x81\x82\xe5" "\x02\x22\x0a\x6b\xf5\xcd\xca\x4c\x11\x8d\x2e\xda\xef\xe1\xff\xac\x00" "\x7b\xdb\x8f\x24\x64\x07\xdb\xa1\xf7\xae\x27\x72\x98\xb7\x65\xe4\x48" "\xb5\x01\xe1\xc5\x7e\x5f\x9e\x62\x0f\xb6\xa8\x94\x50\x6d\x7e\x81\xfa" "\x92\xbd\x55\x71\xb3\x2e\xda\xa3\xfb\xeb\x1a\x84\xe9\xdb\xd2\xd2\xe6" "\x1d\x31\xbf\xfa\xce\x3a\xd6\x15\x83\x7f\x3f\xa9\x5f\x2e\xd3\x7c\x9e" "\x96\xcc\x04\x5b\xae\xdb\x79\xad\x9c\x7f\xf3\x7b\xd9\x67\x98\xe6\xcc" "\xe6\xa8\xd2\xfc\x84\x53\xc3\xa4\x48\x65\xe1\xfa\xe5\xe5\xfb\x55\x11" "\x26\x03\x8e\xf2\xed\x4f\x6f\x7b\x6e\x18\x60\x72\xae\xc9\xd6\x2b\x86" "\x70\xf9\x72\xea\xbd\xf1\x2f\x13\xa1\xd3\xbe\x51\xd0\x37\xb2\x5e\xe0" "\x55\x27\x72\xc1\xfc\xfe\xcc\xcf\xa2\xbb\x44\x5a\x34\xda\xeb\x79\xd4" "\xa1\xbc\xfb\xf7\x0e\x71\x80\x91\xdd\x72\xca\x46\x06\x97\x31\xc3\x87" "\x75\x13\x6d\x72\x56\xe4\x45\xb5\x84\x19\xea\x84\x5d\xd0\xf6\x5a\x8a" "\x1d\xaf\x88\xc7\x50\x73\x1a\x00\x92\x29\x7c\x4c\x96\x40\x05\xbc\x9c" "\xf9\xec\x21\x5f\x07\xc1\x8a\x39\x5b\x35\x0c\xab\x70\x65\x8b\xbb", 4096)); NONFAILING(*(uint16_t*)0x20005244 = 0xfdd1); syscall(__NR_write, r[0], 0x20004240, 0xfffffe48); break; case 2: NONFAILING(memcpy((void*)0x20000100, "/dev/ashmem\x00", 12)); res = syscall(__NR_openat, 0xffffffffffffff9c, 0x20000100, 0x800, 0); if (res != -1) r[1] = res; break; case 3: syscall(__NR_ioctl, r[1], 0x40087703, 0x20010002); break; case 4: syscall(__NR_mmap, 0x20ffb000, 0x1000, 0, 0x400000000202012, r[1], 0); break; case 5: NONFAILING(memcpy((void*)0x20000000, "\x00", 1)); syscall(__NR_ioctl, r[1], 0x40087708, 0x20000000); break; case 6: syscall(__NR_ioctl, r[1], 0x770a, 0); break; } } int main(void) { syscall(__NR_mmap, 0x20000000, 0x1000000, 3, 0x32, -1, 0); install_segv_handler(); use_temporary_dir(); do_sandbox_none(); return 0; }