// https://syzkaller.appspot.com/bug?id=c932f162aae80e87067a04043e516dad1acc4cc7 // 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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef __NR_memfd_create #define __NR_memfd_create 279 #endif #ifndef __NR_mmap #define __NR_mmap 222 #endif #ifndef __NR_mount #define __NR_mount 40 #endif #ifndef __NR_openat #define __NR_openat 56 #endif #ifndef __NR_read #define __NR_read 63 #endif #ifndef __NR_sync #define __NR_sync 81 #endif static unsigned long long procid; static __thread int clone_ongoing; static __thread int skip_segv; static __thread jmp_buf segv_env; static void segv_handler(int sig, siginfo_t* info, void* ctx) { if (__atomic_load_n(&clone_ongoing, __ATOMIC_RELAXED) != 0) { exit(sig); } uintptr_t addr = (uintptr_t)info->si_addr; const uintptr_t prog_start = 1 << 20; const uintptr_t prog_end = 100 << 20; int skip = __atomic_load_n(&skip_segv, __ATOMIC_RELAXED) != 0; int valid = addr < prog_start || addr > prog_end; if (skip && valid) { _longjmp(segv_env, 1); } exit(sig); } static void install_segv_handler(void) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = SIG_IGN; syscall(SYS_rt_sigaction, 0x20, &sa, NULL, 8); syscall(SYS_rt_sigaction, 0x21, &sa, NULL, 8); memset(&sa, 0, sizeof(sa)); sa.sa_sigaction = segv_handler; sa.sa_flags = SA_NODEFER | SA_SIGINFO; sigaction(SIGSEGV, &sa, NULL); sigaction(SIGBUS, &sa, NULL); } #define NONFAILING(...) \ ({ \ int ok = 1; \ __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); \ if (_setjmp(segv_env) == 0) { \ __VA_ARGS__; \ } else \ ok = 0; \ __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); \ ok; \ }) static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } 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; } struct nlmsg { char* pos; int nesting; struct nlattr* nested[8]; char buf[4096]; }; static void netlink_init(struct nlmsg* nlmsg, int typ, int flags, const void* data, int size) { memset(nlmsg, 0, sizeof(*nlmsg)); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf; hdr->nlmsg_type = typ; hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | flags; memcpy(hdr + 1, data, size); nlmsg->pos = (char*)(hdr + 1) + NLMSG_ALIGN(size); } static void netlink_attr(struct nlmsg* nlmsg, int typ, const void* data, int size) { struct nlattr* attr = (struct nlattr*)nlmsg->pos; attr->nla_len = sizeof(*attr) + size; attr->nla_type = typ; if (size > 0) memcpy(attr + 1, data, size); nlmsg->pos += NLMSG_ALIGN(attr->nla_len); } static void netlink_nest(struct nlmsg* nlmsg, int typ) { struct nlattr* attr = (struct nlattr*)nlmsg->pos; attr->nla_type = typ; nlmsg->pos += sizeof(*attr); nlmsg->nested[nlmsg->nesting++] = attr; } static void netlink_done(struct nlmsg* nlmsg) { struct nlattr* attr = nlmsg->nested[--nlmsg->nesting]; attr->nla_len = nlmsg->pos - (char*)attr; } static int netlink_send_ext(struct nlmsg* nlmsg, int sock, uint16_t reply_type, int* reply_len, bool dofail) { if (nlmsg->pos > nlmsg->buf + sizeof(nlmsg->buf) || nlmsg->nesting) exit(1); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf; hdr->nlmsg_len = nlmsg->pos - nlmsg->buf; struct sockaddr_nl addr; memset(&addr, 0, sizeof(addr)); addr.nl_family = AF_NETLINK; ssize_t n = sendto(sock, nlmsg->buf, hdr->nlmsg_len, 0, (struct sockaddr*)&addr, sizeof(addr)); if (n != (ssize_t)hdr->nlmsg_len) { if (dofail) exit(1); return -1; } n = recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0); if (reply_len) *reply_len = 0; if (n < 0) { if (dofail) exit(1); return -1; } if (n < (ssize_t)sizeof(struct nlmsghdr)) { errno = EINVAL; if (dofail) exit(1); return -1; } if (hdr->nlmsg_type == NLMSG_DONE) return 0; if (reply_len && hdr->nlmsg_type == reply_type) { *reply_len = n; return 0; } if (n < (ssize_t)(sizeof(struct nlmsghdr) + sizeof(struct nlmsgerr))) { errno = EINVAL; if (dofail) exit(1); return -1; } if (hdr->nlmsg_type != NLMSG_ERROR) { errno = EINVAL; if (dofail) exit(1); return -1; } errno = -((struct nlmsgerr*)(hdr + 1))->error; return -errno; } static int netlink_send(struct nlmsg* nlmsg, int sock) { return netlink_send_ext(nlmsg, sock, 0, NULL, true); } static int netlink_query_family_id(struct nlmsg* nlmsg, int sock, const char* family_name, bool dofail) { struct genlmsghdr genlhdr; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = CTRL_CMD_GETFAMILY; netlink_init(nlmsg, GENL_ID_CTRL, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(nlmsg, CTRL_ATTR_FAMILY_NAME, family_name, strnlen(family_name, GENL_NAMSIZ - 1) + 1); int n = 0; int err = netlink_send_ext(nlmsg, sock, GENL_ID_CTRL, &n, dofail); if (err < 0) { return -1; } uint16_t id = 0; struct nlattr* attr = (struct nlattr*)(nlmsg->buf + NLMSG_HDRLEN + NLMSG_ALIGN(sizeof(genlhdr))); for (; (char*)attr < nlmsg->buf + n; attr = (struct nlattr*)((char*)attr + NLMSG_ALIGN(attr->nla_len))) { if (attr->nla_type == CTRL_ATTR_FAMILY_ID) { id = *(uint16_t*)(attr + 1); break; } } if (!id) { errno = EINVAL; return -1; } recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0); return id; } static int netlink_next_msg(struct nlmsg* nlmsg, unsigned int offset, unsigned int total_len) { struct nlmsghdr* hdr = (struct nlmsghdr*)(nlmsg->buf + offset); if (offset == total_len || offset + hdr->nlmsg_len > total_len) return -1; return hdr->nlmsg_len; } static void netlink_add_device_impl(struct nlmsg* nlmsg, const char* type, const char* name, bool up) { struct ifinfomsg hdr; memset(&hdr, 0, sizeof(hdr)); if (up) hdr.ifi_flags = hdr.ifi_change = IFF_UP; netlink_init(nlmsg, RTM_NEWLINK, NLM_F_EXCL | NLM_F_CREATE, &hdr, sizeof(hdr)); if (name) netlink_attr(nlmsg, IFLA_IFNAME, name, strlen(name)); netlink_nest(nlmsg, IFLA_LINKINFO); netlink_attr(nlmsg, IFLA_INFO_KIND, type, strlen(type)); } static void netlink_add_device(struct nlmsg* nlmsg, int sock, const char* type, const char* name) { netlink_add_device_impl(nlmsg, type, name, false); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_veth(struct nlmsg* nlmsg, int sock, const char* name, const char* peer) { netlink_add_device_impl(nlmsg, "veth", name, false); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_nest(nlmsg, VETH_INFO_PEER); nlmsg->pos += sizeof(struct ifinfomsg); netlink_attr(nlmsg, IFLA_IFNAME, peer, strlen(peer)); netlink_done(nlmsg); netlink_done(nlmsg); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_xfrm(struct nlmsg* nlmsg, int sock, const char* name) { netlink_add_device_impl(nlmsg, "xfrm", name, true); netlink_nest(nlmsg, IFLA_INFO_DATA); int if_id = 1; netlink_attr(nlmsg, 2, &if_id, sizeof(if_id)); netlink_done(nlmsg); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_hsr(struct nlmsg* nlmsg, int sock, const char* name, const char* slave1, const char* slave2) { netlink_add_device_impl(nlmsg, "hsr", name, false); netlink_nest(nlmsg, IFLA_INFO_DATA); int ifindex1 = if_nametoindex(slave1); netlink_attr(nlmsg, IFLA_HSR_SLAVE1, &ifindex1, sizeof(ifindex1)); int ifindex2 = if_nametoindex(slave2); netlink_attr(nlmsg, IFLA_HSR_SLAVE2, &ifindex2, sizeof(ifindex2)); netlink_done(nlmsg); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_linked(struct nlmsg* nlmsg, int sock, const char* type, const char* name, const char* link) { netlink_add_device_impl(nlmsg, type, name, false); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_vlan(struct nlmsg* nlmsg, int sock, const char* name, const char* link, uint16_t id, uint16_t proto) { netlink_add_device_impl(nlmsg, "vlan", name, false); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_attr(nlmsg, IFLA_VLAN_ID, &id, sizeof(id)); netlink_attr(nlmsg, IFLA_VLAN_PROTOCOL, &proto, sizeof(proto)); netlink_done(nlmsg); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_macvlan(struct nlmsg* nlmsg, int sock, const char* name, const char* link) { netlink_add_device_impl(nlmsg, "macvlan", name, false); netlink_nest(nlmsg, IFLA_INFO_DATA); uint32_t mode = MACVLAN_MODE_BRIDGE; netlink_attr(nlmsg, IFLA_MACVLAN_MODE, &mode, sizeof(mode)); netlink_done(nlmsg); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_geneve(struct nlmsg* nlmsg, int sock, const char* name, uint32_t vni, struct in_addr* addr4, struct in6_addr* addr6) { netlink_add_device_impl(nlmsg, "geneve", name, false); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_attr(nlmsg, IFLA_GENEVE_ID, &vni, sizeof(vni)); if (addr4) netlink_attr(nlmsg, IFLA_GENEVE_REMOTE, addr4, sizeof(*addr4)); if (addr6) netlink_attr(nlmsg, IFLA_GENEVE_REMOTE6, addr6, sizeof(*addr6)); netlink_done(nlmsg); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); if (err < 0) { } } #define IFLA_IPVLAN_FLAGS 2 #define IPVLAN_MODE_L3S 2 #undef IPVLAN_F_VEPA #define IPVLAN_F_VEPA 2 static void netlink_add_ipvlan(struct nlmsg* nlmsg, int sock, const char* name, const char* link, uint16_t mode, uint16_t flags) { netlink_add_device_impl(nlmsg, "ipvlan", name, false); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_attr(nlmsg, IFLA_IPVLAN_MODE, &mode, sizeof(mode)); netlink_attr(nlmsg, IFLA_IPVLAN_FLAGS, &flags, sizeof(flags)); netlink_done(nlmsg); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_device_change(struct nlmsg* nlmsg, int sock, const char* name, bool up, const char* master, const void* mac, int macsize, const char* new_name) { struct ifinfomsg hdr; memset(&hdr, 0, sizeof(hdr)); if (up) hdr.ifi_flags = hdr.ifi_change = IFF_UP; hdr.ifi_index = if_nametoindex(name); netlink_init(nlmsg, RTM_NEWLINK, 0, &hdr, sizeof(hdr)); if (new_name) netlink_attr(nlmsg, IFLA_IFNAME, new_name, strlen(new_name)); if (master) { int ifindex = if_nametoindex(master); netlink_attr(nlmsg, IFLA_MASTER, &ifindex, sizeof(ifindex)); } if (macsize) netlink_attr(nlmsg, IFLA_ADDRESS, mac, macsize); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static int netlink_add_addr(struct nlmsg* nlmsg, int sock, const char* dev, const void* addr, int addrsize) { struct ifaddrmsg hdr; memset(&hdr, 0, sizeof(hdr)); hdr.ifa_family = addrsize == 4 ? AF_INET : AF_INET6; hdr.ifa_prefixlen = addrsize == 4 ? 24 : 120; hdr.ifa_scope = RT_SCOPE_UNIVERSE; hdr.ifa_index = if_nametoindex(dev); netlink_init(nlmsg, RTM_NEWADDR, NLM_F_CREATE | NLM_F_REPLACE, &hdr, sizeof(hdr)); netlink_attr(nlmsg, IFA_LOCAL, addr, addrsize); netlink_attr(nlmsg, IFA_ADDRESS, addr, addrsize); return netlink_send(nlmsg, sock); } static void netlink_add_addr4(struct nlmsg* nlmsg, int sock, const char* dev, const char* addr) { struct in_addr in_addr; inet_pton(AF_INET, addr, &in_addr); int err = netlink_add_addr(nlmsg, sock, dev, &in_addr, sizeof(in_addr)); if (err < 0) { } } static void netlink_add_addr6(struct nlmsg* nlmsg, int sock, const char* dev, const char* addr) { struct in6_addr in6_addr; inet_pton(AF_INET6, addr, &in6_addr); int err = netlink_add_addr(nlmsg, sock, dev, &in6_addr, sizeof(in6_addr)); if (err < 0) { } } static void netlink_add_neigh(struct nlmsg* nlmsg, int sock, const char* name, const void* addr, int addrsize, const void* mac, int macsize) { struct ndmsg hdr; memset(&hdr, 0, sizeof(hdr)); hdr.ndm_family = addrsize == 4 ? AF_INET : AF_INET6; hdr.ndm_ifindex = if_nametoindex(name); hdr.ndm_state = NUD_PERMANENT; netlink_init(nlmsg, RTM_NEWNEIGH, NLM_F_EXCL | NLM_F_CREATE, &hdr, sizeof(hdr)); netlink_attr(nlmsg, NDA_DST, addr, addrsize); netlink_attr(nlmsg, NDA_LLADDR, mac, macsize); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static struct nlmsg nlmsg; static int tunfd = -1; #define TUN_IFACE "syz_tun" #define LOCAL_MAC 0xaaaaaaaaaaaa #define REMOTE_MAC 0xaaaaaaaaaabb #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 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 = 200; 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; if (ioctl(tunfd, TUNSETIFF, (void*)&ifr) < 0) { exit(1); } char sysctl[64]; sprintf(sysctl, "/proc/sys/net/ipv6/conf/%s/accept_dad", TUN_IFACE); write_file(sysctl, "0"); sprintf(sysctl, "/proc/sys/net/ipv6/conf/%s/router_solicitations", TUN_IFACE); write_file(sysctl, "0"); int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) exit(1); netlink_add_addr4(&nlmsg, sock, TUN_IFACE, LOCAL_IPV4); netlink_add_addr6(&nlmsg, sock, TUN_IFACE, LOCAL_IPV6); uint64_t macaddr = REMOTE_MAC; struct in_addr in_addr; inet_pton(AF_INET, REMOTE_IPV4, &in_addr); netlink_add_neigh(&nlmsg, sock, TUN_IFACE, &in_addr, sizeof(in_addr), &macaddr, ETH_ALEN); struct in6_addr in6_addr; inet_pton(AF_INET6, REMOTE_IPV6, &in6_addr); netlink_add_neigh(&nlmsg, sock, TUN_IFACE, &in6_addr, sizeof(in6_addr), &macaddr, ETH_ALEN); macaddr = LOCAL_MAC; netlink_device_change(&nlmsg, sock, TUN_IFACE, true, 0, &macaddr, ETH_ALEN, NULL); close(sock); } #define DEVLINK_FAMILY_NAME "devlink" #define DEVLINK_CMD_PORT_GET 5 #define DEVLINK_ATTR_BUS_NAME 1 #define DEVLINK_ATTR_DEV_NAME 2 #define DEVLINK_ATTR_NETDEV_NAME 7 static struct nlmsg nlmsg2; static void initialize_devlink_ports(const char* bus_name, const char* dev_name, const char* netdev_prefix) { struct genlmsghdr genlhdr; int len, total_len, id, err, offset; uint16_t netdev_index; int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC); if (sock == -1) exit(1); int rtsock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (rtsock == -1) exit(1); id = netlink_query_family_id(&nlmsg, sock, DEVLINK_FAMILY_NAME, true); if (id == -1) goto error; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = DEVLINK_CMD_PORT_GET; netlink_init(&nlmsg, id, NLM_F_DUMP, &genlhdr, sizeof(genlhdr)); netlink_attr(&nlmsg, DEVLINK_ATTR_BUS_NAME, bus_name, strlen(bus_name) + 1); netlink_attr(&nlmsg, DEVLINK_ATTR_DEV_NAME, dev_name, strlen(dev_name) + 1); err = netlink_send_ext(&nlmsg, sock, id, &total_len, true); if (err < 0) { goto error; } offset = 0; netdev_index = 0; while ((len = netlink_next_msg(&nlmsg, offset, total_len)) != -1) { struct nlattr* attr = (struct nlattr*)(nlmsg.buf + offset + NLMSG_HDRLEN + NLMSG_ALIGN(sizeof(genlhdr))); for (; (char*)attr < nlmsg.buf + offset + len; attr = (struct nlattr*)((char*)attr + NLMSG_ALIGN(attr->nla_len))) { if (attr->nla_type == DEVLINK_ATTR_NETDEV_NAME) { char* port_name; char netdev_name[IFNAMSIZ]; port_name = (char*)(attr + 1); snprintf(netdev_name, sizeof(netdev_name), "%s%d", netdev_prefix, netdev_index); netlink_device_change(&nlmsg2, rtsock, port_name, true, 0, 0, 0, netdev_name); break; } } offset += len; netdev_index++; } error: close(rtsock); close(sock); } #define WIFI_INITIAL_DEVICE_COUNT 2 #define WIFI_MAC_BASE \ { \ 0x08, 0x02, 0x11, 0x00, 0x00, 0x00 \ } #define WIFI_IBSS_BSSID \ { \ 0x50, 0x50, 0x50, 0x50, 0x50, 0x50 \ } #define WIFI_IBSS_SSID \ { \ 0x10, 0x10, 0x10, 0x10, 0x10, 0x10 \ } #define WIFI_DEFAULT_FREQUENCY 2412 #define WIFI_DEFAULT_SIGNAL 0 #define WIFI_DEFAULT_RX_RATE 1 #define HWSIM_CMD_REGISTER 1 #define HWSIM_CMD_FRAME 2 #define HWSIM_CMD_NEW_RADIO 4 #define HWSIM_ATTR_SUPPORT_P2P_DEVICE 14 #define HWSIM_ATTR_PERM_ADDR 22 #define IF_OPER_UP 6 struct join_ibss_props { int wiphy_freq; bool wiphy_freq_fixed; uint8_t* mac; uint8_t* ssid; int ssid_len; }; static int set_interface_state(const char* interface_name, int on) { struct ifreq ifr; int sock = socket(AF_INET, SOCK_DGRAM, 0); if (sock < 0) { return -1; } memset(&ifr, 0, sizeof(ifr)); strcpy(ifr.ifr_name, interface_name); int ret = ioctl(sock, SIOCGIFFLAGS, &ifr); if (ret < 0) { close(sock); return -1; } if (on) ifr.ifr_flags |= IFF_UP; else ifr.ifr_flags &= ~IFF_UP; ret = ioctl(sock, SIOCSIFFLAGS, &ifr); close(sock); if (ret < 0) { return -1; } return 0; } static int nl80211_set_interface(struct nlmsg* nlmsg, int sock, int nl80211_family, uint32_t ifindex, uint32_t iftype, bool dofail) { struct genlmsghdr genlhdr; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = NL80211_CMD_SET_INTERFACE; netlink_init(nlmsg, nl80211_family, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(nlmsg, NL80211_ATTR_IFINDEX, &ifindex, sizeof(ifindex)); netlink_attr(nlmsg, NL80211_ATTR_IFTYPE, &iftype, sizeof(iftype)); int err = netlink_send_ext(nlmsg, sock, 0, NULL, dofail); if (err < 0) { } return err; } static int nl80211_join_ibss(struct nlmsg* nlmsg, int sock, int nl80211_family, uint32_t ifindex, struct join_ibss_props* props, bool dofail) { struct genlmsghdr genlhdr; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = NL80211_CMD_JOIN_IBSS; netlink_init(nlmsg, nl80211_family, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(nlmsg, NL80211_ATTR_IFINDEX, &ifindex, sizeof(ifindex)); netlink_attr(nlmsg, NL80211_ATTR_SSID, props->ssid, props->ssid_len); netlink_attr(nlmsg, NL80211_ATTR_WIPHY_FREQ, &(props->wiphy_freq), sizeof(props->wiphy_freq)); if (props->mac) netlink_attr(nlmsg, NL80211_ATTR_MAC, props->mac, ETH_ALEN); if (props->wiphy_freq_fixed) netlink_attr(nlmsg, NL80211_ATTR_FREQ_FIXED, NULL, 0); int err = netlink_send_ext(nlmsg, sock, 0, NULL, dofail); if (err < 0) { } return err; } static int get_ifla_operstate(struct nlmsg* nlmsg, int ifindex, bool dofail) { struct ifinfomsg info; memset(&info, 0, sizeof(info)); info.ifi_family = AF_UNSPEC; info.ifi_index = ifindex; int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) { return -1; } netlink_init(nlmsg, RTM_GETLINK, 0, &info, sizeof(info)); int n; int err = netlink_send_ext(nlmsg, sock, RTM_NEWLINK, &n, dofail); close(sock); if (err) { return -1; } struct rtattr* attr = IFLA_RTA(NLMSG_DATA(nlmsg->buf)); for (; RTA_OK(attr, n); attr = RTA_NEXT(attr, n)) { if (attr->rta_type == IFLA_OPERSTATE) return *((int32_t*)RTA_DATA(attr)); } return -1; } static int await_ifla_operstate(struct nlmsg* nlmsg, char* interface, int operstate, bool dofail) { int ifindex = if_nametoindex(interface); while (true) { usleep(1000); int ret = get_ifla_operstate(nlmsg, ifindex, dofail); if (ret < 0) return ret; if (ret == operstate) return 0; } return 0; } static int nl80211_setup_ibss_interface(struct nlmsg* nlmsg, int sock, int nl80211_family_id, char* interface, struct join_ibss_props* ibss_props, bool dofail) { int ifindex = if_nametoindex(interface); if (ifindex == 0) { return -1; } int ret = nl80211_set_interface(nlmsg, sock, nl80211_family_id, ifindex, NL80211_IFTYPE_ADHOC, dofail); if (ret < 0) { return -1; } ret = set_interface_state(interface, 1); if (ret < 0) { return -1; } ret = nl80211_join_ibss(nlmsg, sock, nl80211_family_id, ifindex, ibss_props, dofail); if (ret < 0) { return -1; } return 0; } static int hwsim80211_create_device(struct nlmsg* nlmsg, int sock, int hwsim_family, uint8_t mac_addr[ETH_ALEN]) { struct genlmsghdr genlhdr; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = HWSIM_CMD_NEW_RADIO; netlink_init(nlmsg, hwsim_family, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(nlmsg, HWSIM_ATTR_SUPPORT_P2P_DEVICE, NULL, 0); netlink_attr(nlmsg, HWSIM_ATTR_PERM_ADDR, mac_addr, ETH_ALEN); int err = netlink_send(nlmsg, sock); if (err < 0) { } return err; } static void initialize_wifi_devices(void) { int rfkill = open("/dev/rfkill", O_RDWR); if (rfkill == -1) exit(1); struct rfkill_event event = {0}; event.type = RFKILL_TYPE_ALL; event.op = RFKILL_OP_CHANGE_ALL; if (write(rfkill, &event, sizeof(event)) != (ssize_t)(sizeof(event))) exit(1); close(rfkill); uint8_t mac_addr[6] = WIFI_MAC_BASE; int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC); if (sock < 0) exit(1); int hwsim_family_id = netlink_query_family_id(&nlmsg, sock, "MAC80211_HWSIM", true); int nl80211_family_id = netlink_query_family_id(&nlmsg, sock, "nl80211", true); if (hwsim_family_id < 0 || nl80211_family_id < 0) exit(1); uint8_t ssid[] = WIFI_IBSS_SSID; uint8_t bssid[] = WIFI_IBSS_BSSID; struct join_ibss_props ibss_props = {.wiphy_freq = WIFI_DEFAULT_FREQUENCY, .wiphy_freq_fixed = true, .mac = bssid, .ssid = ssid, .ssid_len = sizeof(ssid)}; for (int device_id = 0; device_id < WIFI_INITIAL_DEVICE_COUNT; device_id++) { mac_addr[5] = device_id; int ret = hwsim80211_create_device(&nlmsg, sock, hwsim_family_id, mac_addr); if (ret < 0) exit(1); char interface[6] = "wlan0"; interface[4] += device_id; if (nl80211_setup_ibss_interface(&nlmsg, sock, nl80211_family_id, interface, &ibss_props, true) < 0) exit(1); } for (int device_id = 0; device_id < WIFI_INITIAL_DEVICE_COUNT; device_id++) { char interface[6] = "wlan0"; interface[4] += device_id; int ret = await_ifla_operstate(&nlmsg, interface, IF_OPER_UP, true); if (ret < 0) exit(1); } close(sock); } #define DEV_IPV4 "172.20.20.%d" #define DEV_IPV6 "fe80::%02x" #define DEV_MAC 0x00aaaaaaaaaa static void netdevsim_add(unsigned int addr, unsigned int port_count) { write_file("/sys/bus/netdevsim/del_device", "%u", addr); if (write_file("/sys/bus/netdevsim/new_device", "%u %u", addr, port_count)) { char buf[32]; snprintf(buf, sizeof(buf), "netdevsim%d", addr); initialize_devlink_ports("netdevsim", buf, "netdevsim"); } } #define WG_GENL_NAME "wireguard" enum wg_cmd { WG_CMD_GET_DEVICE, WG_CMD_SET_DEVICE, }; enum wgdevice_attribute { WGDEVICE_A_UNSPEC, WGDEVICE_A_IFINDEX, WGDEVICE_A_IFNAME, WGDEVICE_A_PRIVATE_KEY, WGDEVICE_A_PUBLIC_KEY, WGDEVICE_A_FLAGS, WGDEVICE_A_LISTEN_PORT, WGDEVICE_A_FWMARK, WGDEVICE_A_PEERS, }; enum wgpeer_attribute { WGPEER_A_UNSPEC, WGPEER_A_PUBLIC_KEY, WGPEER_A_PRESHARED_KEY, WGPEER_A_FLAGS, WGPEER_A_ENDPOINT, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, WGPEER_A_LAST_HANDSHAKE_TIME, WGPEER_A_RX_BYTES, WGPEER_A_TX_BYTES, WGPEER_A_ALLOWEDIPS, WGPEER_A_PROTOCOL_VERSION, }; enum wgallowedip_attribute { WGALLOWEDIP_A_UNSPEC, WGALLOWEDIP_A_FAMILY, WGALLOWEDIP_A_IPADDR, WGALLOWEDIP_A_CIDR_MASK, }; static void netlink_wireguard_setup(void) { const char ifname_a[] = "wg0"; const char ifname_b[] = "wg1"; const char ifname_c[] = "wg2"; const char private_a[] = "\xa0\x5c\xa8\x4f\x6c\x9c\x8e\x38\x53\xe2\xfd\x7a\x70\xae\x0f\xb2\x0f\xa1" "\x52\x60\x0c\xb0\x08\x45\x17\x4f\x08\x07\x6f\x8d\x78\x43"; const char private_b[] = "\xb0\x80\x73\xe8\xd4\x4e\x91\xe3\xda\x92\x2c\x22\x43\x82\x44\xbb\x88\x5c" "\x69\xe2\x69\xc8\xe9\xd8\x35\xb1\x14\x29\x3a\x4d\xdc\x6e"; const char private_c[] = "\xa0\xcb\x87\x9a\x47\xf5\xbc\x64\x4c\x0e\x69\x3f\xa6\xd0\x31\xc7\x4a\x15" "\x53\xb6\xe9\x01\xb9\xff\x2f\x51\x8c\x78\x04\x2f\xb5\x42"; const char public_a[] = "\x97\x5c\x9d\x81\xc9\x83\xc8\x20\x9e\xe7\x81\x25\x4b\x89\x9f\x8e\xd9\x25" "\xae\x9f\x09\x23\xc2\x3c\x62\xf5\x3c\x57\xcd\xbf\x69\x1c"; const char public_b[] = "\xd1\x73\x28\x99\xf6\x11\xcd\x89\x94\x03\x4d\x7f\x41\x3d\xc9\x57\x63\x0e" "\x54\x93\xc2\x85\xac\xa4\x00\x65\xcb\x63\x11\xbe\x69\x6b"; const char public_c[] = "\xf4\x4d\xa3\x67\xa8\x8e\xe6\x56\x4f\x02\x02\x11\x45\x67\x27\x08\x2f\x5c" "\xeb\xee\x8b\x1b\xf5\xeb\x73\x37\x34\x1b\x45\x9b\x39\x22"; const uint16_t listen_a = 20001; const uint16_t listen_b = 20002; const uint16_t listen_c = 20003; const uint16_t af_inet = AF_INET; const uint16_t af_inet6 = AF_INET6; const struct sockaddr_in endpoint_b_v4 = { .sin_family = AF_INET, .sin_port = htons(listen_b), .sin_addr = {htonl(INADDR_LOOPBACK)}}; const struct sockaddr_in endpoint_c_v4 = { .sin_family = AF_INET, .sin_port = htons(listen_c), .sin_addr = {htonl(INADDR_LOOPBACK)}}; struct sockaddr_in6 endpoint_a_v6 = {.sin6_family = AF_INET6, .sin6_port = htons(listen_a)}; endpoint_a_v6.sin6_addr = in6addr_loopback; struct sockaddr_in6 endpoint_c_v6 = {.sin6_family = AF_INET6, .sin6_port = htons(listen_c)}; endpoint_c_v6.sin6_addr = in6addr_loopback; const struct in_addr first_half_v4 = {0}; const struct in_addr second_half_v4 = {(uint32_t)htonl(128 << 24)}; const struct in6_addr first_half_v6 = {{{0}}}; const struct in6_addr second_half_v6 = {{{0x80}}}; const uint8_t half_cidr = 1; const uint16_t persistent_keepalives[] = {1, 3, 7, 9, 14, 19}; struct genlmsghdr genlhdr = {.cmd = WG_CMD_SET_DEVICE, .version = 1}; int sock; int id, err; sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC); if (sock == -1) { return; } id = netlink_query_family_id(&nlmsg, sock, WG_GENL_NAME, true); if (id == -1) goto error; netlink_init(&nlmsg, id, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(&nlmsg, WGDEVICE_A_IFNAME, ifname_a, strlen(ifname_a) + 1); netlink_attr(&nlmsg, WGDEVICE_A_PRIVATE_KEY, private_a, 32); netlink_attr(&nlmsg, WGDEVICE_A_LISTEN_PORT, &listen_a, 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGDEVICE_A_PEERS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_b, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_b_v4, sizeof(endpoint_b_v4)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[0], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v4, sizeof(first_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v6, sizeof(first_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_c, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_c_v6, sizeof(endpoint_c_v6)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[1], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v4, sizeof(second_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v6, sizeof(second_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); err = netlink_send(&nlmsg, sock); if (err < 0) { } netlink_init(&nlmsg, id, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(&nlmsg, WGDEVICE_A_IFNAME, ifname_b, strlen(ifname_b) + 1); netlink_attr(&nlmsg, WGDEVICE_A_PRIVATE_KEY, private_b, 32); netlink_attr(&nlmsg, WGDEVICE_A_LISTEN_PORT, &listen_b, 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGDEVICE_A_PEERS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_a, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_a_v6, sizeof(endpoint_a_v6)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[2], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v4, sizeof(first_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v6, sizeof(first_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_c, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_c_v4, sizeof(endpoint_c_v4)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[3], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v4, sizeof(second_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v6, sizeof(second_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); err = netlink_send(&nlmsg, sock); if (err < 0) { } netlink_init(&nlmsg, id, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(&nlmsg, WGDEVICE_A_IFNAME, ifname_c, strlen(ifname_c) + 1); netlink_attr(&nlmsg, WGDEVICE_A_PRIVATE_KEY, private_c, 32); netlink_attr(&nlmsg, WGDEVICE_A_LISTEN_PORT, &listen_c, 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGDEVICE_A_PEERS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_a, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_a_v6, sizeof(endpoint_a_v6)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[4], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v4, sizeof(first_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &first_half_v6, sizeof(first_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGPEER_A_PUBLIC_KEY, public_b, 32); netlink_attr(&nlmsg, WGPEER_A_ENDPOINT, &endpoint_b_v4, sizeof(endpoint_b_v4)); netlink_attr(&nlmsg, WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL, &persistent_keepalives[5], 2); netlink_nest(&nlmsg, NLA_F_NESTED | WGPEER_A_ALLOWEDIPS); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v4, sizeof(second_half_v4)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_nest(&nlmsg, NLA_F_NESTED | 0); netlink_attr(&nlmsg, WGALLOWEDIP_A_FAMILY, &af_inet6, 2); netlink_attr(&nlmsg, WGALLOWEDIP_A_IPADDR, &second_half_v6, sizeof(second_half_v6)); netlink_attr(&nlmsg, WGALLOWEDIP_A_CIDR_MASK, &half_cidr, 1); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); netlink_done(&nlmsg); err = netlink_send(&nlmsg, sock); if (err < 0) { } error: close(sock); } static void initialize_netdevices(void) { char netdevsim[16]; sprintf(netdevsim, "netdevsim%d", (int)procid); struct { const char* type; const char* dev; } devtypes[] = { {"ip6gretap", "ip6gretap0"}, {"bridge", "bridge0"}, {"vcan", "vcan0"}, {"bond", "bond0"}, {"team", "team0"}, {"dummy", "dummy0"}, {"nlmon", "nlmon0"}, {"caif", "caif0"}, {"batadv", "batadv0"}, {"vxcan", "vxcan1"}, {"veth", 0}, {"wireguard", "wg0"}, {"wireguard", "wg1"}, {"wireguard", "wg2"}, }; const char* devmasters[] = {"bridge", "bond", "team", "batadv"}; struct { const char* name; int macsize; bool noipv6; } devices[] = { {"lo", ETH_ALEN}, {"sit0", 0}, {"bridge0", ETH_ALEN}, {"vcan0", 0, true}, {"tunl0", 0}, {"gre0", 0}, {"gretap0", ETH_ALEN}, {"ip_vti0", 0}, {"ip6_vti0", 0}, {"ip6tnl0", 0}, {"ip6gre0", 0}, {"ip6gretap0", ETH_ALEN}, {"erspan0", ETH_ALEN}, {"bond0", ETH_ALEN}, {"veth0", ETH_ALEN}, {"veth1", ETH_ALEN}, {"team0", ETH_ALEN}, {"veth0_to_bridge", ETH_ALEN}, {"veth1_to_bridge", ETH_ALEN}, {"veth0_to_bond", ETH_ALEN}, {"veth1_to_bond", ETH_ALEN}, {"veth0_to_team", ETH_ALEN}, {"veth1_to_team", ETH_ALEN}, {"veth0_to_hsr", ETH_ALEN}, {"veth1_to_hsr", ETH_ALEN}, {"hsr0", 0}, {"dummy0", ETH_ALEN}, {"nlmon0", 0}, {"vxcan0", 0, true}, {"vxcan1", 0, true}, {"caif0", ETH_ALEN}, {"batadv0", ETH_ALEN}, {netdevsim, ETH_ALEN}, {"xfrm0", ETH_ALEN}, {"veth0_virt_wifi", ETH_ALEN}, {"veth1_virt_wifi", ETH_ALEN}, {"virt_wifi0", ETH_ALEN}, {"veth0_vlan", ETH_ALEN}, {"veth1_vlan", ETH_ALEN}, {"vlan0", ETH_ALEN}, {"vlan1", ETH_ALEN}, {"macvlan0", ETH_ALEN}, {"macvlan1", ETH_ALEN}, {"ipvlan0", ETH_ALEN}, {"ipvlan1", ETH_ALEN}, {"veth0_macvtap", ETH_ALEN}, {"veth1_macvtap", ETH_ALEN}, {"macvtap0", ETH_ALEN}, {"macsec0", ETH_ALEN}, {"veth0_to_batadv", ETH_ALEN}, {"veth1_to_batadv", ETH_ALEN}, {"batadv_slave_0", ETH_ALEN}, {"batadv_slave_1", ETH_ALEN}, {"geneve0", ETH_ALEN}, {"geneve1", ETH_ALEN}, {"wg0", 0}, {"wg1", 0}, {"wg2", 0}, }; int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) exit(1); unsigned i; for (i = 0; i < sizeof(devtypes) / sizeof(devtypes[0]); i++) netlink_add_device(&nlmsg, sock, devtypes[i].type, devtypes[i].dev); for (i = 0; i < sizeof(devmasters) / (sizeof(devmasters[0])); i++) { char master[32], slave0[32], veth0[32], slave1[32], veth1[32]; sprintf(slave0, "%s_slave_0", devmasters[i]); sprintf(veth0, "veth0_to_%s", devmasters[i]); netlink_add_veth(&nlmsg, sock, slave0, veth0); sprintf(slave1, "%s_slave_1", devmasters[i]); sprintf(veth1, "veth1_to_%s", devmasters[i]); netlink_add_veth(&nlmsg, sock, slave1, veth1); sprintf(master, "%s0", devmasters[i]); netlink_device_change(&nlmsg, sock, slave0, false, master, 0, 0, NULL); netlink_device_change(&nlmsg, sock, slave1, false, master, 0, 0, NULL); } netlink_add_xfrm(&nlmsg, sock, "xfrm0"); netlink_device_change(&nlmsg, sock, "bridge_slave_0", true, 0, 0, 0, NULL); netlink_device_change(&nlmsg, sock, "bridge_slave_1", true, 0, 0, 0, NULL); netlink_add_veth(&nlmsg, sock, "hsr_slave_0", "veth0_to_hsr"); netlink_add_veth(&nlmsg, sock, "hsr_slave_1", "veth1_to_hsr"); netlink_add_hsr(&nlmsg, sock, "hsr0", "hsr_slave_0", "hsr_slave_1"); netlink_device_change(&nlmsg, sock, "hsr_slave_0", true, 0, 0, 0, NULL); netlink_device_change(&nlmsg, sock, "hsr_slave_1", true, 0, 0, 0, NULL); netlink_add_veth(&nlmsg, sock, "veth0_virt_wifi", "veth1_virt_wifi"); netlink_add_linked(&nlmsg, sock, "virt_wifi", "virt_wifi0", "veth1_virt_wifi"); netlink_add_veth(&nlmsg, sock, "veth0_vlan", "veth1_vlan"); netlink_add_vlan(&nlmsg, sock, "vlan0", "veth0_vlan", 0, htons(ETH_P_8021Q)); netlink_add_vlan(&nlmsg, sock, "vlan1", "veth0_vlan", 1, htons(ETH_P_8021AD)); netlink_add_macvlan(&nlmsg, sock, "macvlan0", "veth1_vlan"); netlink_add_macvlan(&nlmsg, sock, "macvlan1", "veth1_vlan"); netlink_add_ipvlan(&nlmsg, sock, "ipvlan0", "veth0_vlan", IPVLAN_MODE_L2, 0); netlink_add_ipvlan(&nlmsg, sock, "ipvlan1", "veth0_vlan", IPVLAN_MODE_L3S, IPVLAN_F_VEPA); netlink_add_veth(&nlmsg, sock, "veth0_macvtap", "veth1_macvtap"); netlink_add_linked(&nlmsg, sock, "macvtap", "macvtap0", "veth0_macvtap"); netlink_add_linked(&nlmsg, sock, "macsec", "macsec0", "veth1_macvtap"); char addr[32]; sprintf(addr, DEV_IPV4, 14 + 10); struct in_addr geneve_addr4; if (inet_pton(AF_INET, addr, &geneve_addr4) <= 0) exit(1); struct in6_addr geneve_addr6; if (inet_pton(AF_INET6, "fc00::01", &geneve_addr6) <= 0) exit(1); netlink_add_geneve(&nlmsg, sock, "geneve0", 0, &geneve_addr4, 0); netlink_add_geneve(&nlmsg, sock, "geneve1", 1, 0, &geneve_addr6); netdevsim_add((int)procid, 4); netlink_wireguard_setup(); for (i = 0; i < sizeof(devices) / (sizeof(devices[0])); i++) { char addr[32]; sprintf(addr, DEV_IPV4, i + 10); netlink_add_addr4(&nlmsg, sock, devices[i].name, addr); if (!devices[i].noipv6) { sprintf(addr, DEV_IPV6, i + 10); netlink_add_addr6(&nlmsg, sock, devices[i].name, addr); } uint64_t macaddr = DEV_MAC + ((i + 10ull) << 40); netlink_device_change(&nlmsg, sock, devices[i].name, true, 0, &macaddr, devices[i].macsize, NULL); } close(sock); } static void initialize_netdevices_init(void) { int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) exit(1); struct { const char* type; int macsize; bool noipv6; bool noup; } devtypes[] = { {"nr", 7, true}, {"rose", 5, true, true}, }; unsigned i; for (i = 0; i < sizeof(devtypes) / sizeof(devtypes[0]); i++) { char dev[32], addr[32]; sprintf(dev, "%s%d", devtypes[i].type, (int)procid); sprintf(addr, "172.30.%d.%d", i, (int)procid + 1); netlink_add_addr4(&nlmsg, sock, dev, addr); if (!devtypes[i].noipv6) { sprintf(addr, "fe88::%02x:%02x", i, (int)procid + 1); netlink_add_addr6(&nlmsg, sock, dev, addr); } int macsize = devtypes[i].macsize; uint64_t macaddr = 0xbbbbbb + ((unsigned long long)i << (8 * (macsize - 2))) + (procid << (8 * (macsize - 1))); netlink_device_change(&nlmsg, sock, dev, !devtypes[i].noup, 0, &macaddr, macsize, NULL); } close(sock); } 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 || errno == EBADF || errno == EBADFD) return -1; exit(1); } return rv; } static void flush_tun() { char data[1000]; while (read_tun(&data[0], sizeof(data)) != -1) { } } #define MAX_FDS 30 #define BTPROTO_HCI 1 #define ACL_LINK 1 #define SCAN_PAGE 2 typedef struct { uint8_t b[6]; } __attribute__((packed)) bdaddr_t; #define HCI_COMMAND_PKT 1 #define HCI_EVENT_PKT 4 #define HCI_VENDOR_PKT 0xff struct hci_command_hdr { uint16_t opcode; uint8_t plen; } __attribute__((packed)); struct hci_event_hdr { uint8_t evt; uint8_t plen; } __attribute__((packed)); #define HCI_EV_CONN_COMPLETE 0x03 struct hci_ev_conn_complete { uint8_t status; uint16_t handle; bdaddr_t bdaddr; uint8_t link_type; uint8_t encr_mode; } __attribute__((packed)); #define HCI_EV_CONN_REQUEST 0x04 struct hci_ev_conn_request { bdaddr_t bdaddr; uint8_t dev_class[3]; uint8_t link_type; } __attribute__((packed)); #define HCI_EV_REMOTE_FEATURES 0x0b struct hci_ev_remote_features { uint8_t status; uint16_t handle; uint8_t features[8]; } __attribute__((packed)); #define HCI_EV_CMD_COMPLETE 0x0e struct hci_ev_cmd_complete { uint8_t ncmd; uint16_t opcode; } __attribute__((packed)); #define HCI_OP_WRITE_SCAN_ENABLE 0x0c1a #define HCI_OP_READ_BUFFER_SIZE 0x1005 struct hci_rp_read_buffer_size { uint8_t status; uint16_t acl_mtu; uint8_t sco_mtu; uint16_t acl_max_pkt; uint16_t sco_max_pkt; } __attribute__((packed)); #define HCI_OP_READ_BD_ADDR 0x1009 struct hci_rp_read_bd_addr { uint8_t status; bdaddr_t bdaddr; } __attribute__((packed)); #define HCI_EV_LE_META 0x3e struct hci_ev_le_meta { uint8_t subevent; } __attribute__((packed)); #define HCI_EV_LE_CONN_COMPLETE 0x01 struct hci_ev_le_conn_complete { uint8_t status; uint16_t handle; uint8_t role; uint8_t bdaddr_type; bdaddr_t bdaddr; uint16_t interval; uint16_t latency; uint16_t supervision_timeout; uint8_t clk_accurancy; } __attribute__((packed)); struct hci_dev_req { uint16_t dev_id; uint32_t dev_opt; }; struct vhci_vendor_pkt_request { uint8_t type; uint8_t opcode; } __attribute__((packed)); struct vhci_pkt { uint8_t type; union { struct { uint8_t opcode; uint16_t id; } __attribute__((packed)) vendor_pkt; struct hci_command_hdr command_hdr; }; } __attribute__((packed)); #define HCIDEVUP _IOW('H', 201, int) #define HCISETSCAN _IOW('H', 221, int) static int vhci_fd = -1; static void rfkill_unblock_all() { int fd = open("/dev/rfkill", O_WRONLY); if (fd < 0) exit(1); struct rfkill_event event = {0}; event.idx = 0; event.type = RFKILL_TYPE_ALL; event.op = RFKILL_OP_CHANGE_ALL; event.soft = 0; event.hard = 0; if (write(fd, &event, sizeof(event)) < 0) exit(1); close(fd); } static void hci_send_event_packet(int fd, uint8_t evt, void* data, size_t data_len) { struct iovec iv[3]; struct hci_event_hdr hdr; hdr.evt = evt; hdr.plen = data_len; uint8_t type = HCI_EVENT_PKT; iv[0].iov_base = &type; iv[0].iov_len = sizeof(type); iv[1].iov_base = &hdr; iv[1].iov_len = sizeof(hdr); iv[2].iov_base = data; iv[2].iov_len = data_len; if (writev(fd, iv, sizeof(iv) / sizeof(struct iovec)) < 0) exit(1); } static void hci_send_event_cmd_complete(int fd, uint16_t opcode, void* data, size_t data_len) { struct iovec iv[4]; struct hci_event_hdr hdr; hdr.evt = HCI_EV_CMD_COMPLETE; hdr.plen = sizeof(struct hci_ev_cmd_complete) + data_len; struct hci_ev_cmd_complete evt_hdr; evt_hdr.ncmd = 1; evt_hdr.opcode = opcode; uint8_t type = HCI_EVENT_PKT; iv[0].iov_base = &type; iv[0].iov_len = sizeof(type); iv[1].iov_base = &hdr; iv[1].iov_len = sizeof(hdr); iv[2].iov_base = &evt_hdr; iv[2].iov_len = sizeof(evt_hdr); iv[3].iov_base = data; iv[3].iov_len = data_len; if (writev(fd, iv, sizeof(iv) / sizeof(struct iovec)) < 0) exit(1); } static bool process_command_pkt(int fd, char* buf, ssize_t buf_size) { struct hci_command_hdr* hdr = (struct hci_command_hdr*)buf; if (buf_size < (ssize_t)sizeof(struct hci_command_hdr) || hdr->plen != buf_size - sizeof(struct hci_command_hdr)) exit(1); switch (hdr->opcode) { case HCI_OP_WRITE_SCAN_ENABLE: { uint8_t status = 0; hci_send_event_cmd_complete(fd, hdr->opcode, &status, sizeof(status)); return true; } case HCI_OP_READ_BD_ADDR: { struct hci_rp_read_bd_addr rp = {0}; rp.status = 0; memset(&rp.bdaddr, 0xaa, 6); hci_send_event_cmd_complete(fd, hdr->opcode, &rp, sizeof(rp)); return false; } case HCI_OP_READ_BUFFER_SIZE: { struct hci_rp_read_buffer_size rp = {0}; rp.status = 0; rp.acl_mtu = 1021; rp.sco_mtu = 96; rp.acl_max_pkt = 4; rp.sco_max_pkt = 6; hci_send_event_cmd_complete(fd, hdr->opcode, &rp, sizeof(rp)); return false; } } char dummy[0xf9] = {0}; hci_send_event_cmd_complete(fd, hdr->opcode, dummy, sizeof(dummy)); return false; } static void* event_thread(void* arg) { while (1) { char buf[1024] = {0}; ssize_t buf_size = read(vhci_fd, buf, sizeof(buf)); if (buf_size < 0) exit(1); if (buf_size > 0 && buf[0] == HCI_COMMAND_PKT) { if (process_command_pkt(vhci_fd, buf + 1, buf_size - 1)) break; } } return NULL; } #define HCI_HANDLE_1 200 #define HCI_HANDLE_2 201 #define HCI_PRIMARY 0 #define HCI_OP_RESET 0x0c03 static void initialize_vhci() { int hci_sock = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); if (hci_sock < 0) exit(1); vhci_fd = open("/dev/vhci", O_RDWR); if (vhci_fd == -1) exit(1); const int kVhciFd = 202; if (dup2(vhci_fd, kVhciFd) < 0) exit(1); close(vhci_fd); vhci_fd = kVhciFd; struct vhci_vendor_pkt_request vendor_pkt_req = {HCI_VENDOR_PKT, HCI_PRIMARY}; if (write(vhci_fd, &vendor_pkt_req, sizeof(vendor_pkt_req)) != sizeof(vendor_pkt_req)) exit(1); struct vhci_pkt vhci_pkt; if (read(vhci_fd, &vhci_pkt, sizeof(vhci_pkt)) != sizeof(vhci_pkt)) exit(1); if (vhci_pkt.type == HCI_COMMAND_PKT && vhci_pkt.command_hdr.opcode == HCI_OP_RESET) { char response[1] = {0}; hci_send_event_cmd_complete(vhci_fd, HCI_OP_RESET, response, sizeof(response)); if (read(vhci_fd, &vhci_pkt, sizeof(vhci_pkt)) != sizeof(vhci_pkt)) exit(1); } if (vhci_pkt.type != HCI_VENDOR_PKT) exit(1); int dev_id = vhci_pkt.vendor_pkt.id; pthread_t th; if (pthread_create(&th, NULL, event_thread, NULL)) exit(1); int ret = ioctl(hci_sock, HCIDEVUP, dev_id); if (ret) { if (errno == ERFKILL) { rfkill_unblock_all(); ret = ioctl(hci_sock, HCIDEVUP, dev_id); } if (ret && errno != EALREADY) exit(1); } struct hci_dev_req dr = {0}; dr.dev_id = dev_id; dr.dev_opt = SCAN_PAGE; if (ioctl(hci_sock, HCISETSCAN, &dr)) exit(1); struct hci_ev_conn_request request; memset(&request, 0, sizeof(request)); memset(&request.bdaddr, 0xaa, 6); *(uint8_t*)&request.bdaddr.b[5] = 0x10; request.link_type = ACL_LINK; hci_send_event_packet(vhci_fd, HCI_EV_CONN_REQUEST, &request, sizeof(request)); struct hci_ev_conn_complete complete; memset(&complete, 0, sizeof(complete)); complete.status = 0; complete.handle = HCI_HANDLE_1; memset(&complete.bdaddr, 0xaa, 6); *(uint8_t*)&complete.bdaddr.b[5] = 0x10; complete.link_type = ACL_LINK; complete.encr_mode = 0; hci_send_event_packet(vhci_fd, HCI_EV_CONN_COMPLETE, &complete, sizeof(complete)); struct hci_ev_remote_features features; memset(&features, 0, sizeof(features)); features.status = 0; features.handle = HCI_HANDLE_1; hci_send_event_packet(vhci_fd, HCI_EV_REMOTE_FEATURES, &features, sizeof(features)); struct { struct hci_ev_le_meta le_meta; struct hci_ev_le_conn_complete le_conn; } le_conn; memset(&le_conn, 0, sizeof(le_conn)); le_conn.le_meta.subevent = HCI_EV_LE_CONN_COMPLETE; memset(&le_conn.le_conn.bdaddr, 0xaa, 6); *(uint8_t*)&le_conn.le_conn.bdaddr.b[5] = 0x11; le_conn.le_conn.role = 1; le_conn.le_conn.handle = HCI_HANDLE_2; hci_send_event_packet(vhci_fd, HCI_EV_LE_META, &le_conn, sizeof(le_conn)); pthread_join(th, NULL); close(hci_sock); } //% This code is derived from puff.{c,h}, found in the zlib development. The //% original files come with the following copyright notice: //% Copyright (C) 2002-2013 Mark Adler, all rights reserved //% version 2.3, 21 Jan 2013 //% This software is provided 'as-is', without any express or implied //% warranty. In no event will the author be held liable for any damages //% arising from the use of this software. //% Permission is granted to anyone to use this software for any purpose, //% including commercial applications, and to alter it and redistribute it //% freely, subject to the following restrictions: //% 1. The origin of this software must not be misrepresented; you must not //% claim that you wrote the original software. If you use this software //% in a product, an acknowledgment in the product documentation would be //% appreciated but is not required. //% 2. Altered source versions must be plainly marked as such, and must not be //% misrepresented as being the original software. //% 3. This notice may not be removed or altered from any source distribution. //% Mark Adler madler@alumni.caltech.edu //% BEGIN CODE DERIVED FROM puff.{c,h} #define MAXBITS 15 #define MAXLCODES 286 #define MAXDCODES 30 #define MAXCODES (MAXLCODES + MAXDCODES) #define FIXLCODES 288 struct puff_state { unsigned char* out; unsigned long outlen; unsigned long outcnt; const unsigned char* in; unsigned long inlen; unsigned long incnt; int bitbuf; int bitcnt; jmp_buf env; }; static int puff_bits(struct puff_state* s, int need) { long val = s->bitbuf; while (s->bitcnt < need) { if (s->incnt == s->inlen) longjmp(s->env, 1); val |= (long)(s->in[s->incnt++]) << s->bitcnt; s->bitcnt += 8; } s->bitbuf = (int)(val >> need); s->bitcnt -= need; return (int)(val & ((1L << need) - 1)); } static int puff_stored(struct puff_state* s) { s->bitbuf = 0; s->bitcnt = 0; if (s->incnt + 4 > s->inlen) return 2; unsigned len = s->in[s->incnt++]; len |= s->in[s->incnt++] << 8; if (s->in[s->incnt++] != (~len & 0xff) || s->in[s->incnt++] != ((~len >> 8) & 0xff)) return -2; if (s->incnt + len > s->inlen) return 2; if (s->outcnt + len > s->outlen) return 1; for (; len--; s->outcnt++, s->incnt++) { if (s->in[s->incnt]) s->out[s->outcnt] = s->in[s->incnt]; } return 0; } struct puff_huffman { short* count; short* symbol; }; static int puff_decode(struct puff_state* s, const struct puff_huffman* h) { int first = 0; int index = 0; int bitbuf = s->bitbuf; int left = s->bitcnt; int code = first = index = 0; int len = 1; short* next = h->count + 1; while (1) { while (left--) { code |= bitbuf & 1; bitbuf >>= 1; int count = *next++; if (code - count < first) { s->bitbuf = bitbuf; s->bitcnt = (s->bitcnt - len) & 7; return h->symbol[index + (code - first)]; } index += count; first += count; first <<= 1; code <<= 1; len++; } left = (MAXBITS + 1) - len; if (left == 0) break; if (s->incnt == s->inlen) longjmp(s->env, 1); bitbuf = s->in[s->incnt++]; if (left > 8) left = 8; } return -10; } static int puff_construct(struct puff_huffman* h, const short* length, int n) { int len; for (len = 0; len <= MAXBITS; len++) h->count[len] = 0; int symbol; for (symbol = 0; symbol < n; symbol++) (h->count[length[symbol]])++; if (h->count[0] == n) return 0; int left = 1; for (len = 1; len <= MAXBITS; len++) { left <<= 1; left -= h->count[len]; if (left < 0) return left; } short offs[MAXBITS + 1]; offs[1] = 0; for (len = 1; len < MAXBITS; len++) offs[len + 1] = offs[len] + h->count[len]; for (symbol = 0; symbol < n; symbol++) if (length[symbol] != 0) h->symbol[offs[length[symbol]]++] = symbol; return left; } static int puff_codes(struct puff_state* s, const struct puff_huffman* lencode, const struct puff_huffman* distcode) { static const short lens[29] = {3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258}; static const short lext[29] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0}; static const short dists[30] = { 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577}; static const short dext[30] = {0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13}; int symbol; do { symbol = puff_decode(s, lencode); if (symbol < 0) return symbol; if (symbol < 256) { if (s->outcnt == s->outlen) return 1; if (symbol) s->out[s->outcnt] = symbol; s->outcnt++; } else if (symbol > 256) { symbol -= 257; if (symbol >= 29) return -10; int len = lens[symbol] + puff_bits(s, lext[symbol]); symbol = puff_decode(s, distcode); if (symbol < 0) return symbol; unsigned dist = dists[symbol] + puff_bits(s, dext[symbol]); if (dist > s->outcnt) return -11; if (s->outcnt + len > s->outlen) return 1; while (len--) { if (dist <= s->outcnt && s->out[s->outcnt - dist]) s->out[s->outcnt] = s->out[s->outcnt - dist]; s->outcnt++; } } } while (symbol != 256); return 0; } static int puff_fixed(struct puff_state* s) { static int virgin = 1; static short lencnt[MAXBITS + 1], lensym[FIXLCODES]; static short distcnt[MAXBITS + 1], distsym[MAXDCODES]; static struct puff_huffman lencode, distcode; if (virgin) { lencode.count = lencnt; lencode.symbol = lensym; distcode.count = distcnt; distcode.symbol = distsym; short lengths[FIXLCODES]; int symbol; for (symbol = 0; symbol < 144; symbol++) lengths[symbol] = 8; for (; symbol < 256; symbol++) lengths[symbol] = 9; for (; symbol < 280; symbol++) lengths[symbol] = 7; for (; symbol < FIXLCODES; symbol++) lengths[symbol] = 8; puff_construct(&lencode, lengths, FIXLCODES); for (symbol = 0; symbol < MAXDCODES; symbol++) lengths[symbol] = 5; puff_construct(&distcode, lengths, MAXDCODES); virgin = 0; } return puff_codes(s, &lencode, &distcode); } static int puff_dynamic(struct puff_state* s) { static const short order[19] = {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; int nlen = puff_bits(s, 5) + 257; int ndist = puff_bits(s, 5) + 1; int ncode = puff_bits(s, 4) + 4; if (nlen > MAXLCODES || ndist > MAXDCODES) return -3; short lengths[MAXCODES]; int index; for (index = 0; index < ncode; index++) lengths[order[index]] = puff_bits(s, 3); for (; index < 19; index++) lengths[order[index]] = 0; short lencnt[MAXBITS + 1], lensym[MAXLCODES]; struct puff_huffman lencode = {lencnt, lensym}; int err = puff_construct(&lencode, lengths, 19); if (err != 0) return -4; index = 0; while (index < nlen + ndist) { int symbol; int len; symbol = puff_decode(s, &lencode); if (symbol < 0) return symbol; if (symbol < 16) lengths[index++] = symbol; else { len = 0; if (symbol == 16) { if (index == 0) return -5; len = lengths[index - 1]; symbol = 3 + puff_bits(s, 2); } else if (symbol == 17) symbol = 3 + puff_bits(s, 3); else symbol = 11 + puff_bits(s, 7); if (index + symbol > nlen + ndist) return -6; while (symbol--) lengths[index++] = len; } } if (lengths[256] == 0) return -9; err = puff_construct(&lencode, lengths, nlen); if (err && (err < 0 || nlen != lencode.count[0] + lencode.count[1])) return -7; short distcnt[MAXBITS + 1], distsym[MAXDCODES]; struct puff_huffman distcode = {distcnt, distsym}; err = puff_construct(&distcode, lengths + nlen, ndist); if (err && (err < 0 || ndist != distcode.count[0] + distcode.count[1])) return -8; return puff_codes(s, &lencode, &distcode); } static int puff(unsigned char* dest, unsigned long* destlen, const unsigned char* source, unsigned long sourcelen) { struct puff_state s = { .out = dest, .outlen = *destlen, .outcnt = 0, .in = source, .inlen = sourcelen, .incnt = 0, .bitbuf = 0, .bitcnt = 0, }; int err; if (setjmp(s.env) != 0) err = 2; else { int last; do { last = puff_bits(&s, 1); int type = puff_bits(&s, 2); err = type == 0 ? puff_stored(&s) : (type == 1 ? puff_fixed(&s) : (type == 2 ? puff_dynamic(&s) : -1)); if (err != 0) break; } while (!last); } *destlen = s.outcnt; return err; } //% END CODE DERIVED FROM puff.{c,h} #define ZLIB_HEADER_WIDTH 2 static int puff_zlib_to_file(const unsigned char* source, unsigned long sourcelen, int dest_fd) { if (sourcelen < ZLIB_HEADER_WIDTH) return 0; source += ZLIB_HEADER_WIDTH; sourcelen -= ZLIB_HEADER_WIDTH; const unsigned long max_destlen = 132 << 20; void* ret = mmap(0, max_destlen, PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANON, -1, 0); if (ret == MAP_FAILED) return -1; unsigned char* dest = (unsigned char*)ret; unsigned long destlen = max_destlen; int err = puff(dest, &destlen, source, sourcelen); if (err) { munmap(dest, max_destlen); errno = -err; return -1; } if (write(dest_fd, dest, destlen) != (ssize_t)destlen) { munmap(dest, max_destlen); return -1; } return munmap(dest, max_destlen); } static int setup_loop_device(unsigned char* data, unsigned long size, const char* loopname, int* loopfd_p) { int err = 0, loopfd = -1; int memfd = syscall(__NR_memfd_create, "syzkaller", 0); if (memfd == -1) { err = errno; goto error; } if (puff_zlib_to_file(data, size, memfd)) { err = errno; goto error_close_memfd; } loopfd = open(loopname, O_RDWR); if (loopfd == -1) { err = errno; goto error_close_memfd; } if (ioctl(loopfd, LOOP_SET_FD, memfd)) { if (errno != EBUSY) { err = errno; goto error_close_loop; } ioctl(loopfd, LOOP_CLR_FD, 0); usleep(1000); if (ioctl(loopfd, LOOP_SET_FD, memfd)) { err = errno; goto error_close_loop; } } close(memfd); *loopfd_p = loopfd; return 0; error_close_loop: close(loopfd); error_close_memfd: close(memfd); error: errno = err; return -1; } static void reset_loop_device(const char* loopname) { int loopfd = open(loopname, O_RDWR); if (loopfd == -1) { return; } if (ioctl(loopfd, LOOP_CLR_FD, 0)) { } close(loopfd); } static long syz_mount_image(volatile long fsarg, volatile long dir, volatile long flags, volatile long optsarg, volatile long change_dir, volatile unsigned long size, volatile long image) { unsigned char* data = (unsigned char*)image; int res = -1, err = 0, need_loop_device = !!size; char* mount_opts = (char*)optsarg; char* target = (char*)dir; char* fs = (char*)fsarg; char* source = NULL; char loopname[64]; if (need_loop_device) { int loopfd; memset(loopname, 0, sizeof(loopname)); snprintf(loopname, sizeof(loopname), "/dev/loop%llu", procid); if (setup_loop_device(data, size, loopname, &loopfd) == -1) return -1; close(loopfd); source = loopname; } mkdir(target, 0777); char opts[256]; memset(opts, 0, sizeof(opts)); if (strlen(mount_opts) > (sizeof(opts) - 32)) { } strncpy(opts, mount_opts, sizeof(opts) - 32); if (strcmp(fs, "iso9660") == 0) { flags |= MS_RDONLY; } else if (strncmp(fs, "ext", 3) == 0) { bool has_remount_ro = false; char* remount_ro_start = strstr(opts, "errors=remount-ro"); if (remount_ro_start != NULL) { char after = *(remount_ro_start + strlen("errors=remount-ro")); char before = remount_ro_start == opts ? '\0' : *(remount_ro_start - 1); has_remount_ro = ((before == '\0' || before == ',') && (after == '\0' || after == ',')); } if (strstr(opts, "errors=panic") || !has_remount_ro) strcat(opts, ",errors=continue"); } else if (strcmp(fs, "xfs") == 0) { strcat(opts, ",nouuid"); } res = mount(source, target, fs, flags, opts); if (res == -1) { err = errno; goto error_clear_loop; } res = open(target, O_RDONLY | O_DIRECTORY); if (res == -1) { err = errno; goto error_clear_loop; } if (change_dir) { res = chdir(target); if (res == -1) { err = errno; } } error_clear_loop: if (need_loop_device) reset_loop_device(loopname); errno = err; return res; } static void mount_cgroups(const char* dir, const char** controllers, int count) { if (mkdir(dir, 0777)) { return; } char enabled[128] = {0}; int i = 0; for (; i < count; i++) { if (mount("none", dir, "cgroup", 0, controllers[i])) { continue; } umount(dir); strcat(enabled, ","); strcat(enabled, controllers[i]); } if (enabled[0] == 0) { if (rmdir(dir) && errno != EBUSY) exit(1); return; } if (mount("none", dir, "cgroup", 0, enabled + 1)) { if (rmdir(dir) && errno != EBUSY) exit(1); } if (chmod(dir, 0777)) { } } static void mount_cgroups2(const char** controllers, int count) { if (mkdir("/syzcgroup/unified", 0777)) { return; } if (mount("none", "/syzcgroup/unified", "cgroup2", 0, NULL)) { if (rmdir("/syzcgroup/unified") && errno != EBUSY) exit(1); return; } if (chmod("/syzcgroup/unified", 0777)) { } int control = open("/syzcgroup/unified/cgroup.subtree_control", O_WRONLY); if (control == -1) return; int i; for (i = 0; i < count; i++) if (write(control, controllers[i], strlen(controllers[i])) < 0) { } close(control); } static void setup_cgroups() { const char* unified_controllers[] = {"+cpu", "+io", "+pids"}; const char* net_controllers[] = {"net", "net_prio", "devices", "blkio", "freezer"}; const char* cpu_controllers[] = {"cpuset", "cpuacct", "hugetlb", "rlimit", "memory"}; if (mkdir("/syzcgroup", 0777)) { return; } mount_cgroups2(unified_controllers, sizeof(unified_controllers) / sizeof(unified_controllers[0])); mount_cgroups("/syzcgroup/net", net_controllers, sizeof(net_controllers) / sizeof(net_controllers[0])); mount_cgroups("/syzcgroup/cpu", cpu_controllers, sizeof(cpu_controllers) / sizeof(cpu_controllers[0])); write_file("/syzcgroup/cpu/cgroup.clone_children", "1"); write_file("/syzcgroup/cpu/cpuset.memory_pressure_enabled", "1"); } static void setup_cgroups_loop() { int pid = getpid(); char file[128]; char cgroupdir[64]; snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/unified/syz%llu", procid); if (mkdir(cgroupdir, 0777)) { } snprintf(file, sizeof(file), "%s/pids.max", cgroupdir); write_file(file, "32"); snprintf(file, sizeof(file), "%s/cgroup.procs", cgroupdir); write_file(file, "%d", pid); snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/cpu/syz%llu", procid); if (mkdir(cgroupdir, 0777)) { } snprintf(file, sizeof(file), "%s/cgroup.procs", cgroupdir); write_file(file, "%d", pid); snprintf(file, sizeof(file), "%s/memory.soft_limit_in_bytes", cgroupdir); write_file(file, "%d", 299 << 20); snprintf(file, sizeof(file), "%s/memory.limit_in_bytes", cgroupdir); write_file(file, "%d", 300 << 20); snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/net/syz%llu", procid); if (mkdir(cgroupdir, 0777)) { } snprintf(file, sizeof(file), "%s/cgroup.procs", cgroupdir); write_file(file, "%d", pid); } static void setup_cgroups_test() { char cgroupdir[64]; snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/unified/syz%llu", procid); if (symlink(cgroupdir, "./cgroup")) { } snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/cpu/syz%llu", procid); if (symlink(cgroupdir, "./cgroup.cpu")) { } snprintf(cgroupdir, sizeof(cgroupdir), "/syzcgroup/net/syz%llu", procid); if (symlink(cgroupdir, "./cgroup.net")) { } } static void initialize_cgroups() { if (mkdir("./syz-tmp/newroot/syzcgroup", 0700)) exit(1); if (mkdir("./syz-tmp/newroot/syzcgroup/unified", 0700)) exit(1); if (mkdir("./syz-tmp/newroot/syzcgroup/cpu", 0700)) exit(1); if (mkdir("./syz-tmp/newroot/syzcgroup/net", 0700)) exit(1); unsigned bind_mount_flags = MS_BIND | MS_REC | MS_PRIVATE; if (mount("/syzcgroup/unified", "./syz-tmp/newroot/syzcgroup/unified", NULL, bind_mount_flags, NULL)) { } if (mount("/syzcgroup/cpu", "./syz-tmp/newroot/syzcgroup/cpu", NULL, bind_mount_flags, NULL)) { } if (mount("/syzcgroup/net", "./syz-tmp/newroot/syzcgroup/net", NULL, bind_mount_flags, NULL)) { } } static void setup_binderfs(); static void setup_fusectl(); static void sandbox_common_mount_tmpfs(void) { write_file("/proc/sys/fs/mount-max", "100000"); if (mkdir("./syz-tmp", 0777)) exit(1); if (mount("", "./syz-tmp", "tmpfs", 0, NULL)) exit(1); if (mkdir("./syz-tmp/newroot", 0777)) exit(1); if (mkdir("./syz-tmp/newroot/dev", 0700)) exit(1); unsigned bind_mount_flags = MS_BIND | MS_REC | MS_PRIVATE; if (mount("/dev", "./syz-tmp/newroot/dev", NULL, bind_mount_flags, NULL)) exit(1); if (mkdir("./syz-tmp/newroot/proc", 0700)) exit(1); if (mount("syz-proc", "./syz-tmp/newroot/proc", "proc", 0, NULL)) exit(1); if (mkdir("./syz-tmp/newroot/selinux", 0700)) exit(1); const char* selinux_path = "./syz-tmp/newroot/selinux"; if (mount("/selinux", selinux_path, NULL, bind_mount_flags, NULL)) { if (errno != ENOENT) exit(1); if (mount("/sys/fs/selinux", selinux_path, NULL, bind_mount_flags, NULL) && errno != ENOENT) exit(1); } if (mkdir("./syz-tmp/newroot/sys", 0700)) exit(1); if (mount("/sys", "./syz-tmp/newroot/sys", 0, bind_mount_flags, NULL)) exit(1); if (mount("/sys/kernel/debug", "./syz-tmp/newroot/sys/kernel/debug", NULL, bind_mount_flags, NULL) && errno != ENOENT) exit(1); if (mount("/sys/fs/smackfs", "./syz-tmp/newroot/sys/fs/smackfs", NULL, bind_mount_flags, NULL) && errno != ENOENT) exit(1); if (mount("/proc/sys/fs/binfmt_misc", "./syz-tmp/newroot/proc/sys/fs/binfmt_misc", NULL, bind_mount_flags, NULL) && errno != ENOENT) exit(1); initialize_cgroups(); if (mkdir("./syz-tmp/pivot", 0777)) exit(1); if (syscall(SYS_pivot_root, "./syz-tmp", "./syz-tmp/pivot")) { if (chdir("./syz-tmp")) exit(1); } else { if (chdir("/")) exit(1); if (umount2("./pivot", MNT_DETACH)) exit(1); } if (chroot("./newroot")) exit(1); if (chdir("/")) exit(1); setup_binderfs(); setup_fusectl(); } static void setup_fusectl() { if (mount(0, "/sys/fs/fuse/connections", "fusectl", 0, 0)) { } } static void setup_binderfs() { if (mkdir("/dev/binderfs", 0777)) { } if (mount("binder", "/dev/binderfs", "binder", 0, NULL)) { } } static void loop(); static void sandbox_common() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); if (getppid() == 1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = (200 << 20); setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 32 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 136 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); if (unshare(CLONE_NEWNS)) { } if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL)) { } if (unshare(CLONE_NEWIPC)) { } if (unshare(0x02000000)) { } if (unshare(CLONE_NEWUTS)) { } if (unshare(CLONE_SYSVSEM)) { } typedef struct { const char* name; const char* value; } sysctl_t; static const sysctl_t sysctls[] = { {"/proc/sys/kernel/shmmax", "16777216"}, {"/proc/sys/kernel/shmall", "536870912"}, {"/proc/sys/kernel/shmmni", "1024"}, {"/proc/sys/kernel/msgmax", "8192"}, {"/proc/sys/kernel/msgmni", "1024"}, {"/proc/sys/kernel/msgmnb", "1024"}, {"/proc/sys/kernel/sem", "1024 1048576 500 1024"}, }; unsigned i; for (i = 0; i < sizeof(sysctls) / sizeof(sysctls[0]); i++) write_file(sysctls[i].name, sysctls[i].value); } static int wait_for_loop(int pid) { if (pid < 0) exit(1); int status = 0; while (waitpid(-1, &status, __WALL) != pid) { } return WEXITSTATUS(status); } static void drop_caps(void) { struct __user_cap_header_struct cap_hdr = {}; struct __user_cap_data_struct cap_data[2] = {}; cap_hdr.version = _LINUX_CAPABILITY_VERSION_3; cap_hdr.pid = getpid(); if (syscall(SYS_capget, &cap_hdr, &cap_data)) exit(1); const int drop = (1 << CAP_SYS_PTRACE) | (1 << CAP_SYS_NICE); cap_data[0].effective &= ~drop; cap_data[0].permitted &= ~drop; cap_data[0].inheritable &= ~drop; if (syscall(SYS_capset, &cap_hdr, &cap_data)) exit(1); } static int do_sandbox_none(void) { if (unshare(CLONE_NEWPID)) { } int pid = fork(); if (pid != 0) return wait_for_loop(pid); initialize_vhci(); sandbox_common(); drop_caps(); initialize_netdevices_init(); if (unshare(CLONE_NEWNET)) { } write_file("/proc/sys/net/ipv4/ping_group_range", "0 65535"); initialize_tun(); initialize_netdevices(); initialize_wifi_devices(); sandbox_common_mount_tmpfs(); loop(); exit(1); } #define FS_IOC_SETFLAGS _IOW('f', 2, long) static void remove_dir(const char* dir) { int iter = 0; DIR* dp = 0; const int umount_flags = MNT_FORCE | UMOUNT_NOFOLLOW; retry: while (umount2(dir, umount_flags) == 0) { } dp = opendir(dir); if (dp == NULL) { if (errno == EMFILE) { exit(1); } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); while (umount2(filename, umount_flags) == 0) { } struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } int i; for (i = 0;; i++) { if (unlink(filename) == 0) break; if (errno == EPERM) { int fd = open(filename, O_RDONLY); if (fd != -1) { long flags = 0; if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) { } close(fd); continue; } } if (errno == EROFS) { break; } if (errno != EBUSY || i > 100) exit(1); if (umount2(filename, umount_flags)) exit(1); } } closedir(dp); for (int i = 0;; i++) { if (rmdir(dir) == 0) break; if (i < 100) { if (errno == EPERM) { int fd = open(dir, O_RDONLY); if (fd != -1) { long flags = 0; if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) { } close(fd); continue; } } if (errno == EROFS) { break; } if (errno == EBUSY) { if (umount2(dir, umount_flags)) exit(1); continue; } if (errno == ENOTEMPTY) { if (iter < 100) { iter++; goto retry; } } } exit(1); } } static void kill_and_wait(int pid, int* status) { kill(-pid, SIGKILL); kill(pid, SIGKILL); for (int i = 0; i < 100; i++) { if (waitpid(-1, status, WNOHANG | __WALL) == pid) return; usleep(1000); } DIR* dir = opendir("/sys/fs/fuse/connections"); if (dir) { for (;;) { struct dirent* ent = readdir(dir); if (!ent) break; if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) continue; char abort[300]; snprintf(abort, sizeof(abort), "/sys/fs/fuse/connections/%s/abort", ent->d_name); int fd = open(abort, O_WRONLY); if (fd == -1) { continue; } if (write(fd, abort, 1) < 0) { } close(fd); } closedir(dir); } else { } while (waitpid(-1, status, __WALL) != pid) { } } static void setup_loop() { setup_cgroups_loop(); } static void reset_loop() { char buf[64]; snprintf(buf, sizeof(buf), "/dev/loop%llu", procid); int loopfd = open(buf, O_RDWR); if (loopfd != -1) { ioctl(loopfd, LOOP_CLR_FD, 0); close(loopfd); } } static void setup_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); setup_cgroups_test(); write_file("/proc/self/oom_score_adj", "1000"); flush_tun(); if (symlink("/dev/binderfs", "./binderfs")) { } } static void close_fds() { for (int fd = 3; fd < MAX_FDS; fd++) close(fd); } static const char* setup_usb() { if (chmod("/dev/raw-gadget", 0666)) return "failed to chmod /dev/raw-gadget"; return NULL; } static void setup_sysctl() { int cad_pid = fork(); if (cad_pid < 0) exit(1); if (cad_pid == 0) { for (;;) sleep(100); } char tmppid[32]; snprintf(tmppid, sizeof(tmppid), "%d", cad_pid); struct { const char* name; const char* data; } files[] = { {"/proc/sys/kernel/hung_task_check_interval_secs", "20"}, {"/proc/sys/net/core/bpf_jit_kallsyms", "1"}, {"/proc/sys/net/core/bpf_jit_harden", "0"}, {"/proc/sys/kernel/kptr_restrict", "0"}, {"/proc/sys/kernel/softlockup_all_cpu_backtrace", "1"}, {"/proc/sys/fs/mount-max", "100"}, {"/proc/sys/vm/oom_dump_tasks", "0"}, {"/proc/sys/debug/exception-trace", "0"}, {"/proc/sys/kernel/printk", "7 4 1 3"}, {"/proc/sys/kernel/keys/gc_delay", "1"}, {"/proc/sys/vm/oom_kill_allocating_task", "1"}, {"/proc/sys/kernel/ctrl-alt-del", "0"}, {"/proc/sys/kernel/cad_pid", tmppid}, }; for (size_t i = 0; i < sizeof(files) / sizeof(files[0]); i++) { if (!write_file(files[i].name, files[i].data)) { } } kill(cad_pid, SIGKILL); while (waitpid(cad_pid, NULL, 0) != cad_pid) ; } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { setup_loop(); int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); reset_loop(); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); setup_test(); execute_one(); close_fds(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } NONFAILING( memcpy((void*)0x200010c0, "blkio.bfq.io_service_time_recursive\000", 36)); res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x200010c0ul, /*flags=*/0x275a, /*mode=*/0); if (res != -1) r[0] = res; res = syscall(__NR_read, /*fd=*/r[0], /*buf=*/0x20006940ul, /*len=*/0x2020ul); if (res != -1) NONFAILING(r[1] = *(uint32_t*)0x20006958); NONFAILING(memcpy((void*)0x20000000, "exfat\000", 6)); NONFAILING(memcpy((void*)0x20000140, "./file0\000", 8)); NONFAILING(memcpy( (void*)0x20000180, "dmask=00000000000000000000007,utf8,iocharset=iso8859-1,allow_utime=" "00000000000000000002001,fmask=00000000000000000000002,allow_utime=" "00000000000000000000005,umask=00000000000000000000001,gid=", 191)); NONFAILING(sprintf((char*)0x2000023f, "0x%016llx", (long long)r[1])); NONFAILING(memcpy((void*)0x20000251, ",uid=", 5)); NONFAILING(sprintf((char*)0x20000256, "0x%016llx", (long long)-1)); NONFAILING(memcpy( (void*)0x20000268, "\x96\xee\xaf\x70\xb4\x47\x60\x1a\xa8\x27\xb0\xbd\x12\x5c\xb2\x33\x1a\x79" "\x9e\xa5\xf0\x5e\x24\x87\xa2\x56\xe6\xe0\xcd\x1d\x0f\x74\x26\xa5\x44\x52" "\x2e\x1c\x20\x28\x0b\x53\xea\xd1\xc1\x19\x02\x56\xaf\x23\x82\x7a\xb3\x69" "\xda\x27\x15\xc4\x1a\x22\xcd\x4c\x34\x87\xfa\x6b\x09\x25\x8c\xc5\xc6\xf5" "\xea\x56\x70\x39\xa1\x8f\x3d\x03\xa9\xe4\xbc\x10\xa2\x37\x00\x96\x7f\x87" "\x83\x23\x13\xac\x6f\x81\x6b\x45\x39\x71\xaf\xf4\xcd\x80\xc7\x44\x76\xdc" "\xe0\x7e\xf5\xa2\xbc\xf2\xee\xca\x5f\x8d\x7c\x00\x9e\x56\x1a\x93\x4b\x56" "\x93\x91\xc4\x01\x5e\xe6\xcd\x31\x46\x00\xd4\xc3\x22\xfc\xd4\x0b\xc4\x22" "\x66\xeb\x0b\xc7\x1d\x86\xa9\xba\x1e\xfb\xc5\xcb\xc8\x7c\x90\x14\x28\x7b" "\x2f\xd6\xc5\xa2\x0d\xfb\x87\x09\x03\x1d\x40\xcd\xdd\xdd\x02\xca\x9f\x0f" "\x86\x9e\x80\xb1\xc3\x25\x1a\xa7\xe7\x11\x0b\x49\x91\x8e\xa1\x86\xe4\x70" "\x6f\xde\xdb\x70\x7a\xb6\x07\xb8\x26\xdd\x3c\xf8\x34\xb8\xc5\x45\x37\x7e" "\x7b\x82\x07\xc7\x3e\x68\xb2\x90\x7e\x8f\x29\xd6\x3a\x0d\x97\xd7\xe4\xf7" "\xcb\x7a\x8b\xdc\xeb\xe9\xa6\x87\x74\x84\x2b\x0f\x2d\xb3\x67", 249)); NONFAILING(memcpy( (void*)0x20002a40, "\x78\x9c\xec\xdc\x0b\x98\x8d\x55\xfb\x30\xf0\x75\xaf\xb5\x1e\xc6\x34\xb1" "\x9b\xe4\x30\xac\x7b\xdd\x0f\x3b\x0d\x96\x43\x92\x1c\x92\xe4\x90\x24\x49" "\x92\xe4\x94\x90\x34\x49\x92\x90\x18\x72\x4a\x1a\x92\x90\xe3\x24\x89\x21" "\x24\x87\x69\x4c\x1a\xe7\xf3\x21\xe7\x24\x79\xa5\x49\x92\x9c\x72\x0a\xeb" "\xbb\xa6\xde\xf7\xf3\x7f\xdf\xde\xf7\xeb\xfb\x7f\x6f\xdf\xdf\xf7\xfd\xe7" "\xfe\x5d\xd7\xba\xf6\xba\x67\xef\x7b\xed\x7b\xed\x7b\xcf\xec\xe7\x79\xe6" "\xba\xf6\x0f\x3d\x47\xd5\x6b\x51\xbf\x76\x33\x22\x12\xff\x16\xf8\xed\x26" "\x59\x08\x11\x23\x84\x18\x26\x84\x28\x20\x84\x08\x84\x10\x95\xe3\x2b\xc7" "\xe7\xdc\x9f\x4f\x41\xf2\xbf\xf7\x24\xec\xcf\xf5\x48\xda\xb5\xae\x80\x5d" "\x4b\xdc\xff\xdc\x8d\xfb\x9f\xbb\x71\xff\x73\x37\xee\x7f\xee\xc6\xfd\xcf" "\xdd\xb8\xff\xb9\x1b\xf7\x3f\x77\xe3\xfe\x33\x96\x9b\x6d\x9b\x5d\xf4\x06" "\x1e\xb9\x77\xf0\xf5\xff\xdc\x8c\x3f\xff\xff\x1b\xc9\x2e\x37\xf9\x9b\x0d" "\xe5\x6e\xea\xf5\x9f\x48\xe1\xfe\xe7\x6e\xdc\xff\xdc\x8d\xfb\x9f\xbb\x71" "\xff\x73\x37\xee\x7f\xee\xc6\xfd\xcf\xdd\xb8\xff\xb9\x1b\xf7\x9f\xb1\xdc" "\xec\x5a\x5f\x7f\xe6\x71\x6d\xc7\xb5\x7e\xff\x31\xc6\x18\x63\x8c\x31\xc6" "\x18\x63\x8c\x31\xc6\x18\x63\x8c\x31\xc6\x18\x63\x8c\x31\xc6\x18\x63\x8c" "\x31\xc6\x18\x63\x8c\x31\xc6\x18\x63\x8c\x31\xc6\x18\x63\x8c\x31\xc6\x18" "\x63\x8c\x31\xc6\x18\x63\x8c\x31\xc6\x18\x63\x8c\x31\xc6\x18\x63\x8c\x31" "\xc6\x18\x63\x8c\x31\xc6\x18\x63\x8c\x31\xc6\x18\x63\x8c\x31\xc6\x18\x63" "\x8c\x31\xc6\x18\x63\x8c\x31\xc6\x18\x63\x8c\x31\xc6\x18\x63\x8c\x31\xc6" "\x18\x63\x8c\x31\xc6\x18\x63\x8c\x31\xc6\x18\x63\x8c\x31\xc6\x18\x63\x8c" "\x31\xc6\x18\x63\x8c\x31\xc6\x18\x63\x8c\x31\xc6\x18\xcb\x1d\xce\xfb\xab" "\xb4\x10\x22\xe7\x36\xf8\x57\x0f\x4e\xfe\xaf\xad\x8d\x31\xc6\x18\x63\x8c" "\x31\xc6\x18\x63\x7f\x0e\x9f\xf7\x5a\x57\xc0\x18\x63\x8c\x31\xc6\x18\x63" "\x8c\xb1\xff\xfb\x40\x48\xa1\x84\x16\x81\xc8\x23\xf2\x8a\x18\x91\x4f\xc4" "\x8a\xeb\x44\x9c\xb8\x5e\xe4\x17\x05\x44\x44\xdc\x20\xe2\xc5\x8d\xa2\xa0" "\xb8\x49\x14\x12\x85\x45\x11\x51\x54\x24\x88\x62\xa2\xb8\x30\x02\x85\x15" "\x24\x42\x51\x42\x94\x14\x51\x71\xb3\x28\x25\x6e\x11\x89\xa2\xb4\x28\x23" "\xca\x0a\x27\xca\x89\xf2\xa2\x82\xa8\x28\x6e\x15\x95\xc4\x6d\xa2\xb2\xb8" "\x5d\x54\x11\x77\x88\xaa\xa2\x9a\xa8\x2e\x6a\x88\x3b\x45\x4d\x71\x97\xa8" "\x25\xee\x16\xb5\xc5\x3d\xa2\x8e\xa8\x2b\xea\x89\xfa\xe2\x5e\xd1\x40\xdc" "\x27\x1a\x8a\xfb\x45\x23\xf1\x80\x68\x2c\x1e\x14\x4d\xc4\x43\xa2\xa9\x78" "\x58\x34\x13\x8f\x88\xe6\xe2\x51\xd1\x42\x3c\x26\x5a\x8a\xc7\x45\x2b\xd1" "\x5a\xb4\x11\x6d\x45\xbb\xff\xa3\xfc\x97\x45\x5f\xf1\x8a\xe8\x27\xfa\x8b" "\x64\x31\x40\x0c\x14\xaf\x8a\x41\x62\xb0\x18\x22\x86\x8a\x61\xe2\x35\x31" "\x5c\xbc\x2e\x46\x88\x37\x44\x8a\x18\x29\x46\x89\x37\xc5\x68\xf1\x96\x18" "\x23\xde\x16\x63\xc5\x38\x31\x5e\xbc\x23\x26\x88\x89\x62\x92\x98\x2c\xa6" "\x88\xa9\x22\x55\xbc\x2b\xa6\x89\xf7\xc4\x74\xf1\xfe\xc8\xbf\xbd\xa2\x69" "\x62\xb6\x98\x23\x3e\x14\x73\xc5\x3c\x31\x5f\x7c\x24\x16\x88\x8f\xc5\x42" "\xb1\x48\x2c\x16\x4b\x44\xba\xf8\x44\x64\x88\xa5\x22\x53\x7c\x2a\x96\x89" "\xcf\x44\x96\x58\x2e\x56\x88\x95\x62\x95\x58\x2d\xd6\x88\xb5\x62\x9d\x58" "\x2f\x36\x88\x8d\x62\x93\xd8\x2c\xb6\x88\xad\x62\x9b\xf8\x5c\x6c\x17\x3b" "\xc4\x4e\xb1\x4b\xec\x16\x7b\xc4\x5e\xf1\x85\xd8\x27\xbe\x14\xfb\xc5\x57" "\xe2\x80\xf8\xfa\x3f\x99\x7f\xee\x1f\xf2\x7b\x81\x00\x01\x12\x24\x68\xd0" "\x90\x07\xf2\x40\x0c\xc4\x40\x2c\xc4\x42\x1c\xc4\x41\x7e\xc8\x0f\x11\x88" "\x40\x3c\xc4\x43\x41\x28\x08\x85\xa0\x10\x14\x81\x22\x90\x00\x09\x50\x1c" "\x8a\x03\x02\x02\x01\x41\x09\x28\x01\x51\x88\x42\x29\x28\x05\x89\x90\x08" "\x65\xa0\x0c\x38\x70\x50\x1e\xca\x43\x45\xb8\x15\x2a\x41\x25\xa8\x0c\x95" "\xa1\x0a\x54\x81\xaa\x50\x0d\xaa\x41\x0d\xa8\x01\x35\xa1\x26\xd4\x82\x5a" "\x50\x1b\x6a\x43\x1d\xa8\x03\xf5\xa0\x1e\xdc\x0b\xf7\xc2\x7d\xd0\x10\x1a" "\x42\x23\x68\x04\x8d\xa1\x31\x34\x81\x26\xd0\x14\x9a\x42\x33\x68\x06\xcd" "\xa1\x39\xb4\x80\x16\xd0\x12\x5a\x42\x2b\x68\x05\x6d\xa0\x0d\xb4\x83\x76" "\xd0\x1e\xda\x43\x07\xe8\x00\x9d\xa0\x13\x74\x86\xce\xd0\x05\xba\x40\x12" "\x24\x41\x57\xe8\x0a\xdd\xa0\x1b\x74\x87\xee\xd0\x03\x7a\x40\x4f\xe8\x09" "\xbd\xa0\x37\xf4\x86\x97\xe1\x65\x78\x05\x5e\x81\xfe\x50\x47\x0e\x80\x81" "\x30\x10\x06\xc1\x20\x18\x02\x43\x61\x28\xbc\x06\xc3\xe1\x75\x78\x1d\xde" "\x80\x14\x18\x09\xa3\xe0\x4d\x78\x13\xde\x82\x31\x70\x16\xc6\xc2\x38\x18" "\x0f\xe3\xa1\xa6\x9c\x08\x93\x60\x32\x90\x9c\x0a\xa9\x90\x0a\xd3\x60\x1a" "\x4c\x87\xe9\x30\x03\x3e\x80\x0f\x60\x16\xa4\xc1\x6c\x98\x03\x73\x60\x2e" "\xcc\x83\x79\xf0\x11\x2c\x80\x8f\xe1\x63\x58\x04\x8b\x60\x09\xa4\x43\x3a" "\x64\xc0\x52\xc8\x84\x4c\x58\x06\xe7\x20\x0b\x96\xc3\x0a\x58\x09\xab\x60" "\x35\xac\x82\xb5\xb0\x0e\xd6\xc2\x06\xd8\x08\x1b\x60\x33\x6c\x86\xad\xb0" "\x15\x3e\x87\xcf\x61\x07\xec\x80\x5d\xb0\x0b\xf6\xc0\x1e\xf8\x02\xbe\x80" "\x2f\xe1\x4b\x48\x81\x03\x00\xfa\xb7\x77\xdc\x21\x38\x0c\x87\x21\x1b\xb2" "\xe1\x08\x1c\x81\xa3\x70\x14\x8e\xc1\x31\x38\x0e\xc7\xe1\x04\x9c\x84\x53" "\x70\x12\xce\xc0\x19\x38\x0b\xe7\xe0\x3c\x9c\x87\x8b\x70\x11\x2e\xc1\x8b" "\x09\xdf\x35\xdf\x53\x7a\x7d\x8a\x90\x39\xb4\xd4\x32\x8f\xcc\x23\x63\x64" "\x8c\x8c\x95\xb1\x32\x4e\xc6\xc9\xfc\x32\xbf\x8c\xc8\x88\x8c\x97\xf1\xb2" "\xa0\x2c\x28\x0b\xc9\x42\xb2\x88\x2c\x22\x13\x64\x82\x2c\x2e\x8b\x4b\x94" "\x28\x49\x86\xb2\x84\x2c\x21\xa3\x32\x2a\x4b\xc9\x52\x32\x51\x26\xca\x32" "\xb2\x8c\x74\xd2\xc9\xf2\xb2\xbc\xac\x28\x2b\xca\x4a\xb2\x92\xac\x2c\x6f" "\x97\x55\xe4\x1d\xb2\xaa\xac\x26\x3b\xba\x1a\xb2\x86\xac\x29\x3b\xb9\x5a" "\xf2\x6e\x59\x5b\xd6\x96\x75\x64\x5d\x59\x4f\xd6\x97\xf5\x65\x03\xd9\x40" "\x36\x94\x0d\x65\x23\xd9\x48\x36\x96\x8d\x65\x13\xf9\x90\x6c\x2a\x07\xc0" "\x10\x78\x44\xe6\x74\xa6\x85\x1c\x09\x2d\xe5\x28\x68\x25\x5b\xcb\x36\xb2" "\xad\x7c\x0b\x9e\x90\xed\xe5\x18\xe8\x20\x3b\xca\x4e\xf2\x29\x39\x0e\xc6" "\x42\x17\xd9\xde\x25\xc9\x67\x65\x57\x39\x09\xba\xc9\xe7\xe5\x64\x78\x41" "\xf6\x90\x53\xa1\xa7\x7c\x49\xf6\x92\xbd\x65\x1f\xf9\xb2\xec\x2b\x3b\xb8" "\x7e\xb2\xbf\x9c\x01\x03\xe4\x40\x39\x0b\x06\xc9\xc1\x72\x88\x1c\x2a\xe7" "\x42\x5d\x99\xd3\xb1\x7a\xf2\x0d\x99\x22\x47\xca\x51\xf2\x4d\xb9\x04\xde" "\x92\x63\xe4\xdb\x72\xac\x1c\x27\xc7\xcb\x77\xe4\x04\x39\x51\x4e\x92\x93" "\xe5\x14\x39\x55\xa6\xca\x77\xe5\x34\xf9\x9e\x9c\x2e\xdf\x97\x33\xe4\x07" "\x72\xa6\x9c\x25\xd3\xe4\x6c\x39\x47\x7e\x28\xe7\xca\x79\x72\xbe\xfc\x48" "\x2e\x90\x1f\xcb\x85\x72\x91\x5c\x2c\x97\xc8\x74\xf9\x89\xcc\x90\x4b\x65" "\xa6\xfc\x54\x2e\x93\x9f\xc9\x2c\xb9\x5c\xae\x90\x2b\xe5\x2a\xb9\x5a\xae" "\x91\x6b\xe5\x3a\xb9\x5e\x6e\x90\x1b\xe5\x26\xb9\x59\x6e\x91\x5b\xe5\x36" "\xf9\xb9\xdc\x2e\x77\xc8\x9d\x72\x97\xdc\x2d\xf7\xc8\xbd\xf2\x0b\xb9\x4f" "\x7e\x29\xf7\xcb\xaf\xe4\x01\xf9\xb5\x3c\x28\xff\x22\x0f\xc9\x6f\xe4\x61" "\xf9\xad\xcc\x96\xdf\xc9\x23\xf2\x7b\x79\x54\xfe\x20\x8f\xc9\x1f\xe5\x71" "\xf9\x93\x3c\x21\x4f\xca\x53\xf2\xb4\x3c\x23\x7f\x96\x67\xe5\x39\x79\x5e" "\x5e\x90\x17\xe5\x2f\xf2\x92\xbc\x2c\xaf\x48\x2f\x85\x02\x25\x95\x52\x5a" "\x05\x2a\x8f\xca\xab\x62\x54\x3e\x15\xab\xae\x53\x71\xea\x7a\x95\x5f\x15" "\x50\x11\x75\x83\x8a\x57\x37\xaa\x82\xea\x26\x55\x48\x15\x56\x45\x54\x51" "\x95\xa0\x8a\xa9\xe2\xca\x28\x54\x56\x91\x0a\x55\x09\x55\x52\x45\xd5\xcd" "\xaa\x94\xba\x45\x25\xaa\xd2\xaa\x8c\x2a\xab\x9c\x2a\xa7\xca\xab\x0a\xaa" "\xa2\xba\x55\x55\x52\xb7\xa9\xca\xea\x76\x55\x45\xdd\xa1\xaa\xaa\x6a\xaa" "\xba\xaa\xa1\xee\x54\x35\xd5\x5d\xaa\x96\xba\x5b\xd5\x56\xf7\xa8\x3a\xaa" "\xae\xaa\xa7\xea\xab\x7b\x55\x03\x75\x9f\x6a\xa8\xee\x57\x8d\xd4\x03\xaa" "\xb1\x7a\x50\x35\x51\x0f\xa9\xa6\xea\x61\xd5\x4c\x3d\xa2\x9a\xab\x47\x55" "\x0b\xf5\x98\x6a\xa9\x1e\x57\xad\x54\x6b\xd5\x46\xb5\x55\xed\xd4\x13\xaa" "\xbd\x7a\x52\x75\x50\x1d\x55\x27\xf5\x94\xea\xac\x9e\x56\x5d\xd4\x33\x2a" "\x49\x3d\xab\xba\xaa\xe7\x54\x37\xf5\xbc\xea\xae\x5e\x50\x3d\xd4\x8b\xaa" "\xa7\x7a\x49\xf5\x52\xbd\x55\x1f\x75\x59\x5d\x51\x5e\xf5\x53\xfd\x55\xb2" "\x1a\xa0\x06\xaa\x57\xd5\x20\x35\x58\x0d\x51\x43\xd5\x30\xf5\x9a\x1a\xae" "\x5e\x57\x23\xd4\x1b\x2a\x45\x8d\x54\xa3\xd4\x9b\x6a\xb4\x7a\x4b\x8d\x51" "\x6f\xab\xb1\x6a\x9c\x1a\xaf\xde\x51\x13\xd4\x44\x35\x49\x4d\x56\x53\xd4" "\x54\x95\xaa\xde\x55\xd3\xd4\x7b\x6a\xba\x7a\x5f\xcd\x50\x1f\xa8\x99\x6a" "\x96\x4a\x53\xb3\xd5\x90\xbf\xae\x34\xff\x7f\x23\xff\xbd\x7f\x92\x3f\xe2" "\xd7\x67\xdf\xaa\xb6\xa9\xcf\xd5\x76\xb5\x43\xed\x54\xbb\xd4\x6e\xb5\x47" "\xed\x55\x7b\xd5\x3e\xb5\x4f\xed\x57\xfb\xd5\x01\x75\x40\x1d\x54\x07\xd5" "\x21\x75\x48\x1d\x56\x87\x55\xb6\xca\x56\x47\xd4\x11\x75\x54\x1d\x55\xc7" "\xd4\x31\x75\x5c\x1d\x57\x27\xd4\x49\x75\x41\x9d\x56\x67\xd4\xcf\xea\xac" "\x3a\xa7\xce\xa9\x0b\xea\xa2\xba\xa8\x2e\xfd\xf5\x35\x10\x1a\xb4\xd4\x4a" "\x6b\x1d\xe8\x3c\x3a\xaf\x8e\xd1\xf9\x74\xac\xbe\x4e\xc7\xe9\xeb\x75\x7e" "\x5d\x40\x47\xf4\x0d\x3a\x5e\xdf\xa8\x0b\xea\x9b\x74\x21\x5d\x58\x17\xd1" "\x45\x75\x82\x2e\xa6\x8b\x6b\xa3\x51\x5b\x4d\x3a\xd4\x25\x74\x49\x1d\xd5" "\x37\xeb\x52\xfa\x16\x9d\xa8\x4b\xeb\x32\xba\xac\x76\xba\x9c\xf6\xba\xc2" "\xbf\x95\x5f\x5e\x57\xd0\x7f\x54\x5f\x3b\xdd\x4e\xb7\xd7\xed\x75\x07\xdd" "\x41\x77\xd2\x9d\x74\x67\xdd\x59\x77\xd1\x5d\x74\x92\x4e\xd2\x5d\x75\x57" "\xdd\x4d\x77\xd3\xdd\x75\x77\xdd\x43\xf7\xd0\x3d\x75\x4f\xdd\x4b\xf7\xd2" "\x7d\x74\x1f\xdd\x57\xf7\xd5\xfd\x74\x3f\x9d\xac\x93\xf5\x40\xfd\xaa\x1e" "\xa4\x07\xeb\x21\x7a\xa8\x1e\xa6\x5f\xd3\xc3\xf5\x70\x3d\x42\x8f\xd0\x29" "\x3a\x45\x8f\xd2\xa3\xf4\x68\x3d\x5a\x8f\xd1\x63\xf4\x58\x3d\x56\x8f\xd7" "\xe3\xf5\x04\x3d\x41\x4f\xd2\x93\xf4\x14\x3d\x45\xa7\xea\x54\x3d\x4d\x4f" "\xd3\xd3\xf5\x74\x3d\x43\xcf\xd0\x33\xf5\x4c\x9d\xa6\xd3\xf4\x1c\x3d\x47" "\xcf\xd5\x73\xf5\x7c\x3d\x5f\x2f\xd0\x0b\xf4\x42\xbd\x50\x2f\xd6\x8b\x75" "\xba\x4e\xd7\x19\x3a\x43\x67\xea\x4c\xbd\x4c\x2f\xd3\x59\x7a\xb9\x5e\xae" "\x57\xea\x95\x7a\xb5\x5e\xad\xd7\xea\xb5\x7a\xbd\x5e\xaf\x37\xea\x8d\x7a" "\xb3\xde\xac\xb3\xf4\x36\xbd\x4d\x6f\xd7\xdb\xf5\x4e\xbd\x53\xef\xd6\xbb" "\xf5\x5e\xbd\x57\xef\xd3\xfb\xf4\x7e\xbd\x5f\x1f\xd0\x07\xf4\x41\x7d\x50" "\x1f\xd2\x87\xf4\x61\x7d\x58\x67\xeb\x6c\x7d\x44\x1f\xd1\x47\xf5\x51\x7d" "\x4c\x1f\xd3\xc7\xf5\x71\x7d\x42\x9f\xd0\xa7\xf4\x29\x7d\x46\x9f\xd1\x67" "\xf5\x59\x7d\x5e\x9f\xd7\x17\xf5\x45\x7d\x49\x5f\xd2\x57\xf4\x95\x9c\xc3" "\xbe\x40\x06\x32\xd0\x81\x0e\xf2\x04\x79\x82\x98\x20\x26\x88\x0d\x62\x83" "\xb8\x20\x2e\xc8\x1f\xe4\x0f\x22\x41\x24\x88\x0f\xe2\x83\x82\xc1\x4d\x41" "\xa1\xa0\x70\x50\x24\x28\x1a\x24\x04\xc5\x82\xe2\x81\x09\x30\xb0\x01\x05" "\x61\x50\x22\x28\x19\x44\x83\x9b\x83\x52\xc1\x2d\x41\x62\x50\x3a\x28\x13" "\x94\x0d\x5c\x50\x2e\x28\x1f\x54\x08\x2a\x06\xb7\x06\x95\x82\xdb\x82\xca" "\xc1\xed\x41\x95\xe0\x8e\xa0\x6a\x50\x2d\xa8\x1e\xd4\x08\xee\x0c\x6a\x06" "\x77\x05\xb5\x82\xbb\x83\xda\xc1\x3d\x41\x9d\xa0\x6e\x50\x2f\xa8\x1f\xdc" "\x1b\x34\x08\xee\x0b\x1a\x06\xf7\x07\x8d\x82\x07\x82\xc6\xc1\x83\x41\x93" "\xe0\xa1\xa0\x69\xf0\x70\xd0\x2c\x78\x24\x68\x1e\x3c\x1a\xb4\x08\x1e\x0b" "\x5a\x06\x8f\x07\xad\x82\xd6\x41\x9b\xa0\x6d\xd0\xee\x4f\x5d\xdf\xfb\xb3" "\x85\x9f\x74\xfd\x4c\x7f\x93\x6c\x06\x98\x81\xe6\x55\x33\xc8\x0c\x36\x43" "\xcc\x50\x33\xcc\xbc\x66\x86\x9b\xd7\xcd\x08\xf3\x86\x49\x31\x23\xcd\x28" "\xf3\xa6\x19\x6d\xde\x32\x63\xcc\xdb\x66\xac\x19\x67\xc6\x9b\x77\xcc\x04" "\x33\xd1\x4c\x32\x93\xcd\x14\x33\xd5\xa4\x9a\x77\xcd\x34\xf3\x9e\x99\x6e" "\xde\x37\x33\xcc\x07\x66\xa6\x99\x65\xd2\xcc\x6c\x33\xc7\x7c\x68\xe6\x9a" "\x79\x66\xbe\xf9\xc8\x2c\x30\x1f\x9b\x85\x66\x91\x59\x6c\x96\x98\x74\xf3" "\x89\xc9\x30\x4b\x4d\xa6\xf9\xd4\x2c\x33\x9f\x99\x2c\xb3\xdc\xac\x30\x2b" "\xcd\x2a\xb3\xda\xac\x31\x6b\xcd\x3a\xb3\xde\x6c\x30\x1b\xcd\x26\xb3\xd9" "\x6c\x31\x5b\xcd\x36\xf3\xb9\xd9\x6e\x76\x98\x9d\x66\x97\xd9\x6d\xf6\x98" "\xbd\xe6\x0b\xb3\xcf\x7c\x69\xf6\x9b\xaf\xcc\x01\xf3\xb5\x39\x68\xfe\x62" "\x0e\x99\x6f\xcc\x61\xf3\xad\xc9\x36\xdf\x99\x23\xe6\x7b\x73\xd4\xfc\x60" "\x8e\x99\x1f\xcd\x71\xf3\x93\x39\x61\x4e\x9a\x53\xe6\xb4\x39\x63\x7e\x36" "\x67\xcd\x39\x73\xde\x5c\x30\x17\xcd\x2f\xe6\x92\xb9\x6c\xae\x18\x9f\x73" "\x70\x9f\xf3\xf1\x8e\x1a\x35\xe6\xc1\x3c\x18\x83\x31\x18\x8b\xb1\x18\x87" "\x71\x98\x1f\xf3\x63\x04\x23\x18\x8f\xf1\x58\x10\x0b\x62\x21\x2c\x84\x45" "\xb0\x08\x26\x60\x02\x16\xc7\xe2\x98\x83\x90\xb0\x04\x96\xc0\x28\x46\xb1" "\x14\x96\xc2\x44\x4c\xc4\x32\x58\x06\x1d\x3a\x2c\x8f\xe5\xb1\x22\x56\xc4" "\x4a\x58\x09\x2b\x63\x65\xac\x82\x55\xb0\x2a\x56\xc5\xea\x58\x1d\xef\xc4" "\x3b\xf1\x2e\xbc\x0b\xef\xc6\xbb\xf1\x1e\xbc\x07\xeb\x62\x5d\xac\x8f\xf5" "\xb1\x01\x36\xc0\x86\xd8\x10\x1b\x61\x23\x6c\x8c\x8d\xb1\x09\x36\xc1\xa6" "\xd8\x14\x9b\x61\x33\x6c\x8e\xcd\xb1\x05\xb6\xc0\x96\xd8\x12\x5b\x61\x2b" "\x6c\x83\x6d\xb0\x1d\xb6\xc3\xf6\xd8\x1e\x3b\x60\x07\xec\x84\x9d\xb0\x33" "\x76\xc6\x2e\xd8\x05\x93\x30\x09\xbb\x62\x57\xec\x86\xdd\xb0\x3b\x76\xc7" "\x1e\xd8\x03\x7b\x62\x4f\xec\x85\xbd\xb0\x0f\xf6\xc1\xbe\xd8\x17\xfb\x61" "\x3f\x4c\xc6\x64\x1c\x88\x03\x71\x10\x0e\xc2\x21\x38\x04\x87\xe1\x30\x1c" "\x8e\xc3\x71\x04\x8e\xc0\x14\x4c\xc1\x51\x38\x0a\x47\xe3\x68\x1c\x83\x63" "\x70\x2c\x8e\xc3\xf1\xf8\x0e\x4e\xc0\x89\x38\x09\x27\xe3\x14\x9c\x8a\xa9" "\x98\x8a\xd3\x70\x1a\x4e\xc7\xe9\x38\x03\x67\xe0\x4c\x9c\x89\x69\x98\x86" "\x73\x70\x0e\xce\xc5\xb9\x38\x1f\xe7\xe3\x02\x5c\x80\x0b\x71\x21\x2e\xc6" "\xc5\x98\x8e\xe9\x98\x81\x19\x98\x89\x99\xb8\x0c\x97\x61\x16\x66\xe1\x0a" "\x5c\x81\xab\x70\x15\xae\xc1\x35\xb8\x0e\xd7\xe1\x06\xdc\x80\x9b\x70\x13" "\x6e\xc1\x2d\xb8\x0d\xb7\xe1\x76\xdc\x8e\x3b\x71\x27\xee\xc6\xdd\xb8\x17" "\xf7\xe2\x3e\xdc\x87\xfb\x71\x3f\x1e\xc0\x03\x78\x10\x0f\xe2\x21\x3c\x84" "\x87\xf1\x30\x66\x63\x36\x1e\xc1\x23\x78\x14\x8f\xe2\x31\x3c\x86\xc7\xf1" "\x38\x9e\xc0\x13\x78\x0a\x4f\xe1\x19\x3c\x83\x67\xf1\x2c\x9e\xc7\xf3\x78" "\x11\x7f\xc1\x4b\x78\x19\xaf\xa0\xc7\x18\x9b\xcf\xc6\xda\xeb\x6c\x9c\xbd" "\xde\xe6\xb7\x05\xec\x3f\xc6\x45\x6c\x51\x9b\x60\x8b\xd9\xe2\xd6\xd8\x42" "\xb6\xf0\xdf\xc5\x68\xad\x4d\xb4\xa5\x6d\x19\x5b\xd6\x3a\x5b\xce\x96\xb7" "\x15\x7e\x17\x57\xb5\xd5\x6c\x75\x5b\xc3\xde\x69\x6b\xda\xbb\x6c\xad\xdf" "\xc5\x0d\xec\x7d\xb6\xa1\xbd\xdf\x36\xb2\x0f\xd8\xfa\xf6\xde\xbf\x8b\x1b" "\xdb\x07\x6d\x13\xfb\x98\x6d\x6a\x1f\xb7\xcd\x6c\x6b\xdb\xdc\xb6\xb5\x2d" "\xec\x63\xb6\xa5\x7d\xdc\xb6\xb2\xad\x6d\x1b\xdb\xd6\x76\xb6\x4f\xdb\x2e" "\xf6\x19\x9b\x64\x9f\xb5\x5d\xed\x73\xbf\x8b\x33\xec\x52\xbb\xce\xae\xb7" "\x1b\xec\x46\xbb\xcf\x7e\x69\xcf\xdb\x0b\xf6\xa8\xfd\xc1\x5e\xb4\xbf\xd8" "\x7e\xb6\xbf\x1d\x66\x5f\xb3\xc3\xed\xeb\x76\x84\x7d\xc3\xa6\xd8\x91\xbf" "\x8b\xc7\xdb\x77\xec\x04\x3b\xd1\x4e\xb2\x93\xed\x14\x3b\xf5\x77\xf1\x4c" "\x3b\xcb\xa6\xd9\xd9\x76\x8e\xfd\xd0\xce\xb5\xf3\x7e\x17\xa7\xdb\x4f\xec" "\x02\x9b\x69\x17\xda\x45\x76\xb1\x5d\xf2\x6b\x9c\x53\x53\xa6\xfd\xd4\x2e" "\xb3\x9f\xd9\x2c\xbb\xdc\xae\xb0\x2b\xed\x2a\xbb\xda\xae\xb1\x6b\xff\x67" "\xad\x2b\xed\x66\xbb\xc5\x6e\xb5\x7b\xed\x17\x76\xbb\xdd\x61\x77\xda\x5d" "\x76\xb7\xdd\xf3\x6b\x9c\xb3\x8f\xfd\xf6\x2b\x7b\xc0\x7e\x6d\x8f\xd8\xef" "\xed\x21\xfb\x8d\x3d\x6c\x8f\xd9\x6c\xfb\xdd\xaf\x71\xce\xfe\x8e\xd9\x1f" "\xed\x71\xfb\x93\x3d\x61\x4f\xda\x53\xf6\xb4\x3d\x63\x7f\xb6\x67\xed\xb9" "\x5f\xf7\x9f\xb3\xf7\xd3\xf6\xb2\xbd\x62\xbd\x15\x04\x24\x49\x91\xa6\x80" "\xf2\x50\x5e\x8a\xa1\x7c\x14\x4b\xd7\x51\x1c\x5d\x4f\xf9\xa9\x00\x45\xe8" "\x06\x8a\xa7\x1b\xa9\x20\xdd\x44\x85\xa8\x30\x15\xa1\xa2\x94\x40\xc5\xa8" "\x38\x19\x42\xb2\x44\x14\x52\x09\x2a\x49\x51\xba\x99\x4a\xd1\x2d\x94\x48" "\xa5\xa9\x0c\x95\x25\x47\xe5\xa8\x3c\x55\xa0\x8a\x74\x2b\x55\xa2\xdb\xa8" "\x32\xdd\x4e\x55\xe8\x0e\xaa\x4a\xd5\xa8\x3a\xd5\xa0\x3b\xa9\x26\xdd\x45" "\xb5\xe8\x6e\xaa\x4d\xf7\x50\x1d\xaa\x4b\xf5\xa8\x3e\xdd\x4b\x0d\xe8\x3e" "\x6a\x48\xf7\x53\x23\x7a\x80\x1a\xd3\x83\xd4\x84\x1e\xa2\xa6\xf4\x30\x35" "\xa3\x47\xa8\x39\x3d\x4a\x2d\xe8\x31\x6a\x49\x8f\x53\x2b\x6a\x4d\x6d\xa8" "\x2d\xb5\xa3\x27\xa8\x3d\x3d\x49\x1d\xa8\x23\x75\xa2\xa7\xa8\x33\x3d\x4d" "\x5d\xe8\x19\x4a\xa2\x67\xa9\x2b\x3d\x47\xdd\xe8\x79\xea\x4e\x2f\x50\x0f" "\x7a\x91\x7a\xd2\x4b\xd4\x8b\x7a\x53\x1f\x7a\x99\xfa\xd2\x2b\xd4\x8f\xfa" "\x53\x32\x0d\xa0\x81\xf4\x2a\x0d\xa2\xc1\x34\x84\x86\xd2\x30\x7a\x8d\x86" "\xd3\xeb\x34\x82\xde\xa0\x14\x1a\x49\xa3\xe8\x4d\x1a\x4d\x6f\xd1\x18\x7a" "\x9b\xc6\xd2\x38\x1a\x4f\xef\xd0\x04\x9a\x48\x93\x68\x32\x4d\xa1\xa9\x94" "\x4a\xef\xd2\x34\x7a\x8f\xa6\xd3\xfb\x34\x83\x3e\xa0\x99\x34\x8b\xd2\x68" "\x36\xcd\xa1\x0f\x69\x2e\xcd\xa3\xf9\xf4\x11\x2d\xa0\x8f\x69\x21\x2d\xa2" "\xc5\xb4\x84\xd2\xe9\x13\xca\xa0\xa5\x94\x49\x9f\xd2\x32\xfa\x8c\xb2\x68" "\x39\xad\xa0\x95\xb4\x8a\x56\xd3\x1a\x5a\x4b\xeb\x68\x3d\x6d\xa0\x8d\xb4" "\x89\x36\xd3\x16\xda\x4a\xdb\xe8\x73\xda\x4e\x3b\x68\x27\xed\xa2\xdd\xb4" "\x87\xf6\xd2\x17\xb4\x8f\xbe\xa4\xfd\xf4\x15\x1d\xa0\xaf\xe9\x20\xfd\x85" "\x0e\xd1\x37\x74\x98\xbe\xa5\x6c\xfa\x8e\x8e\xd0\xf7\x74\x94\x7e\xa0\x63" "\xf4\x23\x1d\xa7\x9f\xe8\x04\x9d\xa4\x53\x74\x9a\xce\xd0\xcf\x74\x96\xce" "\xd1\x79\xba\x40\x17\xe9\x17\xba\x44\x97\xe9\x0a\x79\x12\x21\x84\x32\x54" "\xa1\x0e\x83\x30\x4f\x98\x37\x8c\x09\xf3\x85\xb1\xe1\x75\x61\x5c\x78\x7d" "\x98\x3f\x2c\x10\x46\xc2\x1b\xc2\xf8\xf0\xc6\xb0\x60\x78\x53\x58\x28\x2c" "\x1c\x16\x09\x8b\x86\x09\x61\xb1\xb0\x78\x68\x42\x0c\x6d\x48\x61\x18\x96" "\x08\x4b\x86\xd1\xf0\xe6\xb0\x54\x78\x4b\x98\x18\x96\x0e\xcb\x84\x65\x43" "\x17\x96\x0b\xcb\x87\x15\xc2\x8a\xe1\xad\x61\xa5\xf0\xb6\xb0\x72\x78\x7b" "\x58\x25\xbc\x23\xac\x1a\x56\x0b\x1f\x7b\xa0\x46\x78\x67\x58\x33\xbc\x2b" "\xac\x15\xde\x1d\xd6\x0e\xef\x09\xeb\x84\x75\xc3\x7a\x61\xfd\xf0\xde\xb0" "\x41\x78\x5f\xd8\x30\xbc\x3f\x6c\x14\x3e\x10\x56\x0a\x1f\x0c\x9b\x84\x0f" "\x85\x4d\xc3\x87\xc3\x66\xe1\x23\x61\xf3\xf0\xd1\xb0\x45\xf8\x58\xd8\x32" "\x7c\x3c\x6c\x15\xb6\x0e\xdb\x84\x6d\xc3\x76\xe1\x13\x61\xfb\xf0\xc9\xb0" "\x43\xd8\x31\xec\x14\x3e\x15\x76\x0e\x9f\x0e\xbb\x84\xcf\x84\x49\xe1\xb3" "\x61\xd7\xf0\xb9\x3f\xbc\x3f\x39\x1c\x10\x0e\x0c\x5f\x0d\x5f\x0d\xbd\xbf" "\x5f\x2d\x8e\x2e\x89\xa6\x47\x3f\x89\x66\x44\x97\x46\x33\xa3\x9f\x46\x97" "\x45\x3f\x8b\x66\x45\x97\x47\x57\x44\x57\x46\x57\x45\x57\x47\xd7\x44\xd7" "\x46\xd7\x45\xd7\x47\x37\x44\x37\x46\x37\x45\x37\x47\xb7\x44\xb7\x46\xbd" "\xaf\x9f\x57\x38\x70\xd2\x29\xa7\x5d\xe0\xf2\xb8\xbc\x2e\xc6\xe5\x73\xb1" "\xee\x3a\x17\xe7\xae\x77\xf9\x5d\x01\x17\x71\x37\xb8\x78\x77\xa3\x2b\xe8" "\x6e\x72\x85\x5c\x61\x57\xc4\x15\x75\x09\xae\x98\x2b\xee\x8c\x43\x67\x1d" "\xb9\xd0\x95\x70\x25\x5d\xd4\xdd\xec\x4a\xb9\x5b\x5c\xa2\x2b\xed\xca\xb8" "\xb2\xce\xb9\x72\xae\xbc\x6b\xeb\xda\xb9\x76\xae\xbd\x7b\xd2\x75\x70\x1d" "\x5d\x27\xf7\x94\x7b\xca\x3d\xed\x9e\x76\xcf\xb8\x67\xdc\xb3\xae\xab\x7b" "\xce\x75\x73\xcf\xbb\xee\xee\x05\xd7\xc3\xbd\xe8\x5e\x74\x2f\xb9\x5e\xae" "\xb7\xeb\xe3\x5e\x76\x7d\xdd\x2b\xae\x9f\xeb\xef\x92\x5d\xb2\x1b\xe8\x06" "\xba\x41\x6e\x90\x1b\xe2\x86\xb8\x61\x6e\x98\x1b\xee\x86\xbb\x11\x6e\x84" "\x4b\x71\x29\x6e\x94\x1b\xe5\x46\xbb\xd1\x6e\x8c\x1b\xe3\xc6\xba\xb1\x6e" "\xbc\x1b\xef\x26\xb8\x09\x6e\x92\x9b\xe4\xa6\xb8\x29\x2e\xd5\xa5\xba\x69" "\x6e\x9a\x9b\xee\xa6\xbb\x19\x6e\x86\x9e\xe9\x66\xba\x34\x97\xe6\xe6\xb8" "\x39\x6e\xae\x9b\xeb\xe6\xbb\xf9\x6e\x41\xe2\x02\xb7\xd0\x2d\x74\x8b\xdd" "\x62\x97\xee\xd2\x5d\x86\xcb\x70\x99\x2e\xd3\x2d\x73\xcb\x5c\x96\xcb\x72" "\x2b\xdc\x0a\xb7\xca\xad\x72\x6b\xdc\x1a\xb7\xce\xad\x73\x1b\xdc\x06\xb7" "\xc9\x6d\x72\x5b\xdc\x16\xb7\xcd\x6d\x73\xdb\xdd\x76\xb7\xd3\xed\x74\xbb" "\xdd\x6e\xb7\xd7\xed\x75\xfb\xdc\x3e\x2d\xdc\x7e\x77\xc0\x1d\x70\x07\xdd" "\x41\x77\xc8\x1d\x72\x87\xdd\xb7\x2e\xdb\x7d\xe7\x8e\xb8\xef\xdd\x51\xf7" "\x83\x3b\xe6\x7e\x74\xc7\xdd\x4f\xee\x84\x3b\xe9\x4e\xb9\xd3\xee\x8c\xfb" "\xd9\x9d\x75\xe7\xdc\x79\x77\xc1\x5d\x74\xbf\xb8\x4b\xee\xb2\xbb\xe2\xbc" "\x4b\x8d\xbc\x1b\x99\x16\x79\x2f\x32\x3d\xf2\x7e\x64\x46\xe4\x83\xc8\xcc" "\xc8\xac\x48\x5a\x64\x76\x64\x4e\xe4\xc3\xc8\xdc\xc8\xbc\xc8\xfc\xc8\x47" "\x91\x05\x91\x8f\x23\x0b\x23\x8b\x22\x8b\x23\x4b\x22\xe9\x91\x4f\x22\x19" "\x91\xa5\x91\xcc\xc8\xa7\x91\x65\x91\xcf\x22\x59\x91\xe5\x91\x15\x91\x95" "\x91\x55\x91\xd5\x11\xef\x8b\x6d\x0f\x7d\x09\x5f\xd2\x47\xfd\xcd\xbe\x94" "\xbf\xc5\x27\xfa\xd2\xbe\x8c\x2f\xeb\x9d\x2f\xe7\xcb\xfb\x0a\xbe\xa2\xbf" "\xd5\x57\xf2\xb7\xf9\xca\xfe\x76\x5f\xc5\xdf\xe1\xab\xfa\x6a\xbe\xba\x7f" "\xdc\xb7\xf2\xad\x7d\x1b\xdf\xd6\xb7\xf3\x4f\xf8\xf6\xfe\x49\xdf\xc1\x77" "\xf4\x9d\xfc\x53\xbe\xb3\x7f\xda\x77\xf1\xcf\xf8\x24\xff\xac\xef\xea\x9f" "\xf3\xdd\xfc\xf3\xbe\xbb\x7f\xc1\xf7\xf0\x2f\xfa\x9e\xfe\x25\xdf\xcb\xf7" "\xf6\x7d\xfc\xcb\xbe\xaf\x7f\xc5\xf7\xf3\xfd\x7d\xb2\x1f\xe0\x07\xfa\x57" "\xfd\x20\x3f\xd8\x0f\xf1\x43\xfd\x30\xff\x9a\x1f\xee\x5f\xf7\x23\xfc\x1b" "\x3e\xc5\x8f\xf4\xa3\xfc\x9b\x7e\xb4\x7f\xcb\x8f\xf1\x6f\xfb\xb1\x7e\x9c" "\x1f\xef\xdf\xf1\x13\xfc\x44\x3f\xc9\x4f\xf6\x53\xfc\x54\x9f\xea\xdf\xf5" "\xd3\xfc\x7b\x7e\xba\x7f\xdf\xcf\xf0\x1f\xf8\x99\x7e\x96\x4f\xf3\xb3\xfd" "\x1c\xff\xa1\x9f\xeb\xe7\xf9\xf9\xfe\x23\xbf\xc0\x7f\xec\x17\xfa\x45\x7e" "\xb1\x5f\xe2\xd3\xfd\x27\x3e\xc3\x2f\xf5\x99\xfe\x53\xbf\xcc\x7f\xe6\xb3" "\xfc\x72\xbf\xc2\xaf\xf4\xab\xfc\x6a\xbf\xc6\xaf\xf5\xeb\xfc\x7a\xbf\xc1" "\x6f\xf4\x9b\xfc\x66\xbf\xc5\x6f\xf5\xdb\xfc\xe7\x7e\xbb\xdf\xe1\x77\xfa" "\x5d\x7e\xb7\xdf\xe3\xf7\xfa\x2f\xfc\x3e\xff\xa5\xdf\xef\xbf\xf2\x07\xfc" "\xd7\xfe\xa0\xff\x8b\x3f\xe4\xbf\xf1\x87\xfd\xb7\x3e\xdb\x7f\xe7\x8f\xf8" "\xef\xfd\x51\xff\x83\x3f\xe6\x7f\xf4\xc7\xfd\x4f\xfe\x84\x3f\xe9\x4f\xf9" "\xd3\xfe\x8c\xff\xd9\x9f\xf5\xe7\xfc\x79\x7f\xc1\x5f\xf4\xbf\xf8\x4b\xfe" "\xb2\xbf\xe2\xbd\xbf\x86\x17\xd1\x19\x63\x8c\x31\xc6\xfe\xbf\xa1\xfe\xe0" "\xfe\x01\xff\xe4\x67\xf2\xaf\x23\xc7\x40\x21\xc4\xf5\x3b\x8a\x66\xff\xe3" "\x9a\x9b\x0a\xfd\x36\x1f\x2c\x13\x3a\x47\x84\x10\xcf\xf6\xef\xf9\xc8\xdf" "\x46\x9d\x3a\xc9\xc9\x7f\xfb\x2a\x81\x2c\x25\x82\x92\x8b\x84\x10\x91\xab" "\xf9\x79\xc4\xd5\x78\xb9\xe8\x24\x9e\x16\x49\xa2\xa3\xa8\xf8\x4f\xeb\x1b" "\x2c\x7b\x5f\xa4\x3f\x58\x3f\x7a\xbb\x10\xb1\xff\x21\x27\x46\x5c\x8d\xaf" "\xae\x7f\xeb\xbf\x58\xff\x89\xa7\xc6\x67\x54\x09\xcf\xc7\xff\x2f\xd6\x5f" "\x24\x44\x62\xc9\xab\x39\xf9\xc4\xd5\x78\xb9\xe8\xf4\xeb\xff\x68\x3b\x8a" "\x4a\xff\x62\xfd\xc2\xed\xff\xa0\xfe\x7c\xdf\xa4\x0a\xd1\xe1\x3f\xe4\xc4" "\x89\xab\x71\x4e\xfd\xbe\xc0\x6f\xf3\x27\xc5\x73\x22\xe9\xef\x1e\xc9\x18" "\x63\x8c\x31\xc6\x18\x63\x8c\xfd\x66\xb0\xac\xde\xfd\x8f\xce\x9f\x73\xce" "\xcf\x13\xf4\xd5\x9c\xbc\xe2\x6a\xfc\x47\xe7\xe7\x8c\x31\xc6\x18\x63\x8c" "\x31\xc6\x18\xbb\xf6\x5e\xe8\xdd\xe7\x99\x27\x92\x92\x3a\x76\xe7\x09\x4f" "\x78\xf2\xff\xd6\x44\x5d\xcb\x5f\xcf\x6b\xfd\x97\x89\x31\xc6\x18\x63\x8c" "\x31\xf6\x67\xbb\x7a\xd0\x7f\xad\x2b\x61\x8c\x31\xc6\x18\x63\x8c\x31\xc6" "\x18\x63\x8c\x31\xc6\x18\x63\x8c\x31\xc6\x18\x63\x8c\x31\xc6\x18\x63\x8c" "\x31\xc6\x18\x63\x8c\x31\xc6\x18\x63\x8c\x31\xc6\x72\xaf\xff\x8a\xaf\x13" "\xbb\xd6\x7b\x64\x8c\x31\xc6\x18\x63\x8c\x31\xc6\x18\x63\x8c\x31\xc6\x18" "\x63\x8c\x31\xc6\x18\x63\x8c\x31\xc6\x18\x63\x8c\x31\xc6\x18\x63\x8c\x31" "\xc6\x18\x63\x8c\x31\xc6\x18\x63\x8c\x31\xc6\x18\x63\x8c\x31\xc6\xae\xb5" "\xff\x11\x00\x00\xff\xff\x68\x87\x30\xba", 5374)); NONFAILING(syz_mount_image(/*fs=*/0x20000000, /*dir=*/0x20000140, /*flags=MS_SYNCHRONOUS|MS_NODIRATIME*/ 0x810, /*opts=*/0x20000180, /*chdir=*/1, /*size=*/0x14fe, /*img=*/0x20002a40)); NONFAILING(memcpy((void*)0x200003c0, "./file0\000", 8)); NONFAILING(memcpy((void*)0x20000400, "tmpfs\000", 6)); syscall(__NR_mount, /*src=*/0ul, /*dst=*/0x200003c0ul, /*type=*/0x20000400ul, /*flags=MS_LAZYTIME*/ 0x2000000ul, /*opts=*/0ul); syscall(__NR_sync); } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x21000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1, /*offset=*/0ul); setup_sysctl(); setup_cgroups(); const char* reason; (void)reason; if ((reason = setup_usb())) printf("the reproducer may not work as expected: USB injection setup " "failed: %s\n", reason); install_segv_handler(); for (procid = 0; procid < 5; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; }