// https://syzkaller.appspot.com/bug?id=2d36e7f205f5655cb59ce49754c466cd6c0a2b22 // 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 #ifndef __NR_bpf #define __NR_bpf 321 #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 struct nlmsg nlmsg; #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); } static int runcmdline(char* cmdline) { int ret = system(cmdline); if (ret) { } return ret; } #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); } #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); } 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); 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_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_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); write_file("/proc/self/oom_score_adj", "1000"); if (symlink("/dev/binderfs", "./binderfs")) { } } static void close_fds() { for (int fd = 3; fd < MAX_FDS; fd++) close(fd); } static const char* setup_usb() { if (chmod("/dev/raw-gadget", 0666)) return "failed to chmod /dev/raw-gadget"; return NULL; } #define NL802154_CMD_SET_SHORT_ADDR 11 #define NL802154_ATTR_IFINDEX 3 #define NL802154_ATTR_SHORT_ADDR 10 static const char* setup_802154() { const char* error = NULL; int sock_generic = -1; int sock_route = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock_route == -1) { error = "socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE) failed"; goto fail; } sock_generic = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC); if (sock_generic == -1) { error = "socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC) failed"; goto fail; } { int nl802154_family_id = netlink_query_family_id(&nlmsg, sock_generic, "nl802154", true); if (nl802154_family_id < 0) { error = "netlink_query_family_id failed"; goto fail; } for (int i = 0; i < 2; i++) { char devname[] = "wpan0"; devname[strlen(devname) - 1] += i; uint64_t hwaddr = 0xaaaaaaaaaaaa0002 + (i << 8); uint16_t shortaddr = 0xaaa0 + i; int ifindex = if_nametoindex(devname); struct genlmsghdr genlhdr; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = NL802154_CMD_SET_SHORT_ADDR; netlink_init(&nlmsg, nl802154_family_id, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(&nlmsg, NL802154_ATTR_IFINDEX, &ifindex, sizeof(ifindex)); netlink_attr(&nlmsg, NL802154_ATTR_SHORT_ADDR, &shortaddr, sizeof(shortaddr)); if (netlink_send(&nlmsg, sock_generic) < 0) { error = "NL802154_CMD_SET_SHORT_ADDR failed"; goto fail; } netlink_device_change(&nlmsg, sock_route, devname, true, 0, &hwaddr, sizeof(hwaddr), 0); if (i == 0) { netlink_add_device_impl(&nlmsg, "lowpan", "lowpan0", false); netlink_done(&nlmsg); netlink_attr(&nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); if (netlink_send(&nlmsg, sock_route) < 0) { error = "netlink: adding device lowpan0 type lowpan link wpan0"; goto fail; } } } } fail: close(sock_route); close(sock_generic); return error; } #define USLEEP_FORKED_CHILD (3 * 50 * 1000) static long handle_clone_ret(long ret) { if (ret != 0) { return ret; } usleep(USLEEP_FORKED_CHILD); syscall(__NR_exit, 0); while (1) { } } static long syz_clone(volatile long flags, volatile long stack, volatile long stack_len, volatile long ptid, volatile long ctid, volatile long tls) { long sp = (stack + stack_len) & ~15; long ret = (long)syscall(__NR_clone, flags & ~CLONE_VM, sp, ptid, ctid, tls); return handle_clone_ret(ret); } #define SWAP_FILE "./swap-file" #define SWAP_FILE_SIZE (128 * 1000 * 1000) static const char* setup_swap() { swapoff(SWAP_FILE); unlink(SWAP_FILE); int fd = open(SWAP_FILE, O_CREAT | O_WRONLY | O_CLOEXEC, 0600); if (fd == -1) return "swap file open failed"; fallocate(fd, FALLOC_FL_ZERO_RANGE, 0, SWAP_FILE_SIZE); close(fd); char cmdline[64]; sprintf(cmdline, "mkswap %s", SWAP_FILE); if (runcmdline(cmdline)) return "mkswap failed"; if (swapon(SWAP_FILE, SWAP_FLAG_PREFER) == 1) return "swapon failed"; 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 < 12; 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); 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) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); 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[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: syscall(__NR_prctl, /*option=*/0x3eul, /*cmd=*/1ul, /*pid=*/0, /*type=PIDTYPE_PGID*/ 2ul, /*uaddr=*/0ul); break; case 1: *(uint32_t*)0x200000000100 = 1; *(uint32_t*)0x200000000104 = 3; *(uint64_t*)0x200000000108 = 0x200000003380; memcpy( (void*)0x200000003380, "\x18\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\xa0\x12\x54\x4f\x95" "\x00\x2b\x00\x00\x00\x00\x00\x93\xad\xff\xa8\x22\x55\xf6\x74\x41\x2d" "\x02\x00\x00\x00\x00\x00\x00\x5a\xb5\x27\xee\x36\x97\xf1\xed\x44\x36" "\xdd\x11\x64\xb1\xb3\xf4\x27\xf6\xba\x6b\x34\xf9\x81\x25\xf3\x0e\x63" "\x1d\x27\x36\x83\x62\x6e\x00\xdc\x25\x4d\x57\x0d\x4a\x6b\x78\xa5\x83" "\x34\x88\xcf\xe4\x10\x09\x00\x00\x00\x4a\xa9\x00\x00\x3d\x3c\xd6\x2f" "\x00\x15\x8e\x6e\xee\x85\x01\x00\x00\x00\x52\x0a\x00\x00\x15\x1d\x01" "\x00\x00\x00\x01\x00\xbf\x00\x00\x00\x00\x3b\xbd\x42\x4c\x6e\x6c\xaf" "\xbe\x93\x09\xab\xa2\x18\x81\x28\x68\xa5\x1d\x12\x9e\x78\xf6\xae\x17" "\x0b\xf5\xa5\x20\x01\xa3\xcd\x00\x00\x41\xf0\xdb\x74\x59\x6f\xd7\x2c" "\x00\x2a\x60\xc1\xbc\x7d\xc8\xc3\x8b\x00\x00\x24\xb9\xdd\x11\x45\xd0" "\x3f\xf4\x5f\x70\x68\x5c\x6b\xd9\xff\x41\xc6\x9b\x7d\xe4\x75\x8c\x10" "\x96\xa1\xdc\x52\xf2\x9e\x46\x0a\x00\x05\x17\xeb\xc4\x06\xe8\x9d\xcb" "\xb7\x67\x7e\x65\x28\xb0\x85\x6e\x31\xeb\x94\x74\xc0\x10\x6f\xc4\x8e" "\x1f\x8c\x1a\x5f\x69\x45\xac\x24\xcf\x60\x90\x68\xf6\xff\x21\xe8\x8b" "\x3c\xfc\x22\xdf\x01\xe4\xba\xc9\xd9\x73\x28\xfa\x2a\x82\xb5\xe8\x74" "\x1e\x02\x05\x6d\x93\x3b\xed\xf5\x9f\xf2\x32\xce\xbc\x68\xb9\x1a\xf5" "\x04\x79\x38\x74\x67\x82\x42\x62\x85\x2c\x79\x39\xdb\x56\x72\xd0\x7c" "\xdb\xe8\xe1\x48\xbf\x56\x49\x7e\x5d\x56\xd0\x6c\x75\x51\xb8\x70\xb2" "\x85\x1c\x3f\x0a\x1a\xab\x71\x58\x7a\x21\xc8\xf1\xb3\x36\x9e\xbf\xcb" "\x4c\xb2\x94\x66\x01\xb0\xf0\x4e\xdb\x25\x6c\x60\x4f\x06\x87\x73\xf6" "\xdb\x9d\x66\x1b\xd7\xf0\xe2\x53\x6f\x00\x00\x00\x00\x00\x00\x00\x00" "\x55\x21\x1c\x6f\x86\x4f\x98\x3d\x74\x5f\x58\x65\xaa\xd4\x1d\x29\x15" "\x8a\xe7\x60\x2a\x2d\x6c\xd4\x15\xe8\x35\x1e\xbc\x28\x3d\xf5\x4d\x6b" "\xec\x66\x47\x09\xff\x03\xf1\xaa\x3d\xc7\xf1\x58\x0a\xce\x9b\xf2\xaf" "\xd2\x8d\x71\x57\xe6\x7f\xb9\x8d\x12\x1a\x96\xeb\x37\x27\x13\x25\x50" "\x12\xe0\x28\xcb\x26\x54\xd4\x93\xa0\xb4\xb3\x5f\xaa\xe1\x76\xf9\x9b" "\x74\x5e\xda\x29\x67\x19\x9c\xc9\x36\x85\xbb\x53\x7e\x8e\x48\x71\xd4" "\xac\xf3\xe3\xdc\x10\xe1\x3e\xf2\x27\xf6\x27\xa4\x00\x00\xad\x1f\xa2" "\x53\xd3\x3f\xa7\x4f\x17\x2d\x00\x07\xae\x4e\x1e\x34\x7c\x0c\xff\x28" "\x23\x5a\x6b\xb7\xaa\x38\x04\xb9\x07\xa8\xf2\x88\x0c\x5c\xb1\xcb\x38" "\x5e\x6a\xdd\x14\x65\x20\x03\xc7\xcd\xd3\x32\x4f\x07\xd1\x34\xd3\xed" "\x07\xf1\xc1\x09\x00\x00\x00\x09\xdd\x87\x2e\xc6\x4f\xa6\xc7\x18\xbb" "\xd1\xaa\x59\x11\x40\xcf\xf0\xbe\x4c\x6f\x8d\xf0\x84\xc5\xe9\x73\x4a" "\xe3\x0a\xa9\xaf\xdc\x71\x25\xf0\x1a\xb0\x3a\x9b\x10\x74\x40\x71\x36" "\xb4\x50\x60\x00\xf0\x91\x6a\xad\xa0\x35\xdf\x2e\x04\x52\xa9\xb3\x9e" "\x73\xae\xeb\x6e\xaf\x14\x65\x2d\xda\x68\x9e\x20\x51\xd9\xb7\xeb\x85" "\xf3\xf2\xd5\xae\x2c\x51\x94\x4d\xa8\xd7\x39\x1d\x5b\x6b\x97\x41\x9a" "\x3b\x76\x60\x0c\xd1\xaa\x0a\xfe\x5f\x8f\x46\xdf\x4c\x51\x24\xca\x42" "\x5d\x37\x4b\x41\x9a\x62\x48\x02\x9d\x33\xd6\x1d\xd5\xc8\x44\x02\x4b" "\xa7\x57\x37\x18\x67\xa7\x9b\x31\xc6\x61\x7f\xc3\x32\x71\x91\xfb\xf5" "\x14\x57\x3f\x1e\x30\xd1\xfd\x2d\x76\x3f\x3e\xe9\x21\x8b\x15\xc1\xd6" "\x0b\xe2\x16\x8f\xff\xcd\x59\x9a\x2c\xb7\x7f\x12\x4e\x22\xf8\x76\x73" "\x67\x58\x05\x49\x4d\xb8\x21\xf3\x9b\x50\xd9\x38\xd5\xfd\x8c\x6b\x2a" "\x3a\x32\x4c\x25\x7b\xc9\x7d\xef\x5f\x07\xf2\x98\x00\x05\xa4\xf8\x1a" "\x9c\xf8\x11\x09\x71\xb7\x49\xcc\xd7\x40\x89\xed\x6b\x86\xf8\x1c\xa3" "\xd2\x47\xd8\xf7\x1d\x29\x0e\xd1\xb1\xa1\x1f\x7a\x67\x12\x51\x70\xc8" "\x8c\x3b\x6a\x50\x69\x63\x32\x22\x64\x01\xb1\x10\xda\x9c\x44\x07\xec" "\xa2\x2d\xeb\xc9\x93\x35\x58\x3b\x00\x01\x3c\x31\x30\x97\x8f\xa0\x69" "\xaf\x82\x23\xb3\x8c\xed\x73\x5c\x2d\x90\xc6\xd8\x4c\x30\xa0\xd8\x7d" "\x42\x64\x74\x89\xb3\x96\x01\xbe\x5c\x27\x69\x6c\xf2\xf1\x66\x25\xc0" "\xc1\x02\x00\x00\x00\x00\x00\x00\x00\x9e\xf5\x21\x34\x84\x2e\x64\x17" "\x1f\x39\x63\x84\x10\x86\xe3\x79\x7a\x48\x25\xd0\x81\xf2\xd9\x87\xf0" "\x5c\x53\x41\x87\xa6\x24\x04\x12\xc8\xf2\x83\xcc\x0c\x1e\xba\x28\x66" "\xdc\x95\x80\x00\x00\x00\x00\x00\x00\x00\x7f\xff\xff\xff\xff\x55\x4b" "\x82\xd9\xc1\x62\xf3\x55\x60\x76\xb8\x05\x52\xd9\x61\xca\x74\xf1\xff" "\xda\xcc\xf0\xea\x5f\x02\xe0\x3a\x9c\xcb\x90\x87\xe6\xc3\xb3\x91\x7b" "\xb7\x4f\xd3\xd5\x60\x70\x0a\x1f\xab\x44\xe7\x7e\x31\x2b\x3b\x12\x9e" "\x00\x03\x02\xd6\x13\x91\x6c\x9b\xcf\x9f\x00\x00\xfa\xc7\x3a\x5b\x6b" "\xfb\x01\xef\xad\xa8\x00\xe5\x00\x00\x00\x00\x00\xfd\xaf\x2f\x7b\x3b" "\x79\xa4\x33\xe0\x80\x74\xea\x24\x62\x97\x4a\xb2\xcb\xd2\x47\xeb\x1c" "\xfa\x26\x38\xf5\x6d\xae\xe5\x7e\xd1\x4b\xc7\x4d\xe0\xfd\x87\xa9\xce" "\x63\x81\x90\xf3\x57\x0e\x0b\x4c\x80\xef\x68\x2d\xf2\x22\x37\x27\x09" "\x55\xaf\xb6\x00\x88\x46\x55\x7e\xe3\xbc\x09\xfd\xa6\xdb\xb6\x55\x0d" "\x59\x73\x00\xeb\x82\xa1\x84\xc9\x6f\xfd\xe5\xa3\x0e\x54\x33\xd8\x66" "\x66\x5b\x98\xca\x20\x02\xc8\x36\xe8\x9f\xee\xf9\x04\xc2\x2f\xf2\x63" "\x4b\x7b\xfb\xf5\xc0\xd5\x86\xcd\xa5\xb4\x5f\xd0\x0d\xed\xe1\xe8\x8a" "\x4d\x41\xde\xe7\xcc\x8d\x08\x34\xfb\x8d\x12\x46\x38\xfe\xc5\x8f\xae" "\xb4\xc1\x6a\xbb\x44\x0d\xf2\xa6\x94\xf4\xcd\xca\xa4\xf6\x5c\x22\xf0" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xd5\x03\xd7\x99" "\x06\x95\x81\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\xff\xf0" "\xef\x89\xb2\xa6\x8d\x2b\xb2\xdd\x16\x3e\x86\x33\x14\xe8\x44\x98\x01" "\xb5\x2b\xb9\x3f\x6c\x90\x84\x65\x9c\xe7\x77\xdd\xa8\x56\x3c\x85\x96" "\x56\xa3\x57\x77\x02\x89\xa6\x1f\xaa\x95\xa8\x2b\xf1\xcf\xb7\xf2\xf9" "\x72\x52\xe9\x32\x2a\xbe\x28\x2c\x33\x44\xfc\x67\x38\xb4\x46\x78\x93" "\xb9\xbf\x0d\x1c\x81\x30\xae\x6b\x00\x11\x06\x35\x37\x64\x13\xc2\x9f" "\x7c\x6f\x7b\x7e\x29\xb9\xf4\xbd\xdd\x5e\x32\x86\x61\xf4\x61\x5e\x62" "\x7a\x6f\x60\x8a\xd5\x3a\x41\x68\xfe\x8e\x5d\x7d\x93\x4a\xa2\x89\xb4" "\xbd\x2b\x87\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\xbc\x4b\x4f\xf5\x00\x00\x00\x9b\x77\x78\x83\xa0\x2f\xfd\x92\xdf\xc4" "\xcb\x41\x14\xb9\xf9\xcf\x4a\xd1\x55\x11\x0c\xd3\xac\xe2\xb3\x22\xae" "\x31\xbf\xa2\x78\x47\xc7\x99\xc8\x86\x9a\x1e\xa5\xb9\x8e\x52\x5e\x63" "\x83\xad\x7f\xd9\x79\x51\x70\xe7\xb1\x1e\x24\x76\x03\x00\x00\x00\x00" "\x14\x59\xc7\xf6\x06\xd7\x21\xd3\x97\x96\x76\xbf\xfb\x30\x49\x16\x6a" "\xb8\x4a\xc1\x06\x19\x91\xbd\x57\xc2\x56\x6c\x10\xc2\x96\x35\x2a\x51" "\x05\xb6\x16\x4e\x3f\x24\x91\xe4\x79\x3e\x59\x0d\xcc\x71\xf1\x10\xda" "\x96\x36\x6c\x40\xdd\x44\xa2\xc9\x88\x2d\x3a\xa0\xf8\xa7\x97\xb8\xfe" "\xa6\xef\xcf\xb5\x27\x6b\x76\x79\xf1\x55\x59\xcd\xaa\xbf\x5f\xc1\x4a" "\xdd\x71\xd0\xbc\xa3\x74\x05\xde\xd6\x9b\x77\xab\x4a\x3d\x74\x87\xfd" "\x50\xc5\xe2\x2a\xde\xf9\x54\x6a\xbb\x7a\x2d\x9c\x08\x5b\x18\x9b\x5f" "\xd1\xf3\x0e\x4e\x0c\x13\xf6\x08\x70\xfd\xe1\xf8\x8d\x83\x0b\x11\x00" "\x21\x35\xe8\xe7\x26\x2f\x29\xb6\xd7\x92\x3b\xfb\xe0\xbd\x2a\x8b\xe1" "\x79\xe5\x6b\x41\xff\x37\x92\xce\xe2\xfc\x37\xee\xe7\x39\xc3\x00\x8c" "\xe7\x40\xd8\x80\x4f\x8e\x70\x5f\x0d\xc5\x9d\x00\x00\x21\x36\x3e\x8d" "\xf9\x4f\xf1\x75\xb4\x8d\xc8\xc1\x2d\xef\x68\x1a\x11\x64\x79\x46\x59" "\x54\x45\xbf\x1c\xb7\xd2\x77\x8c\xd2\x7a\x6b\x3b\x29\x66\xb0\x8b\xe6" "\x00\x00\x00\x20\xa8\xa7\x11\xd1\x93\xba\xe0\xab\x2d\xb9\xed\x9c\x6c" "\xb3\xc3\xde\x42\xab\x89\x52\x44\x14\xca\xe9\x22\x14\x1f\x7b\xaf\x17" "\xeb\xb7\x90\xad\x60\xbd\x03\x87\x0c\x39\xd1\xad\x12\xc7\x50\x83\x7e" "\x63\xf9\x88\x0f\xd7\x02\x59\xe3\x55\x90\xaf\xb4\x84\x3c\xd4\xe9\x98" "\x93\x98\xea\xa8\x9c\xef\xb3\xaa\x13\xca\xb8\xd0\x15\xcb\xaf\x15\x61" "\xd9\x53\x62\xde\xcd\x73\xb8\xf8\xcb\xf8\x26\x9c\xac\x09\x1c\xfa\xaa" "\x3c\x7e\x46\xd6\xe7\x91\x45\xfc\x0f\x1d\x1b\x38\x37\x52\xcc\xb4\x05" "\x15\xa7\x72\x35\x6d\x74\x69\x14\x54\x02\x16\xad\xf4\xc0\xf4\x4f\x1c" "\xff\x37\x60\xaf\xa2\x52\x72\x0e\xc6\xda\xd3\xa9\x86\x71\xec\xda\xff" "\x46\xcd\xdf\xfb\x1f\x05\xa0\xc0\x97\x60\x70\xd6\x03\xa4\x42\xd0\x14" "\x82\x23\x69\xfa\x3e\xac\xbb\x69\xbd\x1b\x0a\x07\x43\x57\xac\xd5\xd0" "\x21\x61\xfe\xd1\x46\xad\x3a\xa1\x5d\x2b\x81\x01\xb7\xbd\x1e\x09\x1a" "\xda\x78\xec\xd5\x01\x81\xf4\xb3\x5c\xae\x1b\x29\xaf\xf9\x14\x94\xc9" "\x16\x32\x3b\x61\xf8\x15\xc4\xe0\x70\x16\x57\x08\x7a\xd1\x1e\xef\x97" "\x95\x29\x21\x36\x5b\xc8\x98\xba\x2c\x76\xa9\xb6\xe0\x05\x2f\x43\xb1" "\xad\x2d\xfd\xf3\xf9\x58\xfc\x1d\x32\xe6\x92\xbc\x88\x46\xc7\x8a\x95" "\x6a\xda\x45\x3c\x67\xc1\xc2\xcd\xc4\xf8\xb1\xc9\x4e\x9a\xdc\x10\x6e" "\x85\xb3\x1e\x03\x0d\x95\x5c\x55\x78\xe1\x07\xa6\xe8\xca\x0d\x4d\xd0" "\x53\x44\xc3\xe2\xaf\x25\xd9\xa3\xb0\xf7\x80\x56\x24\x01\x6a\xea\xb2" "\x71\xa7\x5f\x0b\xac\xb1\x01\xa1\x03\xef\x89\x48\x06\x45\x69\x15\x4a" "\x7d\xe0\x8f\x80\xe4\xdf\x4c\x33\x9b\x69\x43\x1b\x0a\x56\x71\x09\x7d" "\x89\x21\x2b\x46\x5b\x0b\x32\x27\x5d\xea\xe1\x0a\x77\xe3\x34\xc9\xfc" "\x07\x4d\x18\x1b\xde\xb5\xbe\x80\xa6\x24\x9d\x47\x2e\x78\xe6\xbe\x57" "\xa5\xcc\xd3\x54\xcf\x18\x1e\x09\x96\x05\xa6\x44\xec\xad\xe2\x21\xa2" "\xbe\x92\x62\x10\xb2\x69\x0d\x09\xe4\xb7\xa3\xde\xa2\x54\x03\x39\x74" "\x39\x97\x9c\x27\xd5\x61\x32\x62\xde\x08\xba\xce\xcf\xff\x2d\x58\x43" "\x7f\x42\x2d\xf4\x25\x2c\x01\x87\x95\x31\x0c\x25\xe8\xfc\xe1\x8e\xd3" "\x66\xac\x2c\xaa\xde\x56\x4c\xa8\x69\x72\x7a\x7d\x63\xc2\x62\x71\xe1" "\x7d\x7a\xba\x48\x97\x18\x35\x53\x03\x11\x54\x52\x73\xd3\xca\xad\xeb" "\x5d\x20\x17\xdc\xdd\xab\x8f\x38\xf2\x06\x8f\x68\xa4\x11\x1d\xdd\x58" "\x7b\x5d\xf4\xb5\xd8\xf1\xce\x00\x23\x1a\x20\x92\xeb\x2e\x79\x7c\x49" "\x1a\x1e\x66\xf7\x36\x06\xfd\x95\xbb\xe0\xf1\x05\x21\x86\x2b\x62\x62" "\xf0\x25\x9d\xa5\x1f\xf7\x51\x7a\xce\x73\x61\x46\x0a\x46\x69\xa9\x7f" "\x7d\x0b\xf0\x95\xc2\x78\x7f\x00\xbd\xbf\xee\x19\x67\x0d\x1e\x0e\xc5" "\xe6\xc3\xcb\x09\x97\x2f\xa4\xd9\x49\x93\x15\x7b\x96\xd6\x69\x51\x77" "\xc9\x9d\x83\x71\x66\x51\x12\x93\x20\x92\x43\x52\xcd\xa7\xb8\xea\xd9" "\x1c\x33\x01\xaf\x62\x0c\x1e\x8d\x70\x3d\xd2\x9a\xd7\x7f\x54\x83\x67" "\x79\x60\x0b\xb0\xdb\x3e\xcf\xbd\x36\xfa\x81\x64\x99\x98\x98\xe4\xaa" "\xa5\x63\x24\xe1\xc0\x3a\x74\xda\xf5\x93\xf9\x2a\x8e\xcc\x03\xf8\xc8" "\xe3\xaf\x9a\xe0\x7d\xc0\x37\x80\xcc\x0d\x69\xda\x9e\x35\x28\xc1\x69" "\x3f\xb5\x19\x98\x73\x19\x92\xce\xb2\x7d\xcc\x0b\xe5\xbe\x4d\xec\xef" "\xe4\x1b\x78\xbc\x18\x47\xbf\x54\xb0\x87\xe0\x95\x17\x2f\x06\xcf\xa6" "\xd4\xbf\x95\x8b\x1d\x45\x44\x94\x7f\xf1\x23\x06\x55\x19\x9d\xb4\xf4" "\x75\x00\x60\x47\xfe\x83\xca\xca\x97\x75\x8d\xff\xa5\x3c\xee\x76\x4f" "\x85\x93\x2e\xb2\x0d\x54\x24\x1b\x2d\x51\x5c\x08\x26\xdf\xe1\xf0\xf4" "\x0a\xe9\x20\x45\x5a\x45\x48\xfb\x35\xe2\xa3\x45\xc0\x5b\x1c\x25\x2b" "\x78\x77\xbb\x3d\x83\x4b\x0b\x35\x79\xa3\x62\x49\x14\x6f\x83\x2e\xf2" "\x58\xdf\x51\x27\x31\x8c\x70\x17\xac\x1a\x99\x6c\x4f\x90\x2f\x82\xde" "\xb6\x0f\xd1\x13\xcc\xf8\x12\xd5\x5f\xfd\x62\x50\x57\xbd\x4f\xf3\x96" "\x09\x92\xb8\x5b\xc8\xd3\x0e\xdf\xca\x38\x6b\xe1\x6b\x1c\x54\x9a\xec" "\x52\xe3\x1e\x14\x05\xf8\x6c\x77\x60\x28\x29\x01\x75\x0b\x73\x2e\xc0" "\x6b\x0d\xb7\x35\x22\x2a\x73\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1e" "\xd5\x8c\xd2\xc6\x84\x66\x71\x78\x57\x6d\xbb\x57\x34\x5b\x63\xc3\x13" "\xe4\xa8\xfc\xfe\xfe\x51\x1e\x08\x4c\x24\xb3\x1a\x2e\x69\x39\x46\x74" "\x8b\xb7\x35\x11\x69\x5b\xc0\xee\xc1\x55\x3b\x0f\x67\xd5\x06\x78\xfb" "\x29\xad\x13\xd2\x10\x4f\xdd\x7a\x99\x25\x74\xd4\x75\xd3\xe5\x16\x52" "\xfb\x3f\xda\x6a\x9f\xc0\x45\x8f\x10\xb6\xd1\x21\xbd\x48\x66\x48\x58" "\xb5\x1a\x90\x54\xd7\xc1\xd3\x10\xaf\x6a\x04\x3e\x4b\x99\x47\x2f\xbf" "\xf8\x6f\xea\x83\x92\x40\x59\x41\x9d\x54\xf0\x7d\xa0\xb6\xb7\xd6\xe6" "\xd6\x1e\x68\x0f\x15\x1b\x0e", 2642); *(uint64_t*)0x200000000110 = 0x2000002bf000; memcpy((void*)0x2000002bf000, "syzkaller\000", 10); *(uint32_t*)0x200000000118 = 4; *(uint32_t*)0x20000000011c = 0x436; *(uint64_t*)0x200000000120 = 0x200000000040; *(uint32_t*)0x200000000128 = 0; *(uint32_t*)0x20000000012c = 0; memset((void*)0x200000000130, 0, 16); *(uint32_t*)0x200000000140 = 0; *(uint32_t*)0x200000000144 = 0; *(uint32_t*)0x200000000148 = -1; *(uint32_t*)0x20000000014c = 8; *(uint64_t*)0x200000000150 = 0x200000000000; *(uint32_t*)0x200000000000 = 0; *(uint32_t*)0x200000000004 = 0; *(uint32_t*)0x200000000158 = 7; *(uint32_t*)0x20000000015c = 0x10; *(uint64_t*)0x200000000160 = 0; *(uint32_t*)0x200000000168 = 0; *(uint32_t*)0x20000000016c = 0; *(uint32_t*)0x200000000170 = -1; *(uint32_t*)0x200000000174 = 0; *(uint64_t*)0x200000000178 = 0; *(uint64_t*)0x200000000180 = 0; *(uint32_t*)0x200000000188 = 0x10; *(uint32_t*)0x20000000018c = 0; *(uint32_t*)0x200000000190 = 0; res = syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0x200000000100ul, /*size=*/0x48ul); if (res != -1) r[0] = res; break; case 2: res = syscall(__NR_socket, /*domain=*/0x29ul, /*type=SOCK_SEQPACKET*/ 5ul, /*proto=*/0); if (res != -1) r[1] = res; break; case 3: res = syscall(__NR_socket, /*domain=*/0xaul, /*type=*/1ul, /*proto=*/0); if (res != -1) r[2] = res; break; case 4: *(uint32_t*)0x200000000100 = 1; syscall(__NR_setsockopt, /*fd=*/r[2], /*level=*/6, /*optname=TCP_THIN_LINEAR_TIMEOUTS|TCP_CORK*/ 0x13, /*optval=*/0x200000000100ul, /*optlen=*/4ul); break; case 5: *(uint16_t*)0x200000000080 = 0xa; *(uint16_t*)0x200000000082 = htobe16(0); *(uint32_t*)0x200000000084 = htobe32(0); memset((void*)0x200000000088, 0, 16); *(uint32_t*)0x200000000098 = 0; syscall(__NR_connect, /*fd=*/r[2], /*addr=*/0x200000000080ul, /*addrlen=*/0x1cul); break; case 6: *(uint64_t*)0x200000008dc0 = 0; *(uint32_t*)0x200000008dc8 = 0; *(uint64_t*)0x200000008dd0 = 0x200000000240; *(uint64_t*)0x200000000240 = 0x200000000540; memcpy( (void*)0x200000000540, "\x88\x83\x03\x26\x3a\x9e\x1c\xd1\xb5\x0f\xc2\xef\xc6\x26\x70\x9c\x96" "\xbc\xab\x98\xbe\xea\xa9\x07\x71\x49\xfd\x4f\xfe\xb7\xb7\x85\x9b\x0a" "\x68\xc3\x9e\x88\x81\xca\xb4\xfd\xf6\x5d\x79\x13\x58\xed\x73\x4a\xcb" "\x07\x14\x9c\x48\x7b\x4f\x50\xc5\xf9\x17\x13\x9e\x9d\xdd\x44\xad\x39" "\x18\x14\x91\xd0\x94\x61\xf2\x0f\x51\x50\x32\x83\xb4\x1f\x60\x18\xeb" "\x59\xe8\x78\x17\x80\x75\xbb\xae\x99\x36\x08\x0a\x53\xe6\x8b\x3c\xab" "\xbb\x85\xca\x08\x2b\xf4\x89\xfa\x6b\x1a\xbd\x74\xc3\x46\xff\x04\x96" "\x23\xfa\x21\x72\x2d\x20\x46\x36\x95\xf8\x1a\x23\x4d\xe7\x02\xe5\x8d" "\x0b\x7a\x3f\xcd\x18\x3b\xe3\x73\xc7\x3e\x60\x7e\x8c\xfe\x2b\x65\xab" "\xd2\xcc\x3b\x97\xda\xca\x65\xb6\x74\xbb\xd6\x51\xde\x2a\xce\x29\x2d" "\x1d\xb6\x65\xae\x1b\xd9\x57\x5b\xfd\x33\x67\x53\x99\x56\x6e\x7c\x5c" "\x56\xd3\xd7\x23\x2a\x30\x7b\x49\x6f\x31\x1c\xa8\xd3\xd1\x5e\xc4\xc8" "\x24\xed\x0f\x4a\x67\x2c\x68\x55\xc8\x6e\x0d\x8d\x2e\xc8\x29\x1a\x82" "\xa3\xf1\x5e\x2c\xce\x9e", 227); *(uint64_t*)0x200000000248 = 0xe3; *(uint64_t*)0x200000000250 = 0x200000000200; memcpy((void*)0x200000000200, "\xc0\xce\x26\x48\x6d\x16\x4b\x43\x1d\xb4\x44\x40\x94\xbe\x80\xf5" "\xdf\xee\x9b\xa9\xa6\x5a\x4d\x50\xb8\xf8\x3f\x2a\x90\x24\xe5\x58" "\x6a\x61\x4f\x02\xb0\x63\x59\x5a\x81\x72\xc5\x5e\x67\xc5\xd0\x85" "\xc9\xbf\x44\xd4\xac\x2c\xb5\x36\xf9\xdd\x56\x00\x7c\x79", 62); *(uint64_t*)0x200000000258 = 0x3e; *(uint64_t*)0x200000008dd8 = 2; *(uint64_t*)0x200000008de0 = 0; *(uint64_t*)0x200000008de8 = 0; *(uint32_t*)0x200000008df0 = 0; *(uint32_t*)0x200000008df8 = 0; *(uint64_t*)0x200000008e00 = 0; *(uint32_t*)0x200000008e08 = 0; *(uint64_t*)0x200000008e10 = 0x200000000c00; *(uint64_t*)0x200000000c00 = 0x2000000006c0; memcpy( (void*)0x2000000006c0, "\x9d\xe6\xd3\x75\x03\x49\xc2\xf3\x84\x7f\xa4\xa0\x5f\x94\xad\xb3\xd2" "\x1f\xc6\x8c\x16\x1a\xea\x97\xb3\x82\x46\x31\x36\xde\x88\x58\x46\xc0" "\x51\x3c\x1d\x9a\xf3\xf7\x21\xca\xd5\xa7\xa7\x53\x81\x6b\x79\xe9\xaf" "\x45\x9a\x77\x19\x53\x69\x32\x40\x1f\x19\x4b\x7c\x3c\xdd\x1b\x9f\x5b" "\x28\x1e\x87\x5b\x96\x30\x4c\x31\xf9\xaa\x02\x16\x42\x55\x2f\x18\xaa" "\x7d\x26\x9b\xce\xb6\x14\xa8\x89\x5c\x58\x9c\xeb\xc5\xde\xea\x72\x2b" "\xc9\xef\xaf\x97\xab\x2f\x09\x8d\x99\xb9\x62\x10\xc9\x91\xe8\x49\x6e" "\xae\x1a\x05\x58\xcc\x75\x9f\x38\x86\xcc\x73\x5c\x0c\xea\x51\x19\xc1" "\x0b\xe6\x90\x68\xad\xdb\xd4\x98\x6f\x7a\x7b\x50\x3f\xf9\x3a\xf9\x1d" "\xd3\xd1\x73\xd2\x0e\xa0\x95\xe5\x6d\x3b\x9b\xf6\x2b\x6d\x54\x7e\xfc" "\x4b\x5c\xf9\x4b\xd6\x33\xef\x41\x8e\xce\x87\x1a\x5b\xdb\x42\xff\xb2" "\x76\x61\xc2\x22\x75\x4b\xbb\x33\x3c\x1e\x65\xec\x05\x85\x5b\xe1\x24" "\x34\x17\xf2\x7d\x30\xc5\xe7", 211); *(uint64_t*)0x200000000c08 = 0xd8; *(uint64_t*)0x200000000c10 = 0x2000000002c0; memcpy( (void*)0x2000000002c0, "\x46\x8a\xcd\xb4\xe4\xcf\x04\x27\x16\x1e\x4b\x33\x4f\x4c\x94\xeb\xd8" "\x25\x85\x0e\x7c\x13\x2a\x12\x17\xaa\x3b\x55\x47\xf1\xdc\xc7\x3e\xfd" "\xc5\x75\xd1\x6f\x90\x98\x5e\x47\x82\x31\xfe\x76\xee\x24\xfc\xfe\x97" "\x99\x49\x7d\xb0\xcb\xe5\x95\x4a\xcd\xed\x7a\x24\x62\x2c\x24\x63\xba" "\xe7\x52\x9c\x05\xa6\xc8\x1e\x33\xee\x93\x86\x9f\xd7\xc5\x7f\xef\xf1" "\x7c\x9c\xd8\x09\xb1\xbe\x24\x1e\xdc\xed\xe1\x7e\x46\x43\xef\xc8\xc2" "\xba\xed\x1e\x24\x42\xf3\xa2\x36\xfe\x60\xe4\x68\x5d\x29\x71\x07\x7e" "\x62\x5d\xce\x6f\x0b\x6c\x21\x6f\xfc\xeb\xec\xd7\x63\xc3\x9e\x87\xeb" "\x64\x1e\x70\x46\xdd\x68\x94\x9a\xcc\x02", 146); *(uint64_t*)0x200000000c18 = 0x88; *(uint64_t*)0x200000000c20 = 0x200000000880; memcpy((void*)0x200000000880, "\x52\xa6\x7f\x4b\x2e\x32\x45\xfb", 8); *(uint64_t*)0x200000000c28 = 0xfffffee6; *(uint64_t*)0x200000000c30 = 0x2000000008c0; memcpy((void*)0x2000000008c0, "\x91\x01\x73\xd8\x11\xa7\x73\x77\x20\x7b\x36\x1d\xd6\x3b\xd4\x56" "\xea\x8e\x58\xa1\xe5\x56\x99\xc4\xfd\x02\x06\xe2\x71\x61\x04\x5d" "\x62\x98\x99\x59\xf8\xfa\x93\xa3\x43\x7f\x4a\x33\xe5\x58\xce\x92" "\x4e\x3b\xe6\x4f\xd7\x3c\x92\xb7\x33\xb2\xc1\x78\x59\x9b\x60\xcf" "\x9f\x37\xb9\x73\x62\x21\x05\x16\x66\x5b\xe1\xe1\x10\x54\x4d\x2a" "\x87\xc7\x75\x04\x50\xa6\xa7\x3d\xea\x61\x72\xb7\xd9\x76\x67\x05" "\x0f\xb8\x30\x9e\xd2\xa1\x8f\x0b\x5f\x48\x95\x68\x4e", 109); *(uint64_t*)0x200000000c38 = 0x6d; *(uint64_t*)0x200000000c40 = 0x200000001500; memcpy( (void*)0x200000001500, "\xcd\x07\xe8\x51\x42\xf8\xea\xd4\x99\xf3\xef\x72\xf2\x22\x7c\x53\xdd" "\x92\x55\xde\x47\x66\xb5\xf3\x3e\xf2\x18\xa7\xc3\x9a\x97\xbb\xd4\xf8" "\x38\x5f\x18\x52\xa0\x8a\x0e\x90\x0c\x7f\x91\x83\xf6\xc7\x4e\x7e\x34" "\x07\xba\xc0\xd6\x4f\x2f\xe7\x63\x27\x8f\xbc\x7e\xa1\xe7\x11\x1b\xe7" "\x46\xae\x27\x48\xfc\x96\x28\x8a\x8b\x28\x8a\x6d\x1b\xaf\x35\x51\x49" "\x05\xbe\xe7\xb7\x01\x75\xdd\x6a\x5b\x1b\x43\x73\x5e\x06\xd2\x36\xee" "\x53\xc7\x9a\xa6\xf8\x17\xe8\x33\x61\x8b\xa7\x32\x1a\xfd\xf3\x06\x56" "\x58\x9f\xb5\xd9\x2a\x67\xf7\x0e\x2c\xb1\xdd\x98\xe4\x8f\xf6\x5b\xb2" "\x56\x9a\x25\x8f\x78\xbc\xa3\x68\x27\x50\xe0\x58\x4e\xa0\x06\x29\xc6" "\x7c\x64\x11\xcd\x53\x2d\x62\xbe\x01\xf1\x43\xfe\x9c\xe3\x90\x12\x14" "\x73\x57\xe8\xab\xe3\x7b\xaa\x6c\xfa\xd2\x8b\x94\x9c\x34\x3c\x17\x56" "\x70\x15\xb2\x81\x1e\xa8\xdf\xd5\x77\x74\x98\x55\xbc\xc1\xcb\xda\xe0" "\x64\x31\x8a\xc8\x3c\x50\x51\x29\xa4\x07\x54\x3c\x35\x5a\x4e\x90\x2e" "\x6d\x43\xe9\x2c\xf7\xd4\xa5\x38\x40\x0b\x77\x41\x30\x4b\x91\x79\xbc" "\x83\x57\xb8\x20\x81\xd7\x14\x1a\x38\x8f\x86\x59\x10\x8d\xbd\x31\x42" "\xdc\xa4\x48\x3e\xfd\x11\x2e\xae\x79\x5c\x78\x0a\xa1\x4f\xde\x5d\x3a" "\xd8\xa2\x9f\x57\xcb\xbe\x49\x29\xce\xd3\xec\x0c\x45\xc4\x96\x4e\x62" "\x7d\x28\x3b\x4c\x83\x02\xab\x1e\xac\x47\x96\xa4\x0f\xf7\x91\x06\xab" "\x2b\x28\xa1\xa7\x20\x28\xa5\x6a\x6b\x4e\x7e\x44\xf9\x57\x89\x70\xf3" "\x7f\xc3\xed\xfd\xf4\xb5\x1b\xec\xe9\x82\x70\xe1\xb3\xb8\xda\x8f\x4b" "\xad\x2d\x38\xd0\xd0\x42\x20\xf5\x3e\x70\xf8\x8f\x94\x31\xcd\x81\x84" "\x99\x52\x53\xd3\x8f\x27\xfb\xec\xe6\x6f\x45\x55\x8a\x09\x41\x27\x7d" "\xe0\x30\x8e\xd8\xa3\xbd\x8c\xba\xa2\xf1\x24\x06\x45\x80\x86\xf3\x7d" "\x44\x7d\x9c\xb4\x71\xc3\xb0\x75\xbe\xf7\x96\x73\xe3\xb2\x7d\x70\x7f" "\x14\x83\xbe\x89\x49\x60\x0e\x92\x59\xa4\xed\xb9\x62\xff\x5e\x2a\x47" "\xa3\x69\x46\x88\x14\x97\x1d\x2a\x81\xbb\xdf\x62\x22\xdf\xd7\x33\x49" "\x12\xd3\x3b\x51\x08\x0c\xec\xb1\xeb\x5c\xa9\xee\x57\x3a\xbc\x27\x7b" "\x75\xe1\x5b\x8f\xe9\xb2\x42\xab\xd7\x4e\xa7\x4a\x4f\x83\xbd\x96\xe3" "\xb1\xae\x92\x4d\x92\x7b\xb4\x5a\x7b\x4b\x87\x9f\x6a\x68\x9f\x49\x77" "\xd0\xdb\xd4\xea\xa0\xcf\xe6\x4d\xac\xb8\x2c\xf3\x78\x4e\x21\xcd\x4e" "\x13\x6e\xe6\x10\xc2\x67\x2e\xae\xdf\x35\x91\x8d\x3c\x82\xee\xc2\x8e" "\xa5\x75\x3e\xa1\x37\xf8\xa5\xd2\xf2\xf8\xa7\xac\xef\xfa\x1d\x71\xac" "\x75\xbe\xf1\x77\x94\x5d\x75\x7d\xdc\x90\x4c\x46\xa8\xa6\x93\x36\x86" "\x1c\xf0\x8a\x5c\x51\x99\x68\x07\x00\x8e\x58\xeb\xf2\x3a\x7e\x59\x7b" "\xb0\x7c\xce\x48\xe4\x0b\x8a\x17\x21\x44\xc4\xe6\x49\x09\x0f\xba\x0e" "\xc6\x21\x52\xf8\x5c\x3c\x4b\x84\x3b\xde\x0f\x6e\xaf\xba\xa1\x2b\xd1" "\x44\x98\x01\xd2\xc4\xbf\xb5\x13\x17\xbb\xc4\xd5\x21\xea\x10\x15\xe7" "\x3a\x8c\x91\x46\xeb\x37\xeb\x95\x83\xa2\x44\x3d\x8e\xea\x22\x93\xc8" "\x08\xef\xc1\x9a\x57\x35\x40\x82\x81\xf1\x6f\x59\x0e\x00\x41\x5c\x43" "\xac\x2c\xe1\xc3\x43\x2d\x41\x52\x5d\xd0\x13\x7e\xb9\x91\xd9\xc5\x6c" "\x16\x3c\x0d\x4a\xb2\xd4\xce\x2a\x41\x8f\xf5\x37\xbf\x20\xe6\x15\x2b" "\xbd\x81\xd4\xa2\xa3\x57\x0a\x7c\x30\x53\xf2\xce\xb5\xe9\x79\x7d\x2c" "\x60\xfb\x06\x9c\xdc\xb0\x3e\x06\xae\xdf\x63\xff\x47\xf7\xef\x95\x51" "\xe2\x6c\xf0\x87\x40\xc7\x4b\x27\x3b\xcd\xa9\x59\xa1\xe9\xa8\x4c\x0f" "\xa0\x54\x16\xb9\x9d\x73\xd4\x02\xfb\x81\x75\x4e\x1c\xcf\x79\x6d\x9d" "\xa5\x33\x99\xd6\xdc\xe3\xce\x83\x30\x3c\xcb\x41\x66\xcf\x36\xcc\xb0" "\xc9\xbd\xdb\xe0\xe3\x4d\xfb\xca\xe3\x1b\x4c\xe8\xfe\x51\x35\x70\xe0" "\x36\x84\x4a\xb5\x16\xcf\x4d\x62\x93\xbd\xd3\x88\x11\x20\x84\xe6\xae" "\xfc\xc6\xe7\x96\x7f\xe9\x9a\xab\xd7\x2a\x20\x7b\xb4\xec\x8f\xc0\x2d" "\x5b\xc2\x29\xca\x68\xc9\xdb\x99\x52\x92\x08\x14\x6f\x49\xf2\x9f\xda" "\x53\xc4\x97\x07\xd7\x6a\x64\x9a\xa5\xdf\x76\x07\xc3\xee\x51\x4e\xb8" "\x20\xf4\xd0\xcc\x55\xd5\x47\xec\xd3\x19\x3c\x49\x46\x52\x5a\xf9\xf6" "\x8f\x8e\xc2\xd0\xa6\xb0\xcc\xfb\xd8\xae\x0a\x26\x52\x49\x25\x5c\x98" "\xe9\xe6\xab\x3d\x8d\x82\xdb\xfb\x8c\x15\xa8\xef\x69\xb7\x8c\xc9\xb4" "\xf0\xad\x5a\x2c\xe9\xd6\x79\x3a\xda\x0b\x61\x63\xd9\xd1\xed\x3e\x50" "\xf9\xc8\x19\xca\x46\xb4\x0f\xf4\x0b\x37\x5f\x5e\x2c\xe6\xca\xa9\x96" "\xaf\x36\x32\x4c\xbb\xaa\x63\x63\x5b\x0e\x10\x7a\xd0\x11\x74\xba\xa5" "\x53\xb8\x6d\xba\x12\xe8\xad\x95\x86\x72\x7a\x70\xae\xe6\x78\x51\x21" "\xe9\xed\xb5\xa9\x8e\x01\xb7\x84\x87\x34\xd3\xe0\x44\xc4\x94\xa4\x06" "\x14\x93\xe1\xae\x7f\xd7\x3a\x2e\xd9\xb8\x3d\x28\x6e\x24\xa7\x32\x96" "\x6f\xae\xe7\x70\x5d\x8a\x2d\x36\x01\x59\xac\xbd\xf1\x86\x16\x02\x81" "\x34\xc2\x5d\x1a\x92\xbb\x45\xf0\x62\x07\x70\x14\x54\x39\x0b\x87\xd5" "\xbc\xb6\x6e\xc7\x3d\x8c\x3c\x53\x04\x9f\x42\xc8\x5d\xe0\xac\xc4\x5a" "\x93\x79\x30\x22\x03\xbe\x19\x9c\xe5\x51\x54\xb7\x39\xbf\xb3\xd2\x79" "\x29\xb1\x21\x63\xe2\x07\x89\x05\x13\x77\x74\x97\x4b\x90\xc0\x79\x60" "\xfd\x41\x0f\xd5\x83\x94\xbc\x53\xe7\x74\x5f\x56\x27\xde\x2f\x03\x61" "\x41\x81\x73\x76\x3c\x69\xf8\xa1\x1d\x93\xa1\x04\xad\x38\x2c\xf3\x85" "\xb0\xc6\xc7\xc3\xc5\xfc\x82\x36\xe6\xf1\x8a\xe9\xbe\x05\x43\xd2\x8d" "\x54\x05\x0b\x9e\x60\xf2\xf7\x74\xa1\x6b\xe4\x90\x42\x43\xd4\x82\xad" "\x32\x52\xed\xac\xcc\xe5\x6d\xcd\x35\x0b\x6e\x24\x9f\xe6\x86\xd5\xad" "\xc0\x7b\xc5\x7c\x71\xae\xbd\xc2\x43\xea\xc5\x6f\x29\xfa\x24\xe6\x9b" "\x8d\x44\x4c\x54\xa9\x55\x22\xbe\xaf\xac\x62\x30\xa3\xc4\xe8\x9c\x6d" "\x55\x65\x4a\x4a\x07\x7f\x7f\x85\x4d\x6b\x24\xf8\xb4\x5d\xa2\xba\xa5" "\xdc\x3e\x4d\xf1\x5c\x56\x26\x3c\x7f\xa8\x06\x42\x78\x9e\xa7\x12\xa9" "\x56\x2a\x70\x37\x9a\xfe\x5a\xc5\x84\xc8\x91\x17\x8d\x71\xa5\x58\xe7" "\x34\x56\xe5\x3e\x7f\x92\x56\xf4\xc0\xb2\x7d\xaa\x3e\xab\x32\xf1\xe5" "\x6b\x3d\xd9\x28\x00\x53\xc1\xec\x57\xe8\x6f\xd8\x7a\x72\x5a\xb9\xa5" "\xd9\x3e\x3f\x8e\x6e\x84\x8a\xfb\xda\xdb\x85\x9c\x74\x4f\x40\xa8\x64" "\x86\xfb\xbd\x1d\xa6\xa1\x8c\x83\x4b\xf4\x35\x94\xaa\xc9\xd0\x34\x05" "\x21\xde\xa0\x6b\xef\xad\x18\xbb\x86\x8e\x9e\x63\x57\x8e\xd6\x6c\x70" "\xec\xfe\xb3\x1c\xe5\x57\x55\xa5\xd4\x8d\xe4\x11\x3c\x7e\x29\x97\x56" "\x43\xcb\xc5\x3f\x11\x4e\xd5\x22\x23\x1e\x41\x0f\x1f\xe4\xb9\x10\xe6" "\xaf\x3d\x4b\x56\x91\x89\x52\xf7\xf2\x52\x04\x81\x3b\x32\x83\xe2\x0a" "\x54\xfd\x28\x5a\x80\x98\x84\x94\x57\x6b\xd7\x38\xe6\x85\xed\xda\x51" "\x77\xee\xb0\xe2\xc9\x81\x6d\xac\x60\x30\x2b\x12\xec\x04\x6c\x9f\xeb" "\x77\x0d\xec\x40\x3f\xd4\xfa\xdd\x16\x28\xaa\x49\x78\x64\x7e\x8d\xac" "\x18\x25\x16\x6a\x5b\xe8\xb5\x80\xb1\x95\x38\x7d\x90\x1e\xcb\xf0\x3b" "\x70\xd4\x30\x1f\x6d\xe6\x9f\x69\x10\x09\xa6\x59\xc0\x31\x86\xb8\x43" "\x1e\x22\x60\x22\xf8\x11\xa6\xd2\xce\x73\xc8\xbc\xe1\x9b\x09\xe0\x47" "\x28\xb7\x39\xda\x06\x05\x46\x90\xf3\x0c\x71\xbb\x33\x26\xf8\xd4\xfc" "\x80\xcf\x65\x4a\x42\xfc\x61\x34\x96\x72\x06\xe1\x10\x55\x8a\x6f\x9e" "\x9c\x43\x4b\xf1\x75\xde\xf1\x83\xda\x8a\x5c\x13\x59\x75\xdd\x7e\xac" "\x8f\xce\xa1\x34\x37\x10\xcd\x92\xfd\xcb\xa2\x15\x2b\x32\xe0\x14\xcb" "\x8e\x87\xd3\xc5\x00\xe8\xf4\x39\xe1\x52\x2d\xa6\x86\x61\x05\xe9\x37" "\x66\x3d\x80\x44\x52\x79\x82\xd1\x47\xdf\x98\x3c\xa8\x3e\xaa\x7f\xb4" "\xdd\x5c\x0c\x79\x23\x2d\xd6\x87\xe0\x2d\xc1\x35\xd3\x06\x75\x47\xca" "\xfb\x19\x34\xb5\x76\x91\x14\x47\x2b\xeb\x90\x66\x46\xff\xdc\x44\x29" "\x12\x89\xbc\x27\x47\x82\x62\x29\x5c\x2f\xa5\x17\xcc\xd5\x53\x80\x4e" "\x73\xeb\x91\x50\xf5\xd4\x51\xaf\xd7\x9f\x17\x5e\x14\xb5\x63\xa5\xe6" "\xc8\x6e\x9a\x0e\xac\xd4\x50\xbe\x53\x0a\x3e\x50\x62\x97\xa7\x51\xbc" "\x58\x00\xf3\xc4\x5a\x3e\x18\xb9\x3c\x21\xaa\x8c\x0f\x2d\x14\x41\x22" "\x80\x33\x61\xd4\xb5\x9e\x2a\x21\xbb\x46\x2c\x0b\x8b\xf9\xd8\xf4\xc9" "\x16\x10\xc6\x33\xfe\xfc\xed\x62\xb8\xde\x88\xbd\x2e\x56\xe5\x8e\xb5" "\x38\xf3\x0b\x17\x10\xf8\xcf\x5e\x6e\x54\xdb\x33\xad\xc5\x3d\x25\x19" "\x35\x16\x96\x02\x8e\xdd\xa2\xe9\x15\xa3\xf5\x75\xee\x34\x88\xb6\xac" "\x2d\x96\x85\x6f\xe5\x74\x2a\xe5\x76\x79\xe1\x1e\x7b\xae\xeb\x74\x46" "\xaa\x3d\x92\xa8\x34\x08\x6b\x8b\x2e\xba\x58\xa1\x6e\x54\xa2\xdf\x19" "\xf4\xbe\x02\xfb\x9e\xd8\x0f\x95\x47\xc3\x27\xca\x69\xbf\xc0\x27\x85" "\x2c\x0f\x54\xee\xa0\x5b\x09\x82\xf0\xa0\x85\x48\xf1\x6a\x80\xd1\x71" "\x21\xb5\xc3\x53\x6d\x07\x2b\x6d\xd7\x89\x65\xd7\xfc\xb1\xd1\x3d\x84" "\x35\xc0\x03\x05\x0d\xe3\x90\x0f\x43\xec\x37\x80\x70\xff\x24\xe9\xfe" "\x46\x34\x51\xcd\x2c\xa1\xd8\x15\x32\x12\x1f\xa6\xa0\x10\xdf\x9e\x47" "\x1d\xbd\x06\x8c\x9d\xe5\x69\x8e\xb9\x86\xa4\x36\x40\x84\x3e\x6a\xb2" "\xae\x9c\x84\x96\x03\xcc\x1e\xd6\x79\x9c\xd8\x0a\x9d\xc8\x93\x71\x27" "\xef\x00\x6e\xdd\x44\x2b\x68\xfc\x79\xa7\xd3\x1d\x80\xf2\x55\xce\x95" "\x93\xe1\x2a\x21\x9d\x4a\x38\xa8\x4c\x2a\x77\xae\x3c\x60\x4a\xc3\x36" "\x14\xae\xa6\xc8\x52\x3e\x4f\x55\x38\x66\xb8\x01\xcf\xdb\xf3\x54\x53" "\x70\x55\x56\x85\xf2\xf6\xae\x4a\x05\x74\x57\x13\xba\xc8\x45\x2e\x86" "\x53\x68\x07\xb9\x86\x03\x7d\x28\x95\x3c\xc0\x93\x12\x2c\x7e\x40\x0f" "\x4e\xbd\x87\x62\x82\xe8\x31\xb5\xe4\x5c\x2e\x2d\xab\x9c\x76\x20\xef" "\x9a\xa3\xc3\xf7\x33\xba\xef\x8e\xee\x82\x42\xe0\xed\xfc\x20\xc9\xf5" "\x81\x27\x73\x9c\x97\x8f\xbd\xa2\x4a\xf4\x06\x8e\x36\xa0\xc5\x56\xcf" "\x2e\x60\xbe\x43\x3e\x6c\x86\xfc\xaa\xfa\xab\x94\x12\x43\x85\xc1\x4d" "\xff\x93\x27\x13\x04\x44\x32\xcf\xc6\xce\x7c\x6a\xe8\x8c\x1f\xe3\x20" "\x97\xd2\xe2\x23\x61\x68\x18\xeb\x1d\xf9\x81\xcd\x70\xa9\xa3\x5a\xd7" "\x77\x67\x45\xb6\x60\xde\xc2\x5e\x93\xcf\x5d\x61\x57\xcc\x16\x1b\x80" "\x80\x97\xf4\x9a\x77\x13\xc5\xa1\x64\xcd\x5c\xd6\x1c\xb4\x4b\x15\x5e" "\xdd\x38\xb7\x2c\x57\x88\xb5\x32\x8a\x10\x90\xcc\x36\x6f\xb1\x14\xd6" "\x58\xeb\x4f\x04\x57\x40\xfa\x95\xc1\x9a\x9b\x6f\xc4\xc7\x58\x03\x6b" "\x9b\xa3\xd5\x66\xe9\x30\x73\xa5\x38\x7f\x85\x0f\x70\xdb\x48\xd7\xc4" "\xa0\x71\xd2\xb6\xbc\xdc\x67\x11\x3b\x24\x26\x88\xfb\xdd\xff\xcf\xf2" "\xc3\x69\x68\x0a\x4f\x5e\x7f\x0b\xaf\xc2\x72\x41\xa9\x56\x95\xff\x39" "\xc8\x28\xf5\xd2\xb4\xe2\xa5\x95\x54\x14\xaa\xe2\x13\x58\x97\x1a\x9b" "\xd5\xd2\x7f\xb3\xb4\x98\x0d\x7a\x20\x58\xf5\xa6\x86\xa6\x5a\x95\x24" "\x5a\xa4\x18\xdf\x58\x9d\x61\x91\xdd\xf8\xe2\xa7\x5b\x80\xc7\x8d\xec" "\xe4\x9e\x7c\xdb\x6d\xc0\x38\x94\x4c\x8b\xad\xeb\x86\xab\x90\x3a\x7a" "\x2d\xb3\x5c\xff\x18\xdd\x46\xff\xbc\x02\xc3\x64\x61\x20\x5d\xf4\x7e" "\x93\xab\x49\x2e\xe2\xc4\x9b\x48\x9c\x22\xe9\xd0\xa4\x47\x66\xf8\x55" "\xcc\x1b\xc3\x76\x22\xc7\x2a\xb4\x52\x90\x88\x60\xcc\x05\x4e\x9c\xd2" "\x45\xce\xf2\x96\x67\xe0\x78\xe0\x94\x03\xf3\x95\xa0\xff\x22\x22\x72" "\xfd\x39\xbc\xf8\xc6\x57\xde\x07\x1f\xa6\xb0\x2e\xfb\x06\x2e\x13\x3f" "\x4c\xa1\x4d\xbc\x30\x41\xfc\x3d\x0d\x7f\x44\xa3\x0c\x95\x5f\xbe\x50" "\x88\xec\x22\x23\x55\xd0\xb5\x33\xf5\x06\xac\x75\xca\xdb\xb6\x46\xb4" "\x37\xec\xcd\xff\xef\x7f\x52\x1f\xf1\x4b\x37\x16\xf9\x45\xc3\xa0\xb5" "\x32\x61\x6e\x3f\xa4\xdd\x88\xec\xff\x41\x6b\x0c\x91\x79\x8a\xac\x70" "\x72\xc6\x10\xad\xef\x4e\x07\x6f\x56\x09\xbc\x0a\x44\x31\xde\x4d\xe4" "\xa7\x31\x81\x15\xa3\xf4\x5d\xd7\x10\x5f\x0d\x25\xcf\x2f\x2e\xcc\xfb" "\x94\x9b\x7e\x9b\x1c\x6f\x05\x1f\x1c\x8f\x61\xb9\x5f\x66\x5c\x21\x9d" "\x1f\x32\xb7\xaf\x58\x58\x18\xe5\x1a\x93\x7f\x5d\x90\xb0\xdd\x2d\x1e" "\x68\xf4\xa9\xf9\x4f\x8d\xa2\xab\x42\xb3\xc9\x1c\x95\x87\x15\x37\xd9" "\x4f\xc2\xa1\x91\x86\x2c\xbb\xe2\x84\x33\xc7\x77\x3a\x3d\xab\xe8\x2a" "\x37\x1c\x47\xc9\x05\xe4\x6f\x74\xf4\x96\x4f\xe4\xff\x35\x51\x58\x8c" "\xb9\x7d\x08\x94\x65\xd1\xdf\x16\xda\xaf\x56\x17\xd5\xb6\x77\xe2\xe7" "\x75\x41\xf6\x4e\xa3\x3a\xd7\x56\x11\xe1\x51\x6f\x23\x0d\x4f\x20\x7f" "\x58\x49\x44\x58\xb3\xe2\x5a\x3c\xe1\xd1\xd0\x98\xae\x8a\x8d\xb1\x1f" "\xbb\x77\x83\xd6\xf3\x96\x0e\x23\x7c\x0a\x24\xe3\x30\x43\xc2\x1a\x55" "\x2c\xed\xc8\xaa\x7a\x08\x38\xcb\x03\x40\x70\xa5\xaf\x23\x7a\xca\xaa" "\xcf\x0a\x43\x98\xb0\x36\xcf\x32\xdd\xd2\xd6\x14\xd2\x6c\x53\xa3\xfd" "\xbd\x0f\xe8\xcd\x1e\x00\x64\xc8\x77\x7a\xc8\xf9\x75\x5e\x02\xca\x4b" "\xf8\x69\xbc\x94\xcd\x6b\xea\x3b\xab\x11\x2f\x57\xae\xcc\x27\xe6\x01" "\x1d\x4b\x4c\x8c\x39\x26\xab\xf9\x95\xa3\x9b\x43\x84\xf9\xbf\x41\x0c" "\x4e\x35\x25\xa4\x7d\x4d\xb0\x5f\x3c\x6c\x25\x3c\x8a\xdb\x26\x78\xc5" "\xf8\x6d\xd2\xe5\xe3\xff\xca\x79\x8b\x5b\x75\x6c\x02\x07\xe6\x5a\x24" "\x84\x49\xcd\x09\xab\xad\x3b\x3b\x8f\xcd\xa3\x37\x12\x4b\xb6\x60\x79" "\xdd\x1a\xc7\x79\x49\xf3\xc8\xdd\xac\x73\x96\xea\xf8\x34\x85\x44\x16" "\x4e\xdb\x99\xe1\x78\xd5\x9c\x13\x87\x8b\x8b\x8d\xbd\x07\x59\xcb\xf4" "\xb6\xb6\xd3\xdc\xb5\xad\xb4\xb6\xbf\x84\x02\xb9\x3a\xa4\xa6\xb5\x37" "\x89\xb6\x27\xf6\x8b\x77\x26\x18\xcb\x8a\x96\x89\xad\x28\x2a\x23\x0d" "\x6e\x5e\x12\x5d\xa9\x10\xb4\xf2\x6f\x72\xca\xf1\xec\xa8\x36\x2b\x97" "\x7f\x83\xbc\x16\xa7\x98\xe0\x5d\xfc\x6c\x76\x75\xca\xc8\x26\x2e\x78" "\x1d\xb9\xdb\x22\x50\x95\x8a\xb6\xbd\xa8\x5e\xbd\x7c\x4d\x06\x68\x1e" "\xe0\xf3\x0b\xd0\x62\xa0\x82\x94\xce\x0d\x45\x9e\x10\xe3\xa0\xc2\x32" "\x33\x73\xec\x84\xac\x3e\x6d\x99\xec\x61\x34\xee\x39\x5b\x6c\xa8\xad" "\x6e\x6a\x53\xdf\xba\x9a\x07\x74\x79\x44\xcb\x2b\xe0\xed\x2f\xca\xc5" "\xc4\xe7\xc4\x3a\x5d\xa7\x60\x31\xce\xc5\x16\x9b\x3f\x44\x50\x99\x32" "\x2b\x70\x4a\x51\x98\xc1\x01\x8a\x3b\xce\x33\xa1\x55\xe7\x88\x1f\xac" "\x59\xfc\x52\x6c\x32\xe9\x54\xa7\x00\xc4\xb6\xdb\x8f\x25\x46\x7b\x71" "\x4d\x4b\x72\x32\x24\xc1\xf1\xbc\xf5\x9b\x2b\x75\xc5\x77\xfe\x4a\xcd" "\x95\xae\xa1\xc8\xec\x90\x75\x94\x54\x42\xa1\x29\xa3\xef\xd5\xe6\x4a" "\xa3\xd6\x68\xbe\x55\xe3\xc4\x35\x80\x52\x6e\x59\x6a\x74\xba\xf6\x05" "\x57\x66\x06\xc7\xba\xb5\x00\x59\x57\x37\x1f\x07\x5d\xbe\x44\x33\x34" "\x65\x56\x4a\xf0\xeb\x35\xdf\xe1\x44\x65\xd8\x70\x35\xee\x89\x6e\x6f" "\xe8\x13\x8e\xe4\x3b\xc2\xd3\x83\xe6\xee\x51\xfe\x4e\xd6\x23\x41\xd2" "\xa6\x8e\xd6\x43\x85\xec\x31\x86\x7f\x28\xab\x33\xa8\xe0\xe0\xda\x7c" "\x65\x87\x43\x2d\xf0\x28\x6d\x44\xa2\x4c\xa0\xe8\x5a\xe1\x51\x30\x7a" "\x24\x22\x2f\xff\xc9\x71\xb4\x76\xe4\x12\xa4\x50\xc5\x8d\x69\xb7\xb4" "\xa5\xd8\x9c\x5f\x55\x17\x0d\xc5\xf3\x68\x90\x89\xf4\x98\x94\xcf\x6d" "\x03\x4f\x68\x00\x67\xb2\x85\x82\xca\x20\x66\xd2\x57\x8d\xec\x35\x28" "\x04\x12\x89\xc7\x34\x03\x55\x42\x50\x64\x44\x1b\x64\x7a\x51\xbb\x4b" "\xe7\x46\xc1\x65\xc1\x0c\x0a\x2a\x82\xc8\x64\x4a\x83\x2a\x32\x87\x7e" "\xa8\x1e\x24\xa5\x0c\x2e\x3f\x0f\xbc\x5b\x76\x36\x56\xb6\xc7\x27\x8c" "\xc8\x3a\x94\xc6\x5b\xbc\xa4\x31\xce\xfd\xe8\x88\xcd\x42\xb0\x32\x99" "\xb5\x91\xc7\x56\xac\xa3\x8f\x03\xca\x7a\x8f\x61\xaa\x9a\x69\xde\x2c" "\xa8\x1d\x7e\x50\x05\xfb\xd6\xc3\x28\x49\x3e\x28\x33\xd4\x5f\xcb\x68" "\xcd\xfa\x76\x18\x42\xb4\x8a\xeb\xf3\x57\x0c\xec\x22\x0d\xab\x6a\xb3" "\xb5\x8e\x12\x14\xcf\x84\x3b\x72\x01\xa8\x38\x70\x77\xb5\xc1\x46\x2f" "\x2b\x02\x5f\x9c\x6a\x56\xf8", 3339); *(uint64_t*)0x200000000c48 = 0xd0b; *(uint64_t*)0x200000008e18 = 5; *(uint64_t*)0x200000008e20 = 0; *(uint64_t*)0x200000008e28 = 0; *(uint32_t*)0x200000008e30 = 0; *(uint32_t*)0x200000008e38 = 0; syscall(__NR_sendmmsg, /*fd=*/r[1], /*mmsg=*/0x200000008dc0ul, /*vlen=*/2ul, /*f=*/0ul); break; case 7: *(uint32_t*)0x200000000bc0 = 1; syscall(__NR_setsockopt, /*fd=*/r[2], /*level=*/6, /*optname=*/0x14, /*optval=*/0x200000000bc0ul, /*optlen=*/4ul); break; case 8: *(uint32_t*)0x2000000001c0 = r[2]; *(uint32_t*)0x2000000001c4 = r[0]; syscall(__NR_ioctl, /*fd=*/r[1], /*cmd=*/0x89e0, /*arg=*/0x2000000001c0ul); break; case 9: syscall(__NR_write, /*fd=*/r[1], /*buf=*/0ul, /*count=*/0ul); break; case 10: syscall( __NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0xff5000ul, /*prot=*/0ul, /*flags=MAP_POPULATE|MAP_NORESERVE|MAP_NONBLOCK|MAP_HUGETLB|MAP_FIXED|0x2000000000822*/ 0x200000005c832ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); break; case 11: syz_clone(/*flags=*/0, /*stack=*/0x2000000007c0, /*stack_len=*/0, /*parentid=*/0, /*childtid=*/0, /*tls=*/0); 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); const char* reason; (void)reason; if ((reason = setup_usb())) printf("the reproducer may not work as expected: USB injection setup " "failed: %s\n", reason); if ((reason = setup_802154())) printf("the reproducer may not work as expected: 802154 injection setup " "failed: %s\n", reason); if ((reason = setup_swap())) printf("the reproducer may not work as expected: swap setup failed: %s\n", reason); for (procid = 0; procid < 4; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; }