// https://syzkaller.appspot.com/bug?id=2fadd6c28069190d97183c9606710816bf750532 // 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 #include #ifndef __NR_memfd_create #define __NR_memfd_create 319 #endif #ifndef __NR_pwritev2 #define __NR_pwritev2 328 #endif static unsigned long long procid; static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { int state; } event_t; static void event_init(event_t* ev) { ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { if (ev->state) exit(1); __atomic_store_n(&ev->state, 1, __ATOMIC_RELEASE); syscall(SYS_futex, &ev->state, FUTEX_WAKE | FUTEX_PRIVATE_FLAG, 1000000); } static void event_wait(event_t* ev) { while (!__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, 0); } static int event_isset(event_t* ev) { return __atomic_load_n(&ev->state, __ATOMIC_ACQUIRE); } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; for (;;) { uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, &ts); if (__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) return 1; now = current_time_ms(); if (now - start > timeout) return 0; } } 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"); } else if (strncmp(fs, "gfs2", 4) == 0 && (strstr(opts, "errors=panic") || strstr(opts, "debug"))) { strcat(opts, ",errors=withdraw"); } 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; } #define XT_TABLE_SIZE 1536 #define XT_MAX_ENTRIES 10 struct xt_counters { uint64_t pcnt, bcnt; }; struct ipt_getinfo { char name[32]; unsigned int valid_hooks; unsigned int hook_entry[5]; unsigned int underflow[5]; unsigned int num_entries; unsigned int size; }; struct ipt_get_entries { char name[32]; unsigned int size; uint64_t entrytable[XT_TABLE_SIZE / sizeof(uint64_t)]; }; struct ipt_replace { char name[32]; unsigned int valid_hooks; unsigned int num_entries; unsigned int size; unsigned int hook_entry[5]; unsigned int underflow[5]; unsigned int num_counters; struct xt_counters* counters; uint64_t entrytable[XT_TABLE_SIZE / sizeof(uint64_t)]; }; struct ipt_table_desc { const char* name; struct ipt_getinfo info; struct ipt_replace replace; }; static struct ipt_table_desc ipv4_tables[] = { {.name = "filter"}, {.name = "nat"}, {.name = "mangle"}, {.name = "raw"}, {.name = "security"}, }; static struct ipt_table_desc ipv6_tables[] = { {.name = "filter"}, {.name = "nat"}, {.name = "mangle"}, {.name = "raw"}, {.name = "security"}, }; #define IPT_BASE_CTL 64 #define IPT_SO_SET_REPLACE (IPT_BASE_CTL) #define IPT_SO_GET_INFO (IPT_BASE_CTL) #define IPT_SO_GET_ENTRIES (IPT_BASE_CTL + 1) struct arpt_getinfo { char name[32]; unsigned int valid_hooks; unsigned int hook_entry[3]; unsigned int underflow[3]; unsigned int num_entries; unsigned int size; }; struct arpt_get_entries { char name[32]; unsigned int size; uint64_t entrytable[XT_TABLE_SIZE / sizeof(uint64_t)]; }; struct arpt_replace { char name[32]; unsigned int valid_hooks; unsigned int num_entries; unsigned int size; unsigned int hook_entry[3]; unsigned int underflow[3]; unsigned int num_counters; struct xt_counters* counters; uint64_t entrytable[XT_TABLE_SIZE / sizeof(uint64_t)]; }; struct arpt_table_desc { const char* name; struct arpt_getinfo info; struct arpt_replace replace; }; static struct arpt_table_desc arpt_tables[] = { {.name = "filter"}, }; #define ARPT_BASE_CTL 96 #define ARPT_SO_SET_REPLACE (ARPT_BASE_CTL) #define ARPT_SO_GET_INFO (ARPT_BASE_CTL) #define ARPT_SO_GET_ENTRIES (ARPT_BASE_CTL + 1) static void checkpoint_iptables(struct ipt_table_desc* tables, int num_tables, int family, int level) { int fd = socket(family, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: case ENOENT: return; } exit(1); } for (int i = 0; i < num_tables; i++) { struct ipt_table_desc* table = &tables[i]; strcpy(table->info.name, table->name); strcpy(table->replace.name, table->name); socklen_t optlen = sizeof(table->info); if (getsockopt(fd, level, IPT_SO_GET_INFO, &table->info, &optlen)) { switch (errno) { case EPERM: case ENOENT: case ENOPROTOOPT: continue; } exit(1); } if (table->info.size > sizeof(table->replace.entrytable)) exit(1); if (table->info.num_entries > XT_MAX_ENTRIES) exit(1); struct ipt_get_entries entries; memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + table->info.size; if (getsockopt(fd, level, IPT_SO_GET_ENTRIES, &entries, &optlen)) exit(1); table->replace.valid_hooks = table->info.valid_hooks; table->replace.num_entries = table->info.num_entries; table->replace.size = table->info.size; memcpy(table->replace.hook_entry, table->info.hook_entry, sizeof(table->replace.hook_entry)); memcpy(table->replace.underflow, table->info.underflow, sizeof(table->replace.underflow)); memcpy(table->replace.entrytable, entries.entrytable, table->info.size); } close(fd); } static void reset_iptables(struct ipt_table_desc* tables, int num_tables, int family, int level) { int fd = socket(family, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: case ENOENT: return; } exit(1); } for (int i = 0; i < num_tables; i++) { struct ipt_table_desc* table = &tables[i]; if (table->info.valid_hooks == 0) continue; struct ipt_getinfo info; memset(&info, 0, sizeof(info)); strcpy(info.name, table->name); socklen_t optlen = sizeof(info); if (getsockopt(fd, level, IPT_SO_GET_INFO, &info, &optlen)) exit(1); if (memcmp(&table->info, &info, sizeof(table->info)) == 0) { struct ipt_get_entries entries; memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + entries.size; if (getsockopt(fd, level, IPT_SO_GET_ENTRIES, &entries, &optlen)) exit(1); if (memcmp(table->replace.entrytable, entries.entrytable, table->info.size) == 0) continue; } struct xt_counters counters[XT_MAX_ENTRIES]; table->replace.num_counters = info.num_entries; table->replace.counters = counters; optlen = sizeof(table->replace) - sizeof(table->replace.entrytable) + table->replace.size; if (setsockopt(fd, level, IPT_SO_SET_REPLACE, &table->replace, optlen)) exit(1); } close(fd); } static void checkpoint_arptables(void) { int fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: case ENOENT: return; } exit(1); } for (unsigned i = 0; i < sizeof(arpt_tables) / sizeof(arpt_tables[0]); i++) { struct arpt_table_desc* table = &arpt_tables[i]; strcpy(table->info.name, table->name); strcpy(table->replace.name, table->name); socklen_t optlen = sizeof(table->info); if (getsockopt(fd, SOL_IP, ARPT_SO_GET_INFO, &table->info, &optlen)) { switch (errno) { case EPERM: case ENOENT: case ENOPROTOOPT: continue; } exit(1); } if (table->info.size > sizeof(table->replace.entrytable)) exit(1); if (table->info.num_entries > XT_MAX_ENTRIES) exit(1); struct arpt_get_entries entries; memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + table->info.size; if (getsockopt(fd, SOL_IP, ARPT_SO_GET_ENTRIES, &entries, &optlen)) exit(1); table->replace.valid_hooks = table->info.valid_hooks; table->replace.num_entries = table->info.num_entries; table->replace.size = table->info.size; memcpy(table->replace.hook_entry, table->info.hook_entry, sizeof(table->replace.hook_entry)); memcpy(table->replace.underflow, table->info.underflow, sizeof(table->replace.underflow)); memcpy(table->replace.entrytable, entries.entrytable, table->info.size); } close(fd); } static void reset_arptables() { int fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: case ENOENT: return; } exit(1); } for (unsigned i = 0; i < sizeof(arpt_tables) / sizeof(arpt_tables[0]); i++) { struct arpt_table_desc* table = &arpt_tables[i]; if (table->info.valid_hooks == 0) continue; struct arpt_getinfo info; memset(&info, 0, sizeof(info)); strcpy(info.name, table->name); socklen_t optlen = sizeof(info); if (getsockopt(fd, SOL_IP, ARPT_SO_GET_INFO, &info, &optlen)) exit(1); if (memcmp(&table->info, &info, sizeof(table->info)) == 0) { struct arpt_get_entries entries; memset(&entries, 0, sizeof(entries)); strcpy(entries.name, table->name); entries.size = table->info.size; optlen = sizeof(entries) - sizeof(entries.entrytable) + entries.size; if (getsockopt(fd, SOL_IP, ARPT_SO_GET_ENTRIES, &entries, &optlen)) exit(1); if (memcmp(table->replace.entrytable, entries.entrytable, table->info.size) == 0) continue; } else { } struct xt_counters counters[XT_MAX_ENTRIES]; table->replace.num_counters = info.num_entries; table->replace.counters = counters; optlen = sizeof(table->replace) - sizeof(table->replace.entrytable) + table->replace.size; if (setsockopt(fd, SOL_IP, ARPT_SO_SET_REPLACE, &table->replace, optlen)) exit(1); } close(fd); } #define NF_BR_NUMHOOKS 6 #define EBT_TABLE_MAXNAMELEN 32 #define EBT_CHAIN_MAXNAMELEN 32 #define EBT_BASE_CTL 128 #define EBT_SO_SET_ENTRIES (EBT_BASE_CTL) #define EBT_SO_GET_INFO (EBT_BASE_CTL) #define EBT_SO_GET_ENTRIES (EBT_SO_GET_INFO + 1) #define EBT_SO_GET_INIT_INFO (EBT_SO_GET_ENTRIES + 1) #define EBT_SO_GET_INIT_ENTRIES (EBT_SO_GET_INIT_INFO + 1) struct ebt_replace { char name[EBT_TABLE_MAXNAMELEN]; unsigned int valid_hooks; unsigned int nentries; unsigned int entries_size; struct ebt_entries* hook_entry[NF_BR_NUMHOOKS]; unsigned int num_counters; struct ebt_counter* counters; char* entries; }; struct ebt_entries { unsigned int distinguisher; char name[EBT_CHAIN_MAXNAMELEN]; unsigned int counter_offset; int policy; unsigned int nentries; char data[0] __attribute__((aligned(__alignof__(struct ebt_replace)))); }; struct ebt_table_desc { const char* name; struct ebt_replace replace; char entrytable[XT_TABLE_SIZE]; }; static struct ebt_table_desc ebt_tables[] = { {.name = "filter"}, {.name = "nat"}, {.name = "broute"}, }; static void checkpoint_ebtables(void) { int fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: case ENOENT: return; } exit(1); } for (size_t i = 0; i < sizeof(ebt_tables) / sizeof(ebt_tables[0]); i++) { struct ebt_table_desc* table = &ebt_tables[i]; strcpy(table->replace.name, table->name); socklen_t optlen = sizeof(table->replace); if (getsockopt(fd, SOL_IP, EBT_SO_GET_INIT_INFO, &table->replace, &optlen)) { switch (errno) { case EPERM: case ENOENT: case ENOPROTOOPT: continue; } exit(1); } if (table->replace.entries_size > sizeof(table->entrytable)) exit(1); table->replace.num_counters = 0; table->replace.entries = table->entrytable; optlen = sizeof(table->replace) + table->replace.entries_size; if (getsockopt(fd, SOL_IP, EBT_SO_GET_INIT_ENTRIES, &table->replace, &optlen)) exit(1); } close(fd); } static void reset_ebtables() { int fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP); if (fd == -1) { switch (errno) { case EAFNOSUPPORT: case ENOPROTOOPT: case ENOENT: return; } exit(1); } for (unsigned i = 0; i < sizeof(ebt_tables) / sizeof(ebt_tables[0]); i++) { struct ebt_table_desc* table = &ebt_tables[i]; if (table->replace.valid_hooks == 0) continue; struct ebt_replace replace; memset(&replace, 0, sizeof(replace)); strcpy(replace.name, table->name); socklen_t optlen = sizeof(replace); if (getsockopt(fd, SOL_IP, EBT_SO_GET_INFO, &replace, &optlen)) exit(1); replace.num_counters = 0; table->replace.entries = 0; for (unsigned h = 0; h < NF_BR_NUMHOOKS; h++) table->replace.hook_entry[h] = 0; if (memcmp(&table->replace, &replace, sizeof(table->replace)) == 0) { char entrytable[XT_TABLE_SIZE]; memset(&entrytable, 0, sizeof(entrytable)); replace.entries = entrytable; optlen = sizeof(replace) + replace.entries_size; if (getsockopt(fd, SOL_IP, EBT_SO_GET_ENTRIES, &replace, &optlen)) exit(1); if (memcmp(table->entrytable, entrytable, replace.entries_size) == 0) continue; } for (unsigned j = 0, h = 0; h < NF_BR_NUMHOOKS; h++) { if (table->replace.valid_hooks & (1 << h)) { table->replace.hook_entry[h] = (struct ebt_entries*)table->entrytable + j; j++; } } table->replace.entries = table->entrytable; optlen = sizeof(table->replace) + table->replace.entries_size; if (setsockopt(fd, SOL_IP, EBT_SO_SET_ENTRIES, &table->replace, optlen)) exit(1); } close(fd); } static void checkpoint_net_namespace(void) { checkpoint_ebtables(); checkpoint_arptables(); checkpoint_iptables(ipv4_tables, sizeof(ipv4_tables) / sizeof(ipv4_tables[0]), AF_INET, SOL_IP); checkpoint_iptables(ipv6_tables, sizeof(ipv6_tables) / sizeof(ipv6_tables[0]), AF_INET6, SOL_IPV6); } static void reset_net_namespace(void) { reset_ebtables(); reset_arptables(); reset_iptables(ipv4_tables, sizeof(ipv4_tables) / sizeof(ipv4_tables[0]), AF_INET, SOL_IP); reset_iptables(ipv6_tables, sizeof(ipv6_tables) / sizeof(ipv6_tables[0]), AF_INET6, SOL_IPV6); } static void 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_gadgetfs(); 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); if (mkdir("./syz-tmp/newroot/syz-inputs", 0700)) exit(1); if (mount("/syz-inputs", "./syz-tmp/newroot/syz-inputs", NULL, bind_mount_flags | MS_RDONLY, 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_gadgetfs(); setup_binderfs(); setup_fusectl(); } static void setup_gadgetfs() { if (mkdir("/dev/gadgetfs", 0777)) { } if (mount("gadgetfs", "/dev/gadgetfs", "gadgetfs", 0, NULL)) { } } 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(); checkpoint_net_namespace(); } 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); } reset_net_namespace(); } 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_binfmt_misc() { if (mount(0, "/proc/sys/fs/binfmt_misc", "binfmt_misc", 0, 0) && errno != EBUSY) { return NULL; } if (!write_file("/proc/sys/fs/binfmt_misc/register", ":syz0:M:0:\x01::./file0:") || !write_file("/proc/sys/fs/binfmt_misc/register", ":syz1:M:1:\x02::./file0:POC")) return "write(/proc/sys/fs/binfmt_misc/register) failed"; return NULL; } static const char* setup_usb() { if (chmod("/dev/raw-gadget", 0666)) return "failed to chmod /dev/raw-gadget"; return NULL; } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 5; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 50 + (call == 0 ? 4000 : 0)); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); close_fds(); } 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(); 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_call(int call) { intptr_t res = 0; switch (call) { case 0: // syz_mount_image$nilfs2 arguments: [ // fs: ptr[in, buffer] { // buffer: {6e 69 6c 66 73 32 00} (length 0x7) // } // dir: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 32 00} (length 0x8) // } // flags: mount_flags = 0x10 (8 bytes) // opts: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // } // } // chdir: int8 = 0x5 (1 bytes) // size: len = 0xa7f (8 bytes) // img: ptr[in, buffer] { // buffer: (compressed buffer with length 0xa7f) // } // ] // returns fd_dir memcpy((void*)0x200000000040, "nilfs2\000", 7); memcpy((void*)0x200000000200, "./file2\000", 8); memcpy( (void*)0x200000003000, "\x78\x9c\xec\xdd\x4d\x6c\x1c\x57\x01\x00\xe0\x37\x6b\xaf\xf3\xd3\xb4" "\xd9\x14\x87\x9a\x34\xb4\x09\x81\xb6\xfc\xd4\x6e\x1c\x13\x7e\x22\x20" "\x55\x73\x21\x6a\x2a\x6e\x95\x2a\x2e\x51\x92\x96\x88\x24\x20\x52\x09" "\x52\xf5\x90\xe4\xc4\x8d\x56\x55\xb8\xf2\x2b\x0e\xbd\x94\x1f\x55\x22" "\x17\x14\xf5\xc4\xa5\x12\x8d\xc4\xa5\xa7\xc2\x81\x03\x51\x90\x2a\x71" "\x80\x86\xc4\x28\xeb\xf7\x76\xd7\xcf\xbb\x9e\xb5\x63\x7b\xbc\xde\xef" "\x93\x66\xdf\xbe\x79\x6f\xf7\xbd\xd9\x9d\x99\x9d\x9d\x99\xf7\x5e\x00" "\x86\x56\xad\xf9\x38\x33\x33\x51\x84\x70\xe5\xea\x1b\x47\xfe\xf9\xd8" "\x3f\xb6\x84\x70\x75\xbc\x9d\xa3\xd1\x7c\x1c\xed\x88\xd5\x43\x08\x45" "\x8c\x8f\x66\xef\xf7\xc1\xc8\x5c\x78\xfb\xc3\x57\x4f\x74\x0b\x8b\x30" "\xdd\x7c\x4c\xf1\xf0\xdc\xcd\xd6\x6b\xef\x0b\x21\x5c\x0c\x7b\xc2\xb5" "\xd0\x08\xbb\xae\x5c\x7f\xfd\xdd\xe9\x67\x8f\x5d\x3a\x7a\x79\xef\x7b" "\x6f\x1e\xba\xb1\x3a\x4b\x0f\x00\x00\xc3\xe5\x5b\xd7\x0e\xcd\xec\xfc" "\xdb\x5f\x1e\xde\xf1\xd1\x5b\x8f\x1c\x0e\x9b\x5a\xf3\xd3\xf1\x79\x23" "\xc6\xb7\xc5\xe3\xfe\xc3\xf1\xc0\x3f\x1d\xff\xd7\xc2\xfc\x78\xd1\x31" "\x75\x1a\xcb\xf2\x8d\xc6\xa9\x96\xe5\x1b\xe9\x92\xaf\xb3\x9c\x7a\x96" "\x6f\xb4\x47\xf9\x63\xd9\xfb\xd6\x7b\xe4\xdb\x54\x52\xfe\x48\xc7\xbc" "\x6e\xcb\x0d\x83\xec\x37\x31\x6c\x84\xa2\x36\xd9\xb1\x5e\x37\x42\xad" "\x36\x39\x39\xf7\x9f\x3c\x34\xff\xd7\x8f\x15\x93\xe7\x4e\x9f\x79\xf1" "\x7c\x45\x15\x05\x56\xdc\xbf\x1f\x0d\x21\xec\x31\x99\x86\x7e\xba\xd4" "\xdc\x20\xaa\xaf\xc7\x9a\x4e\xb3\xdb\xab\xde\x03\x01\xcc\xc9\xaf\x17" "\x2e\x70\x31\x3f\xb3\x70\x6f\x5a\xef\x36\xda\x5f\xf9\x37\x9f\xae\x75" "\x7f\x3d\xac\x80\xb5\x5e\xff\x95\x3f\x58\xe5\xff\xfa\x92\x3d\x0e\x2b" "\x67\xa3\xae\x4d\x69\xb9\xd2\x76\xb4\x2d\xc6\x3b\xae\x23\x9c\x0d\x5d" "\xee\x5f\xca\xb7\xbf\xd9\xfc\x8d\xb3\xed\x3f\xbd\x5f\x7e\x3d\xa2\xde" "\x67\x3d\x7b\x5d\x47\x18\x94\xeb\x0b\xbd\xea\x39\xb2\xc6\xf5\x58\xae" "\x5e\xf5\xcf\xd7\x8b\x8d\xea\x6b\x31\x4c\x9f\xc3\xd7\xb3\xf4\xce\xed" "\x27\xff\x4e\x07\xe5\x3b\x06\xba\xfb\x8f\xf3\xff\x26\xd3\xd0\x4e\x0b" "\x8e\x6f\x17\x91\xdf\x2b\x03\x6c\x6c\xf9\x7d\x73\xb3\x51\x4a\xcf\xef" "\xeb\xcb\xd3\x37\x95\xa4\x6f\x2e\x49\xdf\x52\x92\xbe\x75\x5e\xae\x85" "\xe9\xf7\x95\xbc\x1e\x86\xd9\x1f\x5e\xfe\x49\x78\xad\x68\xff\xcf\xcf" "\xff\xd3\x2f\xf5\x7c\x78\x3a\xcf\x76\x7f\x0c\x1f\x58\x62\x7d\xf2\xf3" "\x91\x4b\x2d\x7f\x6c\x91\xd8\x5a\x94\xbf\xb4\x63\x24\x67\x50\xa8\xd6" "\x1f\x8f\x3f\x7f\xea\xcb\x27\x5f\xb8\x3e\x77\xff\x7f\xd1\x5a\xff\xef" "\xc4\xf5\x7d\x4f\x8c\x37\xe2\xd6\x74\x2d\x66\x48\xe7\x0b\xf3\xf3\xea" "\xad\x7b\xff\x1b\xf3\xcb\xa9\xf5\xc8\xf7\x60\x56\x9f\xfb\xbb\xe4\x6f" "\x3e\x1f\x9f\x9f\xaf\x18\x6f\xbf\x4f\xe8\xd8\xcf\x2c\xa8\xc7\xc4\x5c" "\x3c\x1d\x21\x6c\xef\x95\x6f\xf7\xfc\xf7\x6f\x64\xf9\xb6\xc4\x69\x73" "\x56\xdf\xfc\xf8\x64\x6b\xf6\xba\x74\xfc\x91\xb6\xf4\xf4\x79\x8d\x66" "\xcb\x5b\xcf\x96\x63\x2c\xab\x47\xda\xaf\xec\x88\x61\x5e\x0f\x58\x8e" "\xb4\x3e\xf6\xba\xff\x3f\xad\x9f\x13\xa1\x5e\xbc\x78\xfa\xcc\xa9\xa7" "\x62\x3c\xad\xa7\x7f\x1e\xa9\x6f\xba\x3b\x7f\x7f\x79\x51\xbf\x5d\xe9" "\xba\x03\xf7\xa6\xbd\xbd\x2f\xde\xfe\x67\x22\xcc\x6f\xff\xb3\xad\x35" "\xbf\x5e\xeb\xdc\x2f\x6c\x6f\xcf\x2f\x3a\xf7\x0b\x8d\x6c\xfe\x74\x8f" "\xf9\x07\x62\x3c\xfd\xce\x7d\x67\x64\x4b\x73\xfe\xe4\x89\xef\x9d\x39" "\xb9\xd2\x0b\x0f\x43\xee\xfc\x85\x57\xbe\x7b\xfc\xcc\x99\x53\x3f\xf0" "\xc4\x13\x4f\x3c\x69\x3d\xa9\x7a\xcf\x04\xac\xb6\xa9\x97\xcf\x7e\x7f" "\xea\xfc\x85\x57\x9e\x3c\x7d\xf6\xf8\x4b\xa7\x5e\x3a\x75\xee\xc0\xc1" "\x83\x07\xa6\xa7\x0f\x7e\xe5\xc0\xcc\x54\xf3\xb8\x7e\xaa\xf3\xe8\x1e" "\xd8\x48\xda\x3f\xfa\x55\xd7\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\xe8\xd7\x0f\x8f\x1e\xb9\xfe\xd7\x77\xbe\xf4\xfe\x5c\xfb\xff\x76\xfb" "\xbf\xd4\xfe\x3f\xdd\xf9\x9b\xda\xff\xff\xb8\x98\x6b\xeb\x5e\xeb\x98" "\x1f\xba\x8c\x03\x98\xda\x01\xee\xe8\x92\xde\xcc\x93\x75\xb0\x3a\x96" "\xe5\xab\xc7\xe9\x63\x59\x7d\xc7\xb3\x72\x76\x66\xaf\xfb\x78\x0c\x5b" "\xe3\xf8\xc5\xf6\xff\xa9\xb8\xbc\x5f\xd7\x54\x9f\x87\xb2\xf9\x79\xff" "\xbd\x29\xdf\x44\x36\x3f\xef\xc1\x63\x2c\xeb\x75\x24\x1f\x2f\xf0\x53" "\x31\xbc\x1c\xc3\x5f\x06\xa8\x50\x11\x7b\xb0\xc8\x3a\xc6\xca\xd7\xdb" "\x5e\xfd\x5b\xa7\x75\x3d\xf5\x4f\xb1\x84\x7e\x29\xb6\x2c\xbb\xce\xac" "\xb8\xf4\xbd\xa5\x2f\x25\xf5\x63\x92\xda\x7f\xf7\xea\xd7\x29\xed\xff" "\x77\xac\x41\x1d\x59\x79\x6b\xd1\x9c\xb0\xea\x65\x04\xba\xfb\xd7\xca" "\xf7\xff\xdd\x3e\x04\x58\x07\xfd\x1b\x2f\x36\x8d\xad\x72\x1d\x7f\xf5" "\x40\xf5\xcb\xb8\xb9\x77\xda\xa6\xaa\xeb\xb6\x16\xd3\xbe\xb1\xc1\x58" "\x17\xab\x9a\x66\x67\xf5\x41\x09\xac\x0f\x55\x8f\xff\x99\xce\x7b\xa6" "\xf0\xdc\x9f\xbe\xb9\xf9\xee\x94\xb2\xdd\x7c\x7a\xfe\xfe\x32\xef\xbf" "\x14\xee\xc5\x7a\x1f\x7f\x52\xf9\x1b\x6b\xfc\xcf\xd6\xf8\x77\x7d\xed" "\xff\x6e\x2d\x1c\x3d\xa1\xb1\xbc\x72\xff\xfb\xb3\x1b\xef\x77\x14\x1b" "\x76\xf5\xbb\xff\xcd\x97\x3f\xf5\x03\x3d\x9e\x97\xb0\xf8\x99\xe8\x8f" "\xee\x96\x7f\xab\xbd\x28\x8f\x87\xfe\xca\x9f\xfd\x45\x56\x7e\x7e\x41" "\xa8\x4f\xb7\xe2\xf2\xa7\xcf\x7f\x6b\x9f\xe5\x2f\x58\xfe\xdd\x65\x25" "\x5d\x78\xbb\xdb\xdc\xff\xc5\xf2\xd3\xc7\xf6\xc4\xbe\x7e\xcb\x9f\xab" "\x71\x51\x9b\x5f\x8f\xfc\xbc\x71\xba\xfe\x97\x9f\x37\x4e\x6e\x67\xcb" "\x7f\x72\xb9\xcb\xbf\xcc\x81\x1a\xef\xc4\xf2\x61\x98\x0d\xca\x38\xb3" "\x4b\xd5\xc7\xf8\xbf\x4d\x65\xe3\xff\x2e\xb0\xc2\xe3\xff\xf6\x92\xdf" "\x87\xf1\xc5\x18\x4f\x3b\xc2\x74\x9f\x43\x3e\xc2\xc9\x12\xeb\xdf\x8a" "\xa4\xdf\x81\x9d\xd9\xfb\x17\x25\xbf\x6f\xc6\xff\x1d\x6c\x5f\x8d\x61" "\xd9\xf6\x90\xc6\xff\x4d\xeb\x63\xa3\x4b\xbc\xd6\x11\xaf\x77\xf9\x6c" "\x37\xea\xbe\x06\x06\xd5\x07\xeb\x77\xfc\xdf\xf6\x0f\x55\xf5\x75\x59" "\x0f\xd3\xe1\x75\x50\x87\xf2\xef\xab\xfa\x7a\x98\x96\x30\xcd\xce\xce" "\xae\xee\x09\xad\x12\x95\x16\x4e\xe5\x9f\x7f\xd5\xff\x13\xaa\x2e\xbf" "\xea\xcf\xbf\x4c\x3e\xfe\x6f\x7e\x0c\x9f\x8f\xff\x9b\xa7\xe7\xe3\xff" "\xe6\xe9\xf9\xf8\xbf\x79\x7a\x3e\xbe\x5e\x9e\xbe\x35\x4b\xcf\x3f\xcf" "\x7c\xfc\xdf\x3c\xfd\xa1\xec\x7d\xf3\xf1\x81\x27\xb2\x3f\xd8\x79\xfa" "\x27\x4a\x5e\xbf\xab\x24\xfd\xe1\x92\xf4\xdd\x25\xe9\x9f\x2c\x49\xdf" "\x5b\x92\xfe\x48\x49\xfa\xa3\x25\xe9\x0f\x96\xa4\xef\x2b\x49\xff\x74" "\x49\xfa\x67\x4a\xd2\x1f\x2b\x49\x7f\xa2\x24\xfd\xb3\x25\xe9\x1b\x5d" "\x6a\x8f\x32\xac\xcb\x0f\xc3\x2c\x6f\x9f\x67\xfb\x87\xe1\x91\xda\xd7" "\xf6\xda\xfe\xc7\x4b\xd2\x81\xc1\xf5\xd3\xb7\xf6\x3f\xf3\xc2\xef\xbf" "\xdd\x98\x6b\xff\x3f\xd6\x3a\x1f\x92\xae\xe3\x1d\x8e\xf1\x7a\xfc\xef" "\xfc\xa3\x18\xcf\xaf\x7b\x87\x8e\xf8\xdd\xb4\x77\x62\xfc\xef\x59\xfa" "\x7a\x3f\xdf\x01\xc3\x24\xef\x3f\x23\xff\x7d\x7f\xbc\x24\x1d\x18\x5c" "\xe9\x3e\x2f\xdb\x37\x0c\xa1\xa2\x7b\x3b\x89\x7e\xfb\xad\xea\x75\x9c" "\xcf\x60\xf9\x5c\x0c\x3f\x1f\xc3\x2f\xc4\xf0\xc9\x18\x4e\xc6\x70\x2a" "\x86\xfb\x63\x38\xbd\x46\xf5\x63\x75\x3c\xf3\xbb\xb7\x0f\xbd\x56\xb4" "\xff\xef\x6f\xcf\xd2\xfb\xbd\x9f\x3c\x6f\x0f\x94\xf7\x13\x75\xa0\xcf" "\xfa\xe4\xe7\x07\x96\x7a\x3f\x7e\xde\x8f\xdf\x52\xdd\x6b\xf9\xcb\x6c" "\x0e\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x50\x99\x5a\xf3\x71\x66\x66\xa2" "\x08\xe1\xca\xd5\x37\x8e\x3c\x7f\xec\xf4\xd4\xdd\x39\xdf\x68\xe5\x68" "\x34\x1f\x47\x3b\x62\xf5\xd6\xeb\x42\x78\x2a\x86\x23\x31\xfc\x79\x7c" "\x72\xfb\xc3\x57\x4f\x74\x86\x77\x62\x58\x84\xe9\x50\x84\xa2\x35\x3f" "\x3c\x77\xb3\x55\xd2\x7d\x21\x84\x8b\x61\x4f\xb8\x16\x1a\x61\xd7\x95" "\xeb\xaf\xbf\x3b\xfd\xec\xb1\x4b\x47\x2f\xef\x7d\xef\xcd\x43\x37\x56" "\xef\x13\x00\x00\x00\x80\x8d\xef\xff\x01\x00\x00\xff\xff\x34\x36\x25" "\x6a", 2687); syz_mount_image(/*fs=*/0x200000000040, /*dir=*/0x200000000200, /*flags=MS_SYNCHRONOUS*/ 0x10, /*opts=*/0x200000000180, /*chdir=*/5, /*size=*/0xa7f, /*img=*/0x200000003000); break; case 1: // openat arguments: [ // fd: fd_dir (resource) // file: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 32 00} (length 0x8) // } // flags: open_flags = 0x143041 (4 bytes) // mode: open_mode = 0x0 (2 bytes) // ] // returns fd memcpy((void*)0x200000000040, "./file2\000", 8); res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x200000000040ul, /*flags=O_SYNC|O_NOATIME|O_CREAT|FASYNC|O_WRONLY*/ 0x143041, /*mode=*/0); if (res != -1) r[0] = res; break; case 2: // write$UHID_INPUT arguments: [ // fd: fd_uhid (resource) // data: ptr[in, uhid_req[UHID_INPUT, uhid_input_req]] { // uhid_req[UHID_INPUT, uhid_input_req] { // type: const = 0x8 (4 bytes) // data: uhid_input_req { // data: buffer: {75 e7 0a 31 3d 5a 15 d8 66 44 ab 26 67 43 13 20 // 06 7b da 86 bb d0 2b dd 2e 07 da 1b cc de fd 4d 3f 3f 9b 89 ab // 0c ee 34 a8 be 06 9e 01 a9 3f 77 90 81 5f e6 05 84 ad 6f 73 00 // 0b ee bf 79 cf 03 6f 47 ad 8c 62 fa e1 12 23 30 23 bb f5 4d 59 // 33 ef 3d 40 59 64 93 f4 43 4c a5 f9 a9 80 66 18 f8 1f 61 86 01 // f3 c4 9f 0f 0a f2 0d a3 75 57 54 9f b8 66 23 4c 0d 96 06 c9 92 // 13 95 3c bb e6 4f 60 27 cd 8b c7 14 8b 9b 61 c8 a3 98 87 c5 b5 // c3 13 93 74 a1 51 64 66 36 29 c9 ae 30 df ba a7 50 ed c6 f4 53 // c1 e0 04 31 6a 34 91 1a 71 c2 91 07 14 b1 7f b6 1b 76 43 a2 91 // f0 f0 1a b5 cc d2 04 a1 a1 33 1b bd 2f ba a9 6c fa 18 e7 82 8a // e4 b3 70 09 0e 64 ba 2f 83 e7 1f 68 39 5a c4 cd c4 eb b7 38 2c // 2d f0 a1 7c 11 8a 29 fe 63 9d 60 5a 33 30 ef 6e 05 d7 7d 02 a8 // f0 cb 2d 13 5d 39 ed 30 69 93 ed 99 8d 8c 4e 31 5c 10 15 a9 89 // 05 fc f6 f8 45 21 97 33 dc fa d7 aa 95 6f b3 77 30 fc 23 0c cc // 69 5a 18 26 f0 80 46 0e 6a 70 71 45 75 24 84 6f 9a 63 0a 5c 0e // 7a 8f 3d 5a 94 5d 09 76 d6 29 bf a2 0c ee ab e6 be bb 27 88 aa // f8 b8 2a ca 5d 0e 73 6b 8f 4b 0b 83 7e 9d e4 56 cb 47 bb 76 2c // 06 a6 51 8a 09 b6 6b 1d cf ae cf 5b 82 05 6d 59 ec aa 04 10 25 // dd 84 bd e9 83 e9 2b 8c e7 7d 60 f6 e8 ac 67 d4 7c 33 60 51 f8 // a4 54 6b 1e 20 1b 1b d4 af fe ac 29 64 bd c6 7e 41 81 96 bd fb // 73 be 0e 9b 28 35 06 ce eb 1d 06 99 ff a7 00 9c f0 38 1d 13 ab // c2 8a c6 b7 5c da 7c 7a af 2f 78 a4 0b ca 5e 65 81 7f d9 a1 1a // 03 da 99 84 a2 a9 11 94 05 7b 4b f0 bc d9 e5 43 0f fa 50 87 04 // ea a7 97 2e f4 c1 82 15 f0 e9 0a 63 f0 d3 77 dc 51 16 34 1c 68 // 2b d1 79 c5 96 c6 73 9e 6a 57 46 88 fb b6 24 7c a0 4a 0f d8 ff // 3a ea 9e 4b f1 71 54 cc 1f b7 8b 7b ea 43 21 48 2e ab 87 37 5f // 45 09 6d b1 05 45 da 20 10 62 cc cb 0b 7b ec 1e 15 97 50 0c 08 // 78 14 1d 67 a7 54 ce ae 74 8d 24 77 77 51 b9 6c ce 44 85 a7 8c // b4 b5 aa f4 ee 24 d5 56 a6 46 d7 d9 db 92 b6 d9 5b 08 c2 be 00 // c4 55 7d 40 45 18 a4 a9 ea 61 e4 ea c2 48 0a be 0f 5a dc 7c a8 // e0 2d 0c 5b 35 93 9a 25 a9 ca 9c 39 7f 53 ac 98 88 34 b0 1d 13 // 12 2d 7b ef 22 ea d5 cb 5f 0e e2 55 ce b1 ec 81 ec a7 61 5d e7 // 64 ce 3a 21 8f 62 c8 60 11 f9 8e 3c 87 ee e9 3a 36 cf f0 f1 ea // b1 ff 67 ff bb 29 49 1b 91 16 b0 1a 65 bf f9 bc 51 be 1f 06 70 // 62 9a d1 aa 6a 7e f1 d2 04 cf 30 0a 2e 16 6b fb 87 49 6b b5 af // 3f 96 7f d3 03 d0 de 1f cd 90 d6 8b 1d a1 88 dc 96 bf 06 4a 18 // 7e 1b 38 80 58 28 b9 3e b9 97 3a 42 ab 7a c8 ca 18 0a 88 dd 48 // 30 03 e3 fa 28 e0 e5 61 fc 5e 5b 39 7a 6c 40 f3 e4 ec a1 c9 f0 // 54 9f 6a 1d f5 12 f6 ff 3a 74 ba 36 94 af 1b 61 16 2d 12 1c 12 // b6 13 7b 16 bf 75 5d 07 2f ca 05 26 cf 49 b1 0a cd cf 7c 3a f8 // 1a 90 2e f2 d0 52 31 4c d4 e7 58 a7 66 bf bf 43 4b 46 2d 98 58 // e2 c9 07 2e dc 54 3f e9 94 df 64 66 2a c3 13 ea 70 b1 4b c3 fc // bb 4e c2 61 dc 4c 81 a3 c2 0c 79 59 76 bf 3b ba 33 67 a9 e6 02 // f8 53 fd db 7c a2 04 95 1b 10 11 5d 04 c2 47 fc 93 91 bf 98 a3 // 50 87 10 4d 2b 61 ab f5 1f b0 ee 44 7a 98 aa 3c 13 30 0b 56 a0 // 8e 99 98 30 03 ce 58 ac 1d 7c 0d d9 6c 44 b5 81 f2 45 1d f7 91 // 03 8a 71 b5 27 47 19 ca 60 71 32 1f d2 18 e5 66 56 cf 45 e4 f4 // 1f 83 54 94 95 0a d9 4f 64 c5 19 b6 96 eb e8 2f e8 9b 64 59 04 // ab b4 a0 ee 1e a5 8d 1d 7a b9 3b 49 e3 20 ca 5d 2d 7d 01 be d7 // 8c b7 61 b5 5f f7 a5 5b c0 31 3a e9 ac 17 b8 02 36 1e 33 9f d2 // f7 bb 40 d4 a4 5a 94 90 74 02 66 04 d8 d2 c1 72 bd 8e bb cc cb // ee 23 0d c7 06 a6 fc 7b 85 65 76 10 79 f3 2b 5c 67 b5 17 06 ba // 4d 42 6f d8 42 8a 4d f0 39 2d f6 f9 47 25 03 20 02 ec e4 66 ca // 93 55 c5 b8 44 f1 9c a3 1b 70 53 5d 8b 3c 60 8e 5b 1f 2d d2 42 // 80 14 f8 9f 30 20 5e a1 1f 5b 4f a9 4c 0c 42 95 f8 e9 ab 09 06 // 28 00 c7 a6 b7 6c 91 05 8e d7 85 d5 63 de 50 51 83 73 b1 5e 16 // 16 ba a4 30 4a 50 78 22 40 87 88 ae be 2e 15 40 18 39 4b 4d 58 // fb 7b fe 71 01 b8 51 3c f6 8a ca d6 30 71 06 45 d5 ee 0c 1a f6 // 0b d9 dd 49 a7 77 42 0e 01 67 d0 22 76 02 c4 dc ce c2 c5 d8 be // 0f e5 a7 48 c1 6c c2 94 fd ab b1 72 7f b1 6e 9b 06 ed 59 f7 21 // 9b 73 76 7f 6a d6 38 5d 46 1b e8 68 82 6c d4 d7 49 f8 4c bd d2 // e5 d6 30 51 e6 06 9f 17 08 f6 c2 37 cd 5a 01 2d 1e 6f ec 70 d6 // f4 b6 1c df a9 13 36 72 70 4b 9f a9 a5 d3 0a c1 55 24 a3 01 6d // c8 65 aa 52 96 2c 99 5f a5 0d 95 1b 44 cd 49 bb 29 43 6b 0c 61 // 6e f7 10 97 e5 c5 c9 0c 5c f0 94 b2 02 cf c2 1b 6d 00 2f 85 d6 // 86 c2 c8 01 fb c8 07 88 74 70 a2 74 0f ef 1b 2b 8a ca 2c 96 ce // 76 50 ed 98 29 52 98 02 77 aa cd ca cb 2f 44 7b fc e8 1d 27 e2 // eb 32 ee b1 26 20 99 16 da 91 e3 59 68 6e 58 c3 0a 05 bd bf 19 // a4 17 87 1b 15 73 c0 d0 94 fd 55 1e 15 e9 1d 21 00 ad aa 78 a6 // 44 ac 74 82 7c 9d 4d 0a 98 2e ef 6e 7d 72 60 86 45 d1 a3 2f 21 // 02 aa da c5 41 a2 e6 1b 5b f0 f5 9a 43 5b 77 f6 21 b1 08 d5 45 // ce 3b ba 95 28 1b 04 1a 7b c1 46 e1 b2 bc f7 43 78 a8 c7 d1 11 // 0c c1 23 eb c6 01 de a4 0f 08 b6 35 c6 ad 01 2c c5 86 fc 47 a9 // ab c1 a1 e1 15 cc 57 0e 35 5f 62 00 2d a9 e8 07 55 4e ed 4c 6c // 7d 07 33 1f 3e b3 bc 94 15 cf 2e 7b 83 dc f4 73 3b 66 7d 73 61 // 66 6b 44 26 c2 dd 97 e3 a2 6b 72 c1 8b 3a 60 91 9b 09 98 21 f0 // 1c fa 3f 5d 6f 7c fd 25 bf c3 2b 06 2c fd 31 56 8d 9c 70 b7 16 // 0e e5 2e 3d 73 e2 43 c6 97 39 77 d2 cd 2d f0 99 6f bf 07 11 8d // e7 78 28 f8 a1 24 c7 ba ae 5a 4f 8b c8 f2 51 49 be 69 ff 8d 89 // b7 24 92 f3 be e3 0d 05 dd ae a6 9c 8d a2 02 09 b8 b4 e8 15 05 // f8 f9 f4 57 23 9c 1e 7b 51 a2 5d 4c 93 ca bf 79 21 0c 78 0c 5b // 14 ef ca a6 62 64 fa fd 8a f7 9c 44 18 0a 1f 0d e5 13 75 0c fc // 0a 64 b9 73 18 40 69 7a ec 8c 7b aa de 01 bb a6 73 a3 e6 b0 36 // fb 49 0b e6 a0 43 06 76 ab 99 41 a7 85 f1 6f e0 cc ba 0f fe 46 // 96 e2 71 01 ba 20 92 f2 00 96 aa c0 02 0d 7b b6 29 07 de e7 cc // b1 f1 6d 3c 3f 24 1e 2b 97 b7 74 64 dc ed 1a 65 11 d3 55 42 25 // a9 32 a3 99 67 08 4e 98 00 36 93 72 33 ee bd f5 61 69 e3 58 46 // 5b 50 db 96 81 c1 be fb e5 f1 a5 7e 48 b9 c2 35 00 3f 3c 83 46 // 0d b4 06 93 85 71 94 8e 54 de f1 73 f9 d5 66 7e f4 00 b9 bc 64 // 92 79 aa 33 a8 da 44 40 a8 2c ae 73 00 d4 7a 4f da 5a 42 9c ed // 3e 36 15 44 12 fa 4b bc 5a 71 45 2d cf 5a 0e 08 5b 2f dd 06 43 // 04 58 d1 0b d7 97 38 06 4e 03 f4 5f d2 b3 a7 6e 62 6b 6c 55 ef // 61 77 28 20 57 42 b2 12 73 c9 ea 6a d6 5d 2b 4d 23 c1 4a 83 fd // 08 91 da 1c ec a9 7b 6c e5 54 60 1c 56 e6 2d 79 51 91 4e 93 1e // dc f1 c6 6f 6a ed 6f 6e 2d 6b ac 34 33 35 aa d7 12 aa 43 83 4d // f8 fd e2 c6 b0 43 e0 24 b9 56 46 d9 23 7c b8 8e 90 ca c8 9b 69 // e9 fa 32 07 39 5a e1 08 8f f3 aa 15 de b4 7a e6 8a 79 28 a2 5d // 1d fe 86 75 7b f1 26 f0 55 b5 bf aa 20 2e 7b 64 d3 80 85 2c 78 // 25 74 ea d9 8c 2e b7 5a 87 25 f2 d6 3d 74 5f 36 b5 03 77 45 cf // 84 f8 e4 3b 4d 23 a9 88 f5 d0 d6 ce ab e5 df a7 6a 3f 29 26 81 // 15 e5 04 b1 85 dc 39 bc 2b d3 57 3b 3f fc 3a de c7 10 4d 90 08 // 30 a0 cc 94 63 15 a3 97 0a 14 b8 20 fb 01 2c 05 f1 48 63 68 25 // 34 5a c0 ff ff e8 79 a0 0b 2d db 1d e8 dc cf 9e c7 a6 af 1a f4 // 72 55 54 f7 cf 8e 60 8b 89 ec c8 0a c3 cd 49 6f d9 a2 3f 6d af // 48 7f 93 e9 6e 7a db 72 c0 c5 80 99 32 44 42 77 fa 8d 5d 72 e9 // a1 d4 98 9d 55 68 72 d6 9e d0 17 67 07 b4 b9 ea 93 78 60 92 e2 // 37 cf 4d ff 2f 6f 13 a6 5d 27 2e 49 46 7f 9c 39 58 a3 db 7a 97 // 04 e9 67 93 32 a7 1e c8 7c f7 74 26 84 7f 68 41 11 37 cd 3a 72 // 8a f1 a1 a9 bd 49 be d3 60 f3 d3 7b 25 86 70 43 79 e0 ce 94 63 // de 52 55 a4 58 d6 32 aa ec 40 3e df 9e 2e 9c f2 02 86 84 b6 4d // e8 a4 e9 da 76 ee b1 e7 f2 f9 d7 b4 40 3c 60 78 49 8c 81 37 dd // de e8 02 1a f6 a9 a3 e7 02 d0 d0 d8 f8 1a d2 da 9b b3 ad 40 18 // 90 df 84 7f 53 9a 54 22 37 77 5c bf 1b c6 ab 61 79 3d 6f bc 64 // 87 e7 be d2 17 ce 39 53 d6 94 5a 49 bb b3 64 e6 a6 f8 19 41 f9 // 9e dc 0b b9 82 41 3b 4f 7e 78 95 0e 15 67 3d d8 46 8b 88 12 58 // d7 f3 27 07 4e 81 7a d6 9e 9f 0f 0b a6 d2 31 08 ab fe f5 75 44 // 4d ec d5 b8 8d 89 46 7d 2e 6b 11 c3 86 03 49 ae 15 26 85 7a 64 // 4e 12 18 5a 03 09 2f 50 b2 38 7a 6e 99 c3 36 78 b4 4a c1 05 63 // 4c 08 40 77 99 a9 1a 03 4c 43 18 3c 82 04 93 44 d6 15 4e d1 19 // 4c 13 60 f9 7b 2b 6e 17 a3 54 fd a3 54 88 f8 69 36 aa 1f 7e ef // d5 f5 3e 2a 6a ad 6d cb 71 56 46 da 2b ed ca ad 7e 8d bd 9b e9 // b3 11 f8 ec 70 5b 31 9d 4b 5d a9 d9 50 d3 94 04 c3 64 cb 9c f4 // b8 6e 42 4d d3 42 18 fe 4d 5c 94 c6 cb a8 ed 84 50 19 a3 93 3e // ae 13 54 c7 e5 5d de 53 9e 2d 0b e9 eb 14 72 22 8d 0f ce 2f db // c1 ae b2 5d d6 ce 5d 3e 49 a9 f3 54 b1 a9 63 a5 63 4e 17 2a 13 // c3 e7 bd d9 34 a2 e3 15 e2 8d 3a 74 95 ac 35 db a2 df cd da 62 // 0e 5d 39 c3 3e be 8f 08 95 3e 7b 78 36 18 38 66 2b 25 92 66 6e // 88 b5 98 e7 39 9c c3 75 70 4f d2 83 75 9d f3 dc bd d0 57 97 50 // bb 2e 75 2b f7 0a 6f a7 75 6d ba f1 85 79 9b 47 d5 25 76 8b 2a // 52 9d 5a 95 c7 45 72 50 86 a6 51 bf c1 e2 11 bf 63 b6 8e ab 04 // 1b a7 7c 70 a6 a1 3a 64 6b 59 75 6f c5 c8 27 c0 17 b2 e7 39 bd // 0c 07 40 60 13 49 25 30 28 60 00 18 52 a2 5a eb 85 2f 42 43 6f // a0 0a 30 87 dc b7 f7 04 6c 5f c0 71 9e f7 d1 0c 75 17 cf c7 6e // 69 df ac a5 45 20 2d 90 f1 ef 78 1e 6d 65 c4 3a db ff a7 3d be // 4c ae 4e 54 e2 32 cf 6d 62 c4 b1 8e 09 be 28 7d 24 f6 ae d3 c4 // 06 6e 71 bc e7 e9 76 25 7b a5 da 46 68 e1 46 28 2c 94 3b 97 28 // 15 a7 86 6f 04 25 5b 4b 12 54 8f 68 53 55 84 59 5a 4a 40 ba cc // 63 58 70 a6 94 a1 bd 31 1c 25 18 db 21 ed dc 85 32 e2 7a 08 65 // 18 8b 15 b0 67 4d d0 55 20 6d d8 a2 31 9e 38 61 26 96 1a c2 07 // f8 37 b0 b2 ef a6 82 01 6d f2 bc b4 96 90 81 f3 ac 5c 70 45 57 // 8b cf 8e 91 dc 83 c5 45 41 27 cb 9d 48 78 8e 8f 6b 11 70 27 30 // 40 ae c9 c5 4c 2c a7 1e d2 2d d5 b7 31 da 15 85 44 e2 da 13 11 // 10 70 72 63 01 98 48 e4 e1 ef 0c 73 25 c8 b7 b8 7d f7 88 4a e1 // 26 60 fe b2 e2 f1 b9 dd 00 67 8b d7 03 a1 6e 4b 9f c4 3f 11 b1 // 34 0f 8e e2 8d 1f c4 cf 37 6c a7 eb 83 ab 06 ea 7a a4 87 91 5b // 76 c3 bd 11 22 35 26 6f 7d 22 47 74 e8 a6 e7 32 fb 92 33 16 81 // 82 39 b0 af 75 70 e0 c9 6b 5e 12 e2 a4 dd 79 85 9d 04 0a 89 c7 // 8c 26 e7 fd fd 35 1c b1 7a 01 33 92 9c 02 ff 92 72 c7 c7 20 d7 // 66 68 ec e8 55 00 1a 7a 79 48 2f ce 61 4a 7c d2 4b 12 2a 6d 1e // 53 d2 f0 1d 71 f0 cc a2 58 2e bb 56 1e 03 02 e7 17 e6 2a 6d dd // 5b 44 e0 02 c5 3e 08 8e c6 fe 69 ae b6 f2 a0 e9 fd 7f 6f c1 d4 // 5a d8 e9 f2 80 4b 1e b1 b4 33 a4 4a 1f 23 88 7b ca 29 59 71 1a // 4c fe 95 0f ce fa 20 2f 78 dc a7 c8 08 b2 0e 03 7b 8b 4b 07 05 // 3e 2d 64 5f 39 c1 0e ef 35 7c 7c 47 ac 1d f2 de 82 3b 83 ea 17 // fd 87 fe 68 30 42 8a ac 0c a1 6b 63 67 b5 b7 65 12 bd 3d 21 6e // 4a 33 b1 22 90 a1 dd 22 5c 67 42 8b 5d 2f e3 dd 0f 5e f6 d3 96 // bf 48 37 4e a5 66 2a 2c d2 eb 01 74 f6 7e 2b 1b f7 5b 90 cd e0 // a9 3a 86 ec fd c7 39 3d f1 5d 2d 64 1f f3 db 0f f1 30 b1 e3 f9 // d1 58 84 56 94 85 ac 16 ce e2 08 56 f9 66 4a e8 89 3e 38 31 28 // fe aa 56 51 af d5 4b 22 e1 ce d7 ab cc 9d 90 37 84 3e c7 95 cf // cd 86 fb 47 23 65 44 12 7b 1a 85 35 f7 ee 84 c1 b5 0b 37 c1 e1 // 96 f0 c8 a0 4c 05 86 d9 3a b9 cd c6 33 56 f1 ea 1a da 99 d7 fd // 00 78 36 3d 9f 81 be 92 d1 4d 29 bb e3 3e de e7 bf 23 e9 ba 8c // aa 98 c3 35 95 ac 6b 53 78 8c 72 6d de 6f c4 e0 ab 53 33 c7 42 // cc 95 d0 dc f7 71 99 57 8f 79 0d 2b 65 4b b5 0f 05 c1 81 86 c2 // d2 6d 9a 34 2a 45 32 84 08 45 fa 1e 8d 0c 69 4d bc 45 17 6a 5d // ae d3 f9 00 f7 f2 2b 14 4d 57 9e 34 88 a3 24 c1 fc 43 e9 03 a2 // 13 37 65 b5 01 97 aa 19 e5 43 9d 02 9f 17 dd fb 2c 80 44 19 a5 // fa e6 a1 c9 12 a2 4b 15 18 1c d8 1b df 23 90 39 80 a4 4d 5e 66 // 4d d9 14 d1 6b ab 6b 53 9d 88 49 ed 85 0d 97 2d 68 83 c0 0d 8e // 73 00 d3 18 a5 e5 0b 6a c7 15 5e 3f 34 78 20 f2 cc 43 c3 f4 6a // 44 bc 86 ef dc 6a 8e 06 da 56 2d 1f b1 1e c7 df 11 88 1a 58 89 // fc 5c 39 42 69 b2 4c 8a 6d a5 db 4c 3a e9 30 fc c3 50 79 c9 de // 5b 68 88 67 e7 35 7b 7f 23 05 09 e0 fe d9 ff 66 3c 9c 92 37 a5 // 54 01 eb d5 72 75 04 fc 81 2e b5 6d 1a 88 ed 7d 4e f0 1b 59 36 // b0 27 ab ae 7f 4a 29 f0 e3 2f ce 98 5c c3 7c ec c9 ac b0 47 b2 // 91 96 c1 6b b1 5e e5 54 ab 1f 0f 70 dd 02 37 a7 73 73 0a 2e ab // b9 7e 25 dd 11 ec 12 a0 be 48 6e 76 e1 1e 00 22 30 2e 9f da 94 // c3 8a 0b 25 f6 e7 8b b2 c4 9b 18 21 8f f3 81 34 e7 b3 f5 c6 a2 // 8f d6 be 3f ff 81 f2 13 b7 06 54 26 28 8c 22 41 6b 05 bd 5d 7b // fc 2a e6 00 1f 49 5e 4c 8a 8d bc 26 27 93 a7 25 85 f1 5f 66 a4 // 90 f5 70 c3 33 d2 c4 f1 bf e4 e1 ce ee 26 0c c5 cb ab 53 9c 93 // b2 39 4e 93 79 9b a0 cf 1a d0 f5 0a 78 ec 19 68 ec 6d d7 0b 16 // 71 68 04 5a 2f 91 18 0b 32 79 c5 f4 eb de 32 af 0a 64 31 3e 9d // f5 df 16 90 ba 8d ea 6e 1d e1 8b 4f 95 fb d7 3d 08 5c b0 17 d1 // 34 ab de a9 93 df 1e 75 6e 1a d2 ca 66 05 28 58 53 1e 59 73 19 // e2 54 85 2e 20 73 6d dc 50 69 28 d3 da e8 f1 96 ee 80 8c 08 fe // d9 58 7f 5b 1f 8c d3 de 89 85 af d3 64 70 76 bb 87 22 43 58 e1 // 07 79 5b 83 cb 6c 0b be bb da 9b 36 ec fb 00 2a 91 42 7f 14 39 // 8d dd e4 d1 f6 70 61 6f 31 54 07 5e 62 c3 ec b2 aa 35 ec c5 9b // 82 1e 71 e2 98 c5 4d 5a 8b 0f a1 cc d3 09 1b fc c9 06 9c da 0c // f9 c8 aa a6 b4 79 5d ff ee 56 fb 5f 6e da 40 57 d0 6e 81 70 3b // 53 0c 53 ec 6b d4 6a a0 2a 73 33 96 ed 6d ce 94 9f cc 00 2a 10 // cc 07 dd 72 b9 a1 ee c6 97 b9 21 72 dd a2 ad e6 07 77 21 38 12 // 2b 2a 9a 09 66 56 cd 36 ba 03 6f da 57 74 c8 0b e2 16 b1 4b 67 // ab 3a 45 85 a5 af} (length 0x1000) size: len = 0x1000 (2 bytes) // } // } // } // len: len = 0x1006 (8 bytes) // ] *(uint32_t*)0x200000002480 = 8; memcpy( (void*)0x200000002484, "\x75\xe7\x0a\x31\x3d\x5a\x15\xd8\x66\x44\xab\x26\x67\x43\x13\x20\x06" "\x7b\xda\x86\xbb\xd0\x2b\xdd\x2e\x07\xda\x1b\xcc\xde\xfd\x4d\x3f\x3f" "\x9b\x89\xab\x0c\xee\x34\xa8\xbe\x06\x9e\x01\xa9\x3f\x77\x90\x81\x5f" "\xe6\x05\x84\xad\x6f\x73\x00\x0b\xee\xbf\x79\xcf\x03\x6f\x47\xad\x8c" "\x62\xfa\xe1\x12\x23\x30\x23\xbb\xf5\x4d\x59\x33\xef\x3d\x40\x59\x64" "\x93\xf4\x43\x4c\xa5\xf9\xa9\x80\x66\x18\xf8\x1f\x61\x86\x01\xf3\xc4" "\x9f\x0f\x0a\xf2\x0d\xa3\x75\x57\x54\x9f\xb8\x66\x23\x4c\x0d\x96\x06" "\xc9\x92\x13\x95\x3c\xbb\xe6\x4f\x60\x27\xcd\x8b\xc7\x14\x8b\x9b\x61" "\xc8\xa3\x98\x87\xc5\xb5\xc3\x13\x93\x74\xa1\x51\x64\x66\x36\x29\xc9" "\xae\x30\xdf\xba\xa7\x50\xed\xc6\xf4\x53\xc1\xe0\x04\x31\x6a\x34\x91" "\x1a\x71\xc2\x91\x07\x14\xb1\x7f\xb6\x1b\x76\x43\xa2\x91\xf0\xf0\x1a" "\xb5\xcc\xd2\x04\xa1\xa1\x33\x1b\xbd\x2f\xba\xa9\x6c\xfa\x18\xe7\x82" "\x8a\xe4\xb3\x70\x09\x0e\x64\xba\x2f\x83\xe7\x1f\x68\x39\x5a\xc4\xcd" "\xc4\xeb\xb7\x38\x2c\x2d\xf0\xa1\x7c\x11\x8a\x29\xfe\x63\x9d\x60\x5a" "\x33\x30\xef\x6e\x05\xd7\x7d\x02\xa8\xf0\xcb\x2d\x13\x5d\x39\xed\x30" "\x69\x93\xed\x99\x8d\x8c\x4e\x31\x5c\x10\x15\xa9\x89\x05\xfc\xf6\xf8" "\x45\x21\x97\x33\xdc\xfa\xd7\xaa\x95\x6f\xb3\x77\x30\xfc\x23\x0c\xcc" "\x69\x5a\x18\x26\xf0\x80\x46\x0e\x6a\x70\x71\x45\x75\x24\x84\x6f\x9a" "\x63\x0a\x5c\x0e\x7a\x8f\x3d\x5a\x94\x5d\x09\x76\xd6\x29\xbf\xa2\x0c" "\xee\xab\xe6\xbe\xbb\x27\x88\xaa\xf8\xb8\x2a\xca\x5d\x0e\x73\x6b\x8f" "\x4b\x0b\x83\x7e\x9d\xe4\x56\xcb\x47\xbb\x76\x2c\x06\xa6\x51\x8a\x09" "\xb6\x6b\x1d\xcf\xae\xcf\x5b\x82\x05\x6d\x59\xec\xaa\x04\x10\x25\xdd" "\x84\xbd\xe9\x83\xe9\x2b\x8c\xe7\x7d\x60\xf6\xe8\xac\x67\xd4\x7c\x33" "\x60\x51\xf8\xa4\x54\x6b\x1e\x20\x1b\x1b\xd4\xaf\xfe\xac\x29\x64\xbd" "\xc6\x7e\x41\x81\x96\xbd\xfb\x73\xbe\x0e\x9b\x28\x35\x06\xce\xeb\x1d" "\x06\x99\xff\xa7\x00\x9c\xf0\x38\x1d\x13\xab\xc2\x8a\xc6\xb7\x5c\xda" "\x7c\x7a\xaf\x2f\x78\xa4\x0b\xca\x5e\x65\x81\x7f\xd9\xa1\x1a\x03\xda" "\x99\x84\xa2\xa9\x11\x94\x05\x7b\x4b\xf0\xbc\xd9\xe5\x43\x0f\xfa\x50" "\x87\x04\xea\xa7\x97\x2e\xf4\xc1\x82\x15\xf0\xe9\x0a\x63\xf0\xd3\x77" "\xdc\x51\x16\x34\x1c\x68\x2b\xd1\x79\xc5\x96\xc6\x73\x9e\x6a\x57\x46" "\x88\xfb\xb6\x24\x7c\xa0\x4a\x0f\xd8\xff\x3a\xea\x9e\x4b\xf1\x71\x54" "\xcc\x1f\xb7\x8b\x7b\xea\x43\x21\x48\x2e\xab\x87\x37\x5f\x45\x09\x6d" "\xb1\x05\x45\xda\x20\x10\x62\xcc\xcb\x0b\x7b\xec\x1e\x15\x97\x50\x0c" "\x08\x78\x14\x1d\x67\xa7\x54\xce\xae\x74\x8d\x24\x77\x77\x51\xb9\x6c" "\xce\x44\x85\xa7\x8c\xb4\xb5\xaa\xf4\xee\x24\xd5\x56\xa6\x46\xd7\xd9" "\xdb\x92\xb6\xd9\x5b\x08\xc2\xbe\x00\xc4\x55\x7d\x40\x45\x18\xa4\xa9" "\xea\x61\xe4\xea\xc2\x48\x0a\xbe\x0f\x5a\xdc\x7c\xa8\xe0\x2d\x0c\x5b" "\x35\x93\x9a\x25\xa9\xca\x9c\x39\x7f\x53\xac\x98\x88\x34\xb0\x1d\x13" "\x12\x2d\x7b\xef\x22\xea\xd5\xcb\x5f\x0e\xe2\x55\xce\xb1\xec\x81\xec" "\xa7\x61\x5d\xe7\x64\xce\x3a\x21\x8f\x62\xc8\x60\x11\xf9\x8e\x3c\x87" "\xee\xe9\x3a\x36\xcf\xf0\xf1\xea\xb1\xff\x67\xff\xbb\x29\x49\x1b\x91" "\x16\xb0\x1a\x65\xbf\xf9\xbc\x51\xbe\x1f\x06\x70\x62\x9a\xd1\xaa\x6a" "\x7e\xf1\xd2\x04\xcf\x30\x0a\x2e\x16\x6b\xfb\x87\x49\x6b\xb5\xaf\x3f" "\x96\x7f\xd3\x03\xd0\xde\x1f\xcd\x90\xd6\x8b\x1d\xa1\x88\xdc\x96\xbf" "\x06\x4a\x18\x7e\x1b\x38\x80\x58\x28\xb9\x3e\xb9\x97\x3a\x42\xab\x7a" "\xc8\xca\x18\x0a\x88\xdd\x48\x30\x03\xe3\xfa\x28\xe0\xe5\x61\xfc\x5e" "\x5b\x39\x7a\x6c\x40\xf3\xe4\xec\xa1\xc9\xf0\x54\x9f\x6a\x1d\xf5\x12" "\xf6\xff\x3a\x74\xba\x36\x94\xaf\x1b\x61\x16\x2d\x12\x1c\x12\xb6\x13" "\x7b\x16\xbf\x75\x5d\x07\x2f\xca\x05\x26\xcf\x49\xb1\x0a\xcd\xcf\x7c" "\x3a\xf8\x1a\x90\x2e\xf2\xd0\x52\x31\x4c\xd4\xe7\x58\xa7\x66\xbf\xbf" "\x43\x4b\x46\x2d\x98\x58\xe2\xc9\x07\x2e\xdc\x54\x3f\xe9\x94\xdf\x64" "\x66\x2a\xc3\x13\xea\x70\xb1\x4b\xc3\xfc\xbb\x4e\xc2\x61\xdc\x4c\x81" "\xa3\xc2\x0c\x79\x59\x76\xbf\x3b\xba\x33\x67\xa9\xe6\x02\xf8\x53\xfd" "\xdb\x7c\xa2\x04\x95\x1b\x10\x11\x5d\x04\xc2\x47\xfc\x93\x91\xbf\x98" "\xa3\x50\x87\x10\x4d\x2b\x61\xab\xf5\x1f\xb0\xee\x44\x7a\x98\xaa\x3c" "\x13\x30\x0b\x56\xa0\x8e\x99\x98\x30\x03\xce\x58\xac\x1d\x7c\x0d\xd9" "\x6c\x44\xb5\x81\xf2\x45\x1d\xf7\x91\x03\x8a\x71\xb5\x27\x47\x19\xca" "\x60\x71\x32\x1f\xd2\x18\xe5\x66\x56\xcf\x45\xe4\xf4\x1f\x83\x54\x94" "\x95\x0a\xd9\x4f\x64\xc5\x19\xb6\x96\xeb\xe8\x2f\xe8\x9b\x64\x59\x04" "\xab\xb4\xa0\xee\x1e\xa5\x8d\x1d\x7a\xb9\x3b\x49\xe3\x20\xca\x5d\x2d" "\x7d\x01\xbe\xd7\x8c\xb7\x61\xb5\x5f\xf7\xa5\x5b\xc0\x31\x3a\xe9\xac" "\x17\xb8\x02\x36\x1e\x33\x9f\xd2\xf7\xbb\x40\xd4\xa4\x5a\x94\x90\x74" "\x02\x66\x04\xd8\xd2\xc1\x72\xbd\x8e\xbb\xcc\xcb\xee\x23\x0d\xc7\x06" "\xa6\xfc\x7b\x85\x65\x76\x10\x79\xf3\x2b\x5c\x67\xb5\x17\x06\xba\x4d" "\x42\x6f\xd8\x42\x8a\x4d\xf0\x39\x2d\xf6\xf9\x47\x25\x03\x20\x02\xec" "\xe4\x66\xca\x93\x55\xc5\xb8\x44\xf1\x9c\xa3\x1b\x70\x53\x5d\x8b\x3c" "\x60\x8e\x5b\x1f\x2d\xd2\x42\x80\x14\xf8\x9f\x30\x20\x5e\xa1\x1f\x5b" "\x4f\xa9\x4c\x0c\x42\x95\xf8\xe9\xab\x09\x06\x28\x00\xc7\xa6\xb7\x6c" "\x91\x05\x8e\xd7\x85\xd5\x63\xde\x50\x51\x83\x73\xb1\x5e\x16\x16\xba" "\xa4\x30\x4a\x50\x78\x22\x40\x87\x88\xae\xbe\x2e\x15\x40\x18\x39\x4b" "\x4d\x58\xfb\x7b\xfe\x71\x01\xb8\x51\x3c\xf6\x8a\xca\xd6\x30\x71\x06" "\x45\xd5\xee\x0c\x1a\xf6\x0b\xd9\xdd\x49\xa7\x77\x42\x0e\x01\x67\xd0" "\x22\x76\x02\xc4\xdc\xce\xc2\xc5\xd8\xbe\x0f\xe5\xa7\x48\xc1\x6c\xc2" "\x94\xfd\xab\xb1\x72\x7f\xb1\x6e\x9b\x06\xed\x59\xf7\x21\x9b\x73\x76" "\x7f\x6a\xd6\x38\x5d\x46\x1b\xe8\x68\x82\x6c\xd4\xd7\x49\xf8\x4c\xbd" "\xd2\xe5\xd6\x30\x51\xe6\x06\x9f\x17\x08\xf6\xc2\x37\xcd\x5a\x01\x2d" "\x1e\x6f\xec\x70\xd6\xf4\xb6\x1c\xdf\xa9\x13\x36\x72\x70\x4b\x9f\xa9" "\xa5\xd3\x0a\xc1\x55\x24\xa3\x01\x6d\xc8\x65\xaa\x52\x96\x2c\x99\x5f" "\xa5\x0d\x95\x1b\x44\xcd\x49\xbb\x29\x43\x6b\x0c\x61\x6e\xf7\x10\x97" "\xe5\xc5\xc9\x0c\x5c\xf0\x94\xb2\x02\xcf\xc2\x1b\x6d\x00\x2f\x85\xd6" "\x86\xc2\xc8\x01\xfb\xc8\x07\x88\x74\x70\xa2\x74\x0f\xef\x1b\x2b\x8a" "\xca\x2c\x96\xce\x76\x50\xed\x98\x29\x52\x98\x02\x77\xaa\xcd\xca\xcb" "\x2f\x44\x7b\xfc\xe8\x1d\x27\xe2\xeb\x32\xee\xb1\x26\x20\x99\x16\xda" "\x91\xe3\x59\x68\x6e\x58\xc3\x0a\x05\xbd\xbf\x19\xa4\x17\x87\x1b\x15" "\x73\xc0\xd0\x94\xfd\x55\x1e\x15\xe9\x1d\x21\x00\xad\xaa\x78\xa6\x44" "\xac\x74\x82\x7c\x9d\x4d\x0a\x98\x2e\xef\x6e\x7d\x72\x60\x86\x45\xd1" "\xa3\x2f\x21\x02\xaa\xda\xc5\x41\xa2\xe6\x1b\x5b\xf0\xf5\x9a\x43\x5b" "\x77\xf6\x21\xb1\x08\xd5\x45\xce\x3b\xba\x95\x28\x1b\x04\x1a\x7b\xc1" "\x46\xe1\xb2\xbc\xf7\x43\x78\xa8\xc7\xd1\x11\x0c\xc1\x23\xeb\xc6\x01" "\xde\xa4\x0f\x08\xb6\x35\xc6\xad\x01\x2c\xc5\x86\xfc\x47\xa9\xab\xc1" "\xa1\xe1\x15\xcc\x57\x0e\x35\x5f\x62\x00\x2d\xa9\xe8\x07\x55\x4e\xed" "\x4c\x6c\x7d\x07\x33\x1f\x3e\xb3\xbc\x94\x15\xcf\x2e\x7b\x83\xdc\xf4" "\x73\x3b\x66\x7d\x73\x61\x66\x6b\x44\x26\xc2\xdd\x97\xe3\xa2\x6b\x72" "\xc1\x8b\x3a\x60\x91\x9b\x09\x98\x21\xf0\x1c\xfa\x3f\x5d\x6f\x7c\xfd" "\x25\xbf\xc3\x2b\x06\x2c\xfd\x31\x56\x8d\x9c\x70\xb7\x16\x0e\xe5\x2e" "\x3d\x73\xe2\x43\xc6\x97\x39\x77\xd2\xcd\x2d\xf0\x99\x6f\xbf\x07\x11" "\x8d\xe7\x78\x28\xf8\xa1\x24\xc7\xba\xae\x5a\x4f\x8b\xc8\xf2\x51\x49" "\xbe\x69\xff\x8d\x89\xb7\x24\x92\xf3\xbe\xe3\x0d\x05\xdd\xae\xa6\x9c" "\x8d\xa2\x02\x09\xb8\xb4\xe8\x15\x05\xf8\xf9\xf4\x57\x23\x9c\x1e\x7b" "\x51\xa2\x5d\x4c\x93\xca\xbf\x79\x21\x0c\x78\x0c\x5b\x14\xef\xca\xa6" "\x62\x64\xfa\xfd\x8a\xf7\x9c\x44\x18\x0a\x1f\x0d\xe5\x13\x75\x0c\xfc" "\x0a\x64\xb9\x73\x18\x40\x69\x7a\xec\x8c\x7b\xaa\xde\x01\xbb\xa6\x73" "\xa3\xe6\xb0\x36\xfb\x49\x0b\xe6\xa0\x43\x06\x76\xab\x99\x41\xa7\x85" "\xf1\x6f\xe0\xcc\xba\x0f\xfe\x46\x96\xe2\x71\x01\xba\x20\x92\xf2\x00" "\x96\xaa\xc0\x02\x0d\x7b\xb6\x29\x07\xde\xe7\xcc\xb1\xf1\x6d\x3c\x3f" "\x24\x1e\x2b\x97\xb7\x74\x64\xdc\xed\x1a\x65\x11\xd3\x55\x42\x25\xa9" "\x32\xa3\x99\x67\x08\x4e\x98\x00\x36\x93\x72\x33\xee\xbd\xf5\x61\x69" "\xe3\x58\x46\x5b\x50\xdb\x96\x81\xc1\xbe\xfb\xe5\xf1\xa5\x7e\x48\xb9" "\xc2\x35\x00\x3f\x3c\x83\x46\x0d\xb4\x06\x93\x85\x71\x94\x8e\x54\xde" "\xf1\x73\xf9\xd5\x66\x7e\xf4\x00\xb9\xbc\x64\x92\x79\xaa\x33\xa8\xda" "\x44\x40\xa8\x2c\xae\x73\x00\xd4\x7a\x4f\xda\x5a\x42\x9c\xed\x3e\x36" "\x15\x44\x12\xfa\x4b\xbc\x5a\x71\x45\x2d\xcf\x5a\x0e\x08\x5b\x2f\xdd" "\x06\x43\x04\x58\xd1\x0b\xd7\x97\x38\x06\x4e\x03\xf4\x5f\xd2\xb3\xa7" "\x6e\x62\x6b\x6c\x55\xef\x61\x77\x28\x20\x57\x42\xb2\x12\x73\xc9\xea" "\x6a\xd6\x5d\x2b\x4d\x23\xc1\x4a\x83\xfd\x08\x91\xda\x1c\xec\xa9\x7b" "\x6c\xe5\x54\x60\x1c\x56\xe6\x2d\x79\x51\x91\x4e\x93\x1e\xdc\xf1\xc6" "\x6f\x6a\xed\x6f\x6e\x2d\x6b\xac\x34\x33\x35\xaa\xd7\x12\xaa\x43\x83" "\x4d\xf8\xfd\xe2\xc6\xb0\x43\xe0\x24\xb9\x56\x46\xd9\x23\x7c\xb8\x8e" "\x90\xca\xc8\x9b\x69\xe9\xfa\x32\x07\x39\x5a\xe1\x08\x8f\xf3\xaa\x15" "\xde\xb4\x7a\xe6\x8a\x79\x28\xa2\x5d\x1d\xfe\x86\x75\x7b\xf1\x26\xf0" "\x55\xb5\xbf\xaa\x20\x2e\x7b\x64\xd3\x80\x85\x2c\x78\x25\x74\xea\xd9" "\x8c\x2e\xb7\x5a\x87\x25\xf2\xd6\x3d\x74\x5f\x36\xb5\x03\x77\x45\xcf" "\x84\xf8\xe4\x3b\x4d\x23\xa9\x88\xf5\xd0\xd6\xce\xab\xe5\xdf\xa7\x6a" "\x3f\x29\x26\x81\x15\xe5\x04\xb1\x85\xdc\x39\xbc\x2b\xd3\x57\x3b\x3f" "\xfc\x3a\xde\xc7\x10\x4d\x90\x08\x30\xa0\xcc\x94\x63\x15\xa3\x97\x0a" "\x14\xb8\x20\xfb\x01\x2c\x05\xf1\x48\x63\x68\x25\x34\x5a\xc0\xff\xff" "\xe8\x79\xa0\x0b\x2d\xdb\x1d\xe8\xdc\xcf\x9e\xc7\xa6\xaf\x1a\xf4\x72" "\x55\x54\xf7\xcf\x8e\x60\x8b\x89\xec\xc8\x0a\xc3\xcd\x49\x6f\xd9\xa2" "\x3f\x6d\xaf\x48\x7f\x93\xe9\x6e\x7a\xdb\x72\xc0\xc5\x80\x99\x32\x44" "\x42\x77\xfa\x8d\x5d\x72\xe9\xa1\xd4\x98\x9d\x55\x68\x72\xd6\x9e\xd0" "\x17\x67\x07\xb4\xb9\xea\x93\x78\x60\x92\xe2\x37\xcf\x4d\xff\x2f\x6f" "\x13\xa6\x5d\x27\x2e\x49\x46\x7f\x9c\x39\x58\xa3\xdb\x7a\x97\x04\xe9" "\x67\x93\x32\xa7\x1e\xc8\x7c\xf7\x74\x26\x84\x7f\x68\x41\x11\x37\xcd" "\x3a\x72\x8a\xf1\xa1\xa9\xbd\x49\xbe\xd3\x60\xf3\xd3\x7b\x25\x86\x70" "\x43\x79\xe0\xce\x94\x63\xde\x52\x55\xa4\x58\xd6\x32\xaa\xec\x40\x3e" "\xdf\x9e\x2e\x9c\xf2\x02\x86\x84\xb6\x4d\xe8\xa4\xe9\xda\x76\xee\xb1" "\xe7\xf2\xf9\xd7\xb4\x40\x3c\x60\x78\x49\x8c\x81\x37\xdd\xde\xe8\x02" "\x1a\xf6\xa9\xa3\xe7\x02\xd0\xd0\xd8\xf8\x1a\xd2\xda\x9b\xb3\xad\x40" "\x18\x90\xdf\x84\x7f\x53\x9a\x54\x22\x37\x77\x5c\xbf\x1b\xc6\xab\x61" "\x79\x3d\x6f\xbc\x64\x87\xe7\xbe\xd2\x17\xce\x39\x53\xd6\x94\x5a\x49" "\xbb\xb3\x64\xe6\xa6\xf8\x19\x41\xf9\x9e\xdc\x0b\xb9\x82\x41\x3b\x4f" "\x7e\x78\x95\x0e\x15\x67\x3d\xd8\x46\x8b\x88\x12\x58\xd7\xf3\x27\x07" "\x4e\x81\x7a\xd6\x9e\x9f\x0f\x0b\xa6\xd2\x31\x08\xab\xfe\xf5\x75\x44" "\x4d\xec\xd5\xb8\x8d\x89\x46\x7d\x2e\x6b\x11\xc3\x86\x03\x49\xae\x15" "\x26\x85\x7a\x64\x4e\x12\x18\x5a\x03\x09\x2f\x50\xb2\x38\x7a\x6e\x99" "\xc3\x36\x78\xb4\x4a\xc1\x05\x63\x4c\x08\x40\x77\x99\xa9\x1a\x03\x4c" "\x43\x18\x3c\x82\x04\x93\x44\xd6\x15\x4e\xd1\x19\x4c\x13\x60\xf9\x7b" "\x2b\x6e\x17\xa3\x54\xfd\xa3\x54\x88\xf8\x69\x36\xaa\x1f\x7e\xef\xd5" "\xf5\x3e\x2a\x6a\xad\x6d\xcb\x71\x56\x46\xda\x2b\xed\xca\xad\x7e\x8d" "\xbd\x9b\xe9\xb3\x11\xf8\xec\x70\x5b\x31\x9d\x4b\x5d\xa9\xd9\x50\xd3" "\x94\x04\xc3\x64\xcb\x9c\xf4\xb8\x6e\x42\x4d\xd3\x42\x18\xfe\x4d\x5c" "\x94\xc6\xcb\xa8\xed\x84\x50\x19\xa3\x93\x3e\xae\x13\x54\xc7\xe5\x5d" "\xde\x53\x9e\x2d\x0b\xe9\xeb\x14\x72\x22\x8d\x0f\xce\x2f\xdb\xc1\xae" "\xb2\x5d\xd6\xce\x5d\x3e\x49\xa9\xf3\x54\xb1\xa9\x63\xa5\x63\x4e\x17" "\x2a\x13\xc3\xe7\xbd\xd9\x34\xa2\xe3\x15\xe2\x8d\x3a\x74\x95\xac\x35" "\xdb\xa2\xdf\xcd\xda\x62\x0e\x5d\x39\xc3\x3e\xbe\x8f\x08\x95\x3e\x7b" "\x78\x36\x18\x38\x66\x2b\x25\x92\x66\x6e\x88\xb5\x98\xe7\x39\x9c\xc3" "\x75\x70\x4f\xd2\x83\x75\x9d\xf3\xdc\xbd\xd0\x57\x97\x50\xbb\x2e\x75" "\x2b\xf7\x0a\x6f\xa7\x75\x6d\xba\xf1\x85\x79\x9b\x47\xd5\x25\x76\x8b" "\x2a\x52\x9d\x5a\x95\xc7\x45\x72\x50\x86\xa6\x51\xbf\xc1\xe2\x11\xbf" "\x63\xb6\x8e\xab\x04\x1b\xa7\x7c\x70\xa6\xa1\x3a\x64\x6b\x59\x75\x6f" "\xc5\xc8\x27\xc0\x17\xb2\xe7\x39\xbd\x0c\x07\x40\x60\x13\x49\x25\x30" "\x28\x60\x00\x18\x52\xa2\x5a\xeb\x85\x2f\x42\x43\x6f\xa0\x0a\x30\x87" "\xdc\xb7\xf7\x04\x6c\x5f\xc0\x71\x9e\xf7\xd1\x0c\x75\x17\xcf\xc7\x6e" "\x69\xdf\xac\xa5\x45\x20\x2d\x90\xf1\xef\x78\x1e\x6d\x65\xc4\x3a\xdb" "\xff\xa7\x3d\xbe\x4c\xae\x4e\x54\xe2\x32\xcf\x6d\x62\xc4\xb1\x8e\x09" "\xbe\x28\x7d\x24\xf6\xae\xd3\xc4\x06\x6e\x71\xbc\xe7\xe9\x76\x25\x7b" "\xa5\xda\x46\x68\xe1\x46\x28\x2c\x94\x3b\x97\x28\x15\xa7\x86\x6f\x04" "\x25\x5b\x4b\x12\x54\x8f\x68\x53\x55\x84\x59\x5a\x4a\x40\xba\xcc\x63" "\x58\x70\xa6\x94\xa1\xbd\x31\x1c\x25\x18\xdb\x21\xed\xdc\x85\x32\xe2" "\x7a\x08\x65\x18\x8b\x15\xb0\x67\x4d\xd0\x55\x20\x6d\xd8\xa2\x31\x9e" "\x38\x61\x26\x96\x1a\xc2\x07\xf8\x37\xb0\xb2\xef\xa6\x82\x01\x6d\xf2" "\xbc\xb4\x96\x90\x81\xf3\xac\x5c\x70\x45\x57\x8b\xcf\x8e\x91\xdc\x83" "\xc5\x45\x41\x27\xcb\x9d\x48\x78\x8e\x8f\x6b\x11\x70\x27\x30\x40\xae" "\xc9\xc5\x4c\x2c\xa7\x1e\xd2\x2d\xd5\xb7\x31\xda\x15\x85\x44\xe2\xda" "\x13\x11\x10\x70\x72\x63\x01\x98\x48\xe4\xe1\xef\x0c\x73\x25\xc8\xb7" "\xb8\x7d\xf7\x88\x4a\xe1\x26\x60\xfe\xb2\xe2\xf1\xb9\xdd\x00\x67\x8b" "\xd7\x03\xa1\x6e\x4b\x9f\xc4\x3f\x11\xb1\x34\x0f\x8e\xe2\x8d\x1f\xc4" "\xcf\x37\x6c\xa7\xeb\x83\xab\x06\xea\x7a\xa4\x87\x91\x5b\x76\xc3\xbd" "\x11\x22\x35\x26\x6f\x7d\x22\x47\x74\xe8\xa6\xe7\x32\xfb\x92\x33\x16" "\x81\x82\x39\xb0\xaf\x75\x70\xe0\xc9\x6b\x5e\x12\xe2\xa4\xdd\x79\x85" "\x9d\x04\x0a\x89\xc7\x8c\x26\xe7\xfd\xfd\x35\x1c\xb1\x7a\x01\x33\x92" "\x9c\x02\xff\x92\x72\xc7\xc7\x20\xd7\x66\x68\xec\xe8\x55\x00\x1a\x7a" "\x79\x48\x2f\xce\x61\x4a\x7c\xd2\x4b\x12\x2a\x6d\x1e\x53\xd2\xf0\x1d" "\x71\xf0\xcc\xa2\x58\x2e\xbb\x56\x1e\x03\x02\xe7\x17\xe6\x2a\x6d\xdd" "\x5b\x44\xe0\x02\xc5\x3e\x08\x8e\xc6\xfe\x69\xae\xb6\xf2\xa0\xe9\xfd" "\x7f\x6f\xc1\xd4\x5a\xd8\xe9\xf2\x80\x4b\x1e\xb1\xb4\x33\xa4\x4a\x1f" "\x23\x88\x7b\xca\x29\x59\x71\x1a\x4c\xfe\x95\x0f\xce\xfa\x20\x2f\x78" "\xdc\xa7\xc8\x08\xb2\x0e\x03\x7b\x8b\x4b\x07\x05\x3e\x2d\x64\x5f\x39" "\xc1\x0e\xef\x35\x7c\x7c\x47\xac\x1d\xf2\xde\x82\x3b\x83\xea\x17\xfd" "\x87\xfe\x68\x30\x42\x8a\xac\x0c\xa1\x6b\x63\x67\xb5\xb7\x65\x12\xbd" "\x3d\x21\x6e\x4a\x33\xb1\x22\x90\xa1\xdd\x22\x5c\x67\x42\x8b\x5d\x2f" "\xe3\xdd\x0f\x5e\xf6\xd3\x96\xbf\x48\x37\x4e\xa5\x66\x2a\x2c\xd2\xeb" "\x01\x74\xf6\x7e\x2b\x1b\xf7\x5b\x90\xcd\xe0\xa9\x3a\x86\xec\xfd\xc7" "\x39\x3d\xf1\x5d\x2d\x64\x1f\xf3\xdb\x0f\xf1\x30\xb1\xe3\xf9\xd1\x58" "\x84\x56\x94\x85\xac\x16\xce\xe2\x08\x56\xf9\x66\x4a\xe8\x89\x3e\x38" "\x31\x28\xfe\xaa\x56\x51\xaf\xd5\x4b\x22\xe1\xce\xd7\xab\xcc\x9d\x90" "\x37\x84\x3e\xc7\x95\xcf\xcd\x86\xfb\x47\x23\x65\x44\x12\x7b\x1a\x85" "\x35\xf7\xee\x84\xc1\xb5\x0b\x37\xc1\xe1\x96\xf0\xc8\xa0\x4c\x05\x86" "\xd9\x3a\xb9\xcd\xc6\x33\x56\xf1\xea\x1a\xda\x99\xd7\xfd\x00\x78\x36" "\x3d\x9f\x81\xbe\x92\xd1\x4d\x29\xbb\xe3\x3e\xde\xe7\xbf\x23\xe9\xba" "\x8c\xaa\x98\xc3\x35\x95\xac\x6b\x53\x78\x8c\x72\x6d\xde\x6f\xc4\xe0" "\xab\x53\x33\xc7\x42\xcc\x95\xd0\xdc\xf7\x71\x99\x57\x8f\x79\x0d\x2b" "\x65\x4b\xb5\x0f\x05\xc1\x81\x86\xc2\xd2\x6d\x9a\x34\x2a\x45\x32\x84" "\x08\x45\xfa\x1e\x8d\x0c\x69\x4d\xbc\x45\x17\x6a\x5d\xae\xd3\xf9\x00" "\xf7\xf2\x2b\x14\x4d\x57\x9e\x34\x88\xa3\x24\xc1\xfc\x43\xe9\x03\xa2" "\x13\x37\x65\xb5\x01\x97\xaa\x19\xe5\x43\x9d\x02\x9f\x17\xdd\xfb\x2c" "\x80\x44\x19\xa5\xfa\xe6\xa1\xc9\x12\xa2\x4b\x15\x18\x1c\xd8\x1b\xdf" "\x23\x90\x39\x80\xa4\x4d\x5e\x66\x4d\xd9\x14\xd1\x6b\xab\x6b\x53\x9d" "\x88\x49\xed\x85\x0d\x97\x2d\x68\x83\xc0\x0d\x8e\x73\x00\xd3\x18\xa5" "\xe5\x0b\x6a\xc7\x15\x5e\x3f\x34\x78\x20\xf2\xcc\x43\xc3\xf4\x6a\x44" "\xbc\x86\xef\xdc\x6a\x8e\x06\xda\x56\x2d\x1f\xb1\x1e\xc7\xdf\x11\x88" "\x1a\x58\x89\xfc\x5c\x39\x42\x69\xb2\x4c\x8a\x6d\xa5\xdb\x4c\x3a\xe9" "\x30\xfc\xc3\x50\x79\xc9\xde\x5b\x68\x88\x67\xe7\x35\x7b\x7f\x23\x05" "\x09\xe0\xfe\xd9\xff\x66\x3c\x9c\x92\x37\xa5\x54\x01\xeb\xd5\x72\x75" "\x04\xfc\x81\x2e\xb5\x6d\x1a\x88\xed\x7d\x4e\xf0\x1b\x59\x36\xb0\x27" "\xab\xae\x7f\x4a\x29\xf0\xe3\x2f\xce\x98\x5c\xc3\x7c\xec\xc9\xac\xb0" "\x47\xb2\x91\x96\xc1\x6b\xb1\x5e\xe5\x54\xab\x1f\x0f\x70\xdd\x02\x37" "\xa7\x73\x73\x0a\x2e\xab\xb9\x7e\x25\xdd\x11\xec\x12\xa0\xbe\x48\x6e" "\x76\xe1\x1e\x00\x22\x30\x2e\x9f\xda\x94\xc3\x8a\x0b\x25\xf6\xe7\x8b" "\xb2\xc4\x9b\x18\x21\x8f\xf3\x81\x34\xe7\xb3\xf5\xc6\xa2\x8f\xd6\xbe" "\x3f\xff\x81\xf2\x13\xb7\x06\x54\x26\x28\x8c\x22\x41\x6b\x05\xbd\x5d" "\x7b\xfc\x2a\xe6\x00\x1f\x49\x5e\x4c\x8a\x8d\xbc\x26\x27\x93\xa7\x25" "\x85\xf1\x5f\x66\xa4\x90\xf5\x70\xc3\x33\xd2\xc4\xf1\xbf\xe4\xe1\xce" "\xee\x26\x0c\xc5\xcb\xab\x53\x9c\x93\xb2\x39\x4e\x93\x79\x9b\xa0\xcf" "\x1a\xd0\xf5\x0a\x78\xec\x19\x68\xec\x6d\xd7\x0b\x16\x71\x68\x04\x5a" "\x2f\x91\x18\x0b\x32\x79\xc5\xf4\xeb\xde\x32\xaf\x0a\x64\x31\x3e\x9d" "\xf5\xdf\x16\x90\xba\x8d\xea\x6e\x1d\xe1\x8b\x4f\x95\xfb\xd7\x3d\x08" "\x5c\xb0\x17\xd1\x34\xab\xde\xa9\x93\xdf\x1e\x75\x6e\x1a\xd2\xca\x66" "\x05\x28\x58\x53\x1e\x59\x73\x19\xe2\x54\x85\x2e\x20\x73\x6d\xdc\x50" "\x69\x28\xd3\xda\xe8\xf1\x96\xee\x80\x8c\x08\xfe\xd9\x58\x7f\x5b\x1f" "\x8c\xd3\xde\x89\x85\xaf\xd3\x64\x70\x76\xbb\x87\x22\x43\x58\xe1\x07" "\x79\x5b\x83\xcb\x6c\x0b\xbe\xbb\xda\x9b\x36\xec\xfb\x00\x2a\x91\x42" "\x7f\x14\x39\x8d\xdd\xe4\xd1\xf6\x70\x61\x6f\x31\x54\x07\x5e\x62\xc3" "\xec\xb2\xaa\x35\xec\xc5\x9b\x82\x1e\x71\xe2\x98\xc5\x4d\x5a\x8b\x0f" "\xa1\xcc\xd3\x09\x1b\xfc\xc9\x06\x9c\xda\x0c\xf9\xc8\xaa\xa6\xb4\x79" "\x5d\xff\xee\x56\xfb\x5f\x6e\xda\x40\x57\xd0\x6e\x81\x70\x3b\x53\x0c" "\x53\xec\x6b\xd4\x6a\xa0\x2a\x73\x33\x96\xed\x6d\xce\x94\x9f\xcc\x00" "\x2a\x10\xcc\x07\xdd\x72\xb9\xa1\xee\xc6\x97\xb9\x21\x72\xdd\xa2\xad" "\xe6\x07\x77\x21\x38\x12\x2b\x2a\x9a\x09\x66\x56\xcd\x36\xba\x03\x6f" "\xda\x57\x74\xc8\x0b\xe2\x16\xb1\x4b\x67\xab\x3a\x45\x85\xa5\xaf", 4096); *(uint16_t*)0x200000003484 = 0x1000; syscall(__NR_write, /*fd=*/r[0], /*data=*/0x200000002480ul, /*len=*/0x1006ul); break; case 3: // openat arguments: [ // fd: fd_dir (resource) // file: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 31 00} (length 0x8) // } // flags: open_flags = 0x42 (4 bytes) // mode: open_mode = 0x0 (2 bytes) // ] // returns fd memcpy((void*)0x2000000002c0, "./file1\000", 8); res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x2000000002c0ul, /*flags=O_CREAT|O_RDWR*/ 0x42, /*mode=*/0); if (res != -1) r[1] = res; break; case 4: // pwritev2 arguments: [ // fd: fd (resource) // vec: ptr[in, array[iovec[in, array[int8]]]] { // array[iovec[in, array[int8]]] { // iovec[in, array[int8]] { // addr: ptr[in, buffer] { // buffer: {df} (length 0x1) // } // len: len = 0xf4240 (8 bytes) // } // } // } // vlen: len = 0x1 (8 bytes) // off_low: int32 = 0x800001 (4 bytes) // off_high: int32 = 0x0 (4 bytes) // flags: rwf_flags = 0x0 (8 bytes) // ] *(uint64_t*)0x2000000000c0 = 0x200000000200; memset((void*)0x200000000200, 223, 1); *(uint64_t*)0x2000000000c8 = 0xf4240; syscall(__NR_pwritev2, /*fd=*/r[1], /*vec=*/0x2000000000c0ul, /*vlen=*/1ul, /*off_low=*/0x800001, /*off_high=*/0, /*flags=*/0ul); break; } } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); setup_cgroups(); const char* reason; (void)reason; if ((reason = setup_binfmt_misc())) printf("the reproducer may not work as expected: binfmt_misc setup failed: " "%s\n", reason); if ((reason = setup_usb())) printf("the reproducer may not work as expected: USB injection setup " "failed: %s\n", reason); for (procid = 0; procid < 6; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; }