// https://syzkaller.appspot.com/bug?id=edc431200af523909e1f15cb14ca4a5316a87e79 // 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 #ifndef __NR_memfd_create #define __NR_memfd_create 319 #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 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 //% This code is derived from puff.{c,h}, found in the zlib development. The //% original files come with the following copyright notice: //% Copyright (C) 2002-2013 Mark Adler, all rights reserved //% version 2.3, 21 Jan 2013 //% This software is provided 'as-is', without any express or implied //% warranty. In no event will the author be held liable for any damages //% arising from the use of this software. //% Permission is granted to anyone to use this software for any purpose, //% including commercial applications, and to alter it and redistribute it //% freely, subject to the following restrictions: //% 1. The origin of this software must not be misrepresented; you must not //% claim that you wrote the original software. If you use this software //% in a product, an acknowledgment in the product documentation would be //% appreciated but is not required. //% 2. Altered source versions must be plainly marked as such, and must not be //% misrepresented as being the original software. //% 3. This notice may not be removed or altered from any source distribution. //% Mark Adler madler@alumni.caltech.edu //% BEGIN CODE DERIVED FROM puff.{c,h} #define MAXBITS 15 #define MAXLCODES 286 #define MAXDCODES 30 #define MAXCODES (MAXLCODES + MAXDCODES) #define FIXLCODES 288 struct puff_state { unsigned char* out; unsigned long outlen; unsigned long outcnt; const unsigned char* in; unsigned long inlen; unsigned long incnt; int bitbuf; int bitcnt; jmp_buf env; }; static int puff_bits(struct puff_state* s, int need) { long val = s->bitbuf; while (s->bitcnt < need) { if (s->incnt == s->inlen) longjmp(s->env, 1); val |= (long)(s->in[s->incnt++]) << s->bitcnt; s->bitcnt += 8; } s->bitbuf = (int)(val >> need); s->bitcnt -= need; return (int)(val & ((1L << need) - 1)); } static int puff_stored(struct puff_state* s) { s->bitbuf = 0; s->bitcnt = 0; if (s->incnt + 4 > s->inlen) return 2; unsigned len = s->in[s->incnt++]; len |= s->in[s->incnt++] << 8; if (s->in[s->incnt++] != (~len & 0xff) || s->in[s->incnt++] != ((~len >> 8) & 0xff)) return -2; if (s->incnt + len > s->inlen) return 2; if (s->outcnt + len > s->outlen) return 1; for (; len--; s->outcnt++, s->incnt++) { if (s->in[s->incnt]) s->out[s->outcnt] = s->in[s->incnt]; } return 0; } struct puff_huffman { short* count; short* symbol; }; static int puff_decode(struct puff_state* s, const struct puff_huffman* h) { int first = 0; int index = 0; int bitbuf = s->bitbuf; int left = s->bitcnt; int code = first = index = 0; int len = 1; short* next = h->count + 1; while (1) { while (left--) { code |= bitbuf & 1; bitbuf >>= 1; int count = *next++; if (code - count < first) { s->bitbuf = bitbuf; s->bitcnt = (s->bitcnt - len) & 7; return h->symbol[index + (code - first)]; } index += count; first += count; first <<= 1; code <<= 1; len++; } left = (MAXBITS + 1) - len; if (left == 0) break; if (s->incnt == s->inlen) longjmp(s->env, 1); bitbuf = s->in[s->incnt++]; if (left > 8) left = 8; } return -10; } static int puff_construct(struct puff_huffman* h, const short* length, int n) { int len; for (len = 0; len <= MAXBITS; len++) h->count[len] = 0; int symbol; for (symbol = 0; symbol < n; symbol++) (h->count[length[symbol]])++; if (h->count[0] == n) return 0; int left = 1; for (len = 1; len <= MAXBITS; len++) { left <<= 1; left -= h->count[len]; if (left < 0) return left; } short offs[MAXBITS + 1]; offs[1] = 0; for (len = 1; len < MAXBITS; len++) offs[len + 1] = offs[len] + h->count[len]; for (symbol = 0; symbol < n; symbol++) if (length[symbol] != 0) h->symbol[offs[length[symbol]]++] = symbol; return left; } static int puff_codes(struct puff_state* s, const struct puff_huffman* lencode, const struct puff_huffman* distcode) { static const short lens[29] = {3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258}; static const short lext[29] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0}; static const short dists[30] = { 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577}; static const short dext[30] = {0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13}; int symbol; do { symbol = puff_decode(s, lencode); if (symbol < 0) return symbol; if (symbol < 256) { if (s->outcnt == s->outlen) return 1; if (symbol) s->out[s->outcnt] = symbol; s->outcnt++; } else if (symbol > 256) { symbol -= 257; if (symbol >= 29) return -10; int len = lens[symbol] + puff_bits(s, lext[symbol]); symbol = puff_decode(s, distcode); if (symbol < 0) return symbol; unsigned dist = dists[symbol] + puff_bits(s, dext[symbol]); if (dist > s->outcnt) return -11; if (s->outcnt + len > s->outlen) return 1; while (len--) { if (dist <= s->outcnt && s->out[s->outcnt - dist]) s->out[s->outcnt] = s->out[s->outcnt - dist]; s->outcnt++; } } } while (symbol != 256); return 0; } static int puff_fixed(struct puff_state* s) { static int virgin = 1; static short lencnt[MAXBITS + 1], lensym[FIXLCODES]; static short distcnt[MAXBITS + 1], distsym[MAXDCODES]; static struct puff_huffman lencode, distcode; if (virgin) { lencode.count = lencnt; lencode.symbol = lensym; distcode.count = distcnt; distcode.symbol = distsym; short lengths[FIXLCODES]; int symbol; for (symbol = 0; symbol < 144; symbol++) lengths[symbol] = 8; for (; symbol < 256; symbol++) lengths[symbol] = 9; for (; symbol < 280; symbol++) lengths[symbol] = 7; for (; symbol < FIXLCODES; symbol++) lengths[symbol] = 8; puff_construct(&lencode, lengths, FIXLCODES); for (symbol = 0; symbol < MAXDCODES; symbol++) lengths[symbol] = 5; puff_construct(&distcode, lengths, MAXDCODES); virgin = 0; } return puff_codes(s, &lencode, &distcode); } static int puff_dynamic(struct puff_state* s) { static const short order[19] = {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; int nlen = puff_bits(s, 5) + 257; int ndist = puff_bits(s, 5) + 1; int ncode = puff_bits(s, 4) + 4; if (nlen > MAXLCODES || ndist > MAXDCODES) return -3; short lengths[MAXCODES]; int index; for (index = 0; index < ncode; index++) lengths[order[index]] = puff_bits(s, 3); for (; index < 19; index++) lengths[order[index]] = 0; short lencnt[MAXBITS + 1], lensym[MAXLCODES]; struct puff_huffman lencode = {lencnt, lensym}; int err = puff_construct(&lencode, lengths, 19); if (err != 0) return -4; index = 0; while (index < nlen + ndist) { int symbol; int len; symbol = puff_decode(s, &lencode); if (symbol < 0) return symbol; if (symbol < 16) lengths[index++] = symbol; else { len = 0; if (symbol == 16) { if (index == 0) return -5; len = lengths[index - 1]; symbol = 3 + puff_bits(s, 2); } else if (symbol == 17) symbol = 3 + puff_bits(s, 3); else symbol = 11 + puff_bits(s, 7); if (index + symbol > nlen + ndist) return -6; while (symbol--) lengths[index++] = len; } } if (lengths[256] == 0) return -9; err = puff_construct(&lencode, lengths, nlen); if (err && (err < 0 || nlen != lencode.count[0] + lencode.count[1])) return -7; short distcnt[MAXBITS + 1], distsym[MAXDCODES]; struct puff_huffman distcode = {distcnt, distsym}; err = puff_construct(&distcode, lengths + nlen, ndist); if (err && (err < 0 || ndist != distcode.count[0] + distcode.count[1])) return -8; return puff_codes(s, &lencode, &distcode); } static int puff(unsigned char* dest, unsigned long* destlen, const unsigned char* source, unsigned long sourcelen) { struct puff_state s = { .out = dest, .outlen = *destlen, .outcnt = 0, .in = source, .inlen = sourcelen, .incnt = 0, .bitbuf = 0, .bitcnt = 0, }; int err; if (setjmp(s.env) != 0) err = 2; else { int last; do { last = puff_bits(&s, 1); int type = puff_bits(&s, 2); err = type == 0 ? puff_stored(&s) : (type == 1 ? puff_fixed(&s) : (type == 2 ? puff_dynamic(&s) : -1)); if (err != 0) break; } while (!last); } *destlen = s.outcnt; return err; } //% END CODE DERIVED FROM puff.{c,h} #define ZLIB_HEADER_WIDTH 2 static int puff_zlib_to_file(const unsigned char* source, unsigned long sourcelen, int dest_fd) { if (sourcelen < ZLIB_HEADER_WIDTH) return 0; source += ZLIB_HEADER_WIDTH; sourcelen -= ZLIB_HEADER_WIDTH; const unsigned long max_destlen = 132 << 20; void* ret = mmap(0, max_destlen, PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANON, -1, 0); if (ret == MAP_FAILED) return -1; unsigned char* dest = (unsigned char*)ret; unsigned long destlen = max_destlen; int err = puff(dest, &destlen, source, sourcelen); if (err) { munmap(dest, max_destlen); errno = -err; return -1; } if (write(dest_fd, dest, destlen) != (ssize_t)destlen) { munmap(dest, max_destlen); return -1; } return munmap(dest, max_destlen); } static int setup_loop_device(unsigned char* data, unsigned long size, const char* loopname, int* loopfd_p) { int err = 0, loopfd = -1; int memfd = syscall(__NR_memfd_create, "syzkaller", 0); if (memfd == -1) { err = errno; goto error; } if (puff_zlib_to_file(data, size, memfd)) { err = errno; goto error_close_memfd; } loopfd = open(loopname, O_RDWR); if (loopfd == -1) { err = errno; goto error_close_memfd; } if (ioctl(loopfd, LOOP_SET_FD, memfd)) { if (errno != EBUSY) { err = errno; goto error_close_loop; } ioctl(loopfd, LOOP_CLR_FD, 0); usleep(1000); if (ioctl(loopfd, LOOP_SET_FD, memfd)) { err = errno; goto error_close_loop; } } close(memfd); *loopfd_p = loopfd; return 0; error_close_loop: close(loopfd); error_close_memfd: close(memfd); error: errno = err; return -1; } static void reset_loop_device(const char* loopname) { int loopfd = open(loopname, O_RDWR); if (loopfd == -1) { return; } if (ioctl(loopfd, LOOP_CLR_FD, 0)) { } close(loopfd); } static long syz_mount_image(volatile long fsarg, volatile long dir, volatile long flags, volatile long optsarg, volatile long change_dir, volatile unsigned long size, volatile long image) { unsigned char* data = (unsigned char*)image; int res = -1, err = 0, need_loop_device = !!size; char* mount_opts = (char*)optsarg; char* target = (char*)dir; char* fs = (char*)fsarg; char* source = NULL; char loopname[64]; if (need_loop_device) { int loopfd; memset(loopname, 0, sizeof(loopname)); snprintf(loopname, sizeof(loopname), "/dev/loop%llu", procid); if (setup_loop_device(data, size, loopname, &loopfd) == -1) return -1; close(loopfd); source = loopname; } mkdir(target, 0777); char opts[256]; memset(opts, 0, sizeof(opts)); if (strlen(mount_opts) > (sizeof(opts) - 32)) { } strncpy(opts, mount_opts, sizeof(opts) - 32); if (strcmp(fs, "iso9660") == 0) { flags |= MS_RDONLY; } else if (strncmp(fs, "ext", 3) == 0) { bool has_remount_ro = false; char* remount_ro_start = strstr(opts, "errors=remount-ro"); if (remount_ro_start != NULL) { char after = *(remount_ro_start + strlen("errors=remount-ro")); char before = remount_ro_start == opts ? '\0' : *(remount_ro_start - 1); has_remount_ro = ((before == '\0' || before == ',') && (after == '\0' || after == ',')); } if (strstr(opts, "errors=panic") || !has_remount_ro) strcat(opts, ",errors=continue"); } else if (strcmp(fs, "xfs") == 0) { strcat(opts, ",nouuid"); } res = mount(source, target, fs, flags, opts); if (res == -1) { err = errno; goto error_clear_loop; } res = open(target, O_RDONLY | O_DIRECTORY); if (res == -1) { err = errno; goto error_clear_loop; } if (change_dir) { res = chdir(target); if (res == -1) { err = errno; } } error_clear_loop: if (need_loop_device) reset_loop_device(loopname); errno = err; return res; } #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_binderfs(); static void setup_fusectl(); static void sandbox_common_mount_tmpfs(void) { write_file("/proc/sys/fs/mount-max", "100000"); if (mkdir("./syz-tmp", 0777)) exit(1); if (mount("", "./syz-tmp", "tmpfs", 0, NULL)) exit(1); if (mkdir("./syz-tmp/newroot", 0777)) exit(1); if (mkdir("./syz-tmp/newroot/dev", 0700)) exit(1); unsigned bind_mount_flags = MS_BIND | MS_REC | MS_PRIVATE; if (mount("/dev", "./syz-tmp/newroot/dev", NULL, bind_mount_flags, NULL)) exit(1); if (mkdir("./syz-tmp/newroot/proc", 0700)) exit(1); if (mount("syz-proc", "./syz-tmp/newroot/proc", "proc", 0, NULL)) exit(1); if (mkdir("./syz-tmp/newroot/selinux", 0700)) exit(1); const char* selinux_path = "./syz-tmp/newroot/selinux"; if (mount("/selinux", selinux_path, NULL, bind_mount_flags, NULL)) { if (errno != ENOENT) exit(1); if (mount("/sys/fs/selinux", selinux_path, NULL, bind_mount_flags, NULL) && errno != ENOENT) exit(1); } if (mkdir("./syz-tmp/newroot/sys", 0700)) exit(1); if (mount("/sys", "./syz-tmp/newroot/sys", 0, bind_mount_flags, NULL)) exit(1); if (mount("/sys/kernel/debug", "./syz-tmp/newroot/sys/kernel/debug", NULL, bind_mount_flags, NULL) && errno != ENOENT) exit(1); if (mount("/sys/fs/smackfs", "./syz-tmp/newroot/sys/fs/smackfs", NULL, bind_mount_flags, NULL) && errno != ENOENT) exit(1); if (mount("/proc/sys/fs/binfmt_misc", "./syz-tmp/newroot/proc/sys/fs/binfmt_misc", NULL, bind_mount_flags, NULL) && errno != ENOENT) exit(1); initialize_cgroups(); if (mkdir("./syz-tmp/pivot", 0777)) exit(1); if (syscall(SYS_pivot_root, "./syz-tmp", "./syz-tmp/pivot")) { if (chdir("./syz-tmp")) exit(1); } else { if (chdir("/")) exit(1); if (umount2("./pivot", MNT_DETACH)) exit(1); } if (chroot("./newroot")) exit(1); if (chdir("/")) exit(1); setup_binderfs(); setup_fusectl(); } static void setup_fusectl() { if (mount(0, "/sys/fs/fuse/connections", "fusectl", 0, 0)) { } } static void setup_binderfs() { if (mkdir("/dev/binderfs", 0777)) { } if (mount("binder", "/dev/binderfs", "binder", 0, NULL)) { } } static void loop(); static void sandbox_common() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); if (getppid() == 1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = (200 << 20); setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 32 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 136 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); if (unshare(CLONE_NEWNS)) { } if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL)) { } if (unshare(CLONE_NEWIPC)) { } if (unshare(0x02000000)) { } if (unshare(CLONE_NEWUTS)) { } if (unshare(CLONE_SYSVSEM)) { } typedef struct { const char* name; const char* value; } sysctl_t; static const sysctl_t sysctls[] = { {"/proc/sys/kernel/shmmax", "16777216"}, {"/proc/sys/kernel/shmall", "536870912"}, {"/proc/sys/kernel/shmmni", "1024"}, {"/proc/sys/kernel/msgmax", "8192"}, {"/proc/sys/kernel/msgmni", "1024"}, {"/proc/sys/kernel/msgmnb", "1024"}, {"/proc/sys/kernel/sem", "1024 1048576 500 1024"}, }; unsigned i; for (i = 0; i < sizeof(sysctls) / sizeof(sysctls[0]); i++) write_file(sysctls[i].name, sysctls[i].value); } static int wait_for_loop(int pid) { if (pid < 0) exit(1); int status = 0; while (waitpid(-1, &status, __WALL) != pid) { } return WEXITSTATUS(status); } static void drop_caps(void) { struct __user_cap_header_struct cap_hdr = {}; struct __user_cap_data_struct cap_data[2] = {}; cap_hdr.version = _LINUX_CAPABILITY_VERSION_3; cap_hdr.pid = getpid(); if (syscall(SYS_capget, &cap_hdr, &cap_data)) exit(1); const int drop = (1 << CAP_SYS_PTRACE) | (1 << CAP_SYS_NICE); cap_data[0].effective &= ~drop; cap_data[0].permitted &= ~drop; cap_data[0].inheritable &= ~drop; if (syscall(SYS_capset, &cap_hdr, &cap_data)) exit(1); } static int do_sandbox_none(void) { if (unshare(CLONE_NEWPID)) { } int pid = fork(); if (pid != 0) return wait_for_loop(pid); 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(); 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 void setup_sysctl() { int cad_pid = fork(); if (cad_pid < 0) exit(1); if (cad_pid == 0) { for (;;) sleep(100); } char tmppid[32]; snprintf(tmppid, sizeof(tmppid), "%d", cad_pid); struct { const char* name; const char* data; } files[] = { {"/sys/kernel/debug/x86/nmi_longest_ns", "10000000000"}, {"/proc/sys/kernel/hung_task_check_interval_secs", "20"}, {"/proc/sys/net/core/bpf_jit_kallsyms", "1"}, {"/proc/sys/net/core/bpf_jit_harden", "0"}, {"/proc/sys/kernel/kptr_restrict", "0"}, {"/proc/sys/kernel/softlockup_all_cpu_backtrace", "1"}, {"/proc/sys/fs/mount-max", "100"}, {"/proc/sys/vm/oom_dump_tasks", "0"}, {"/proc/sys/debug/exception-trace", "0"}, {"/proc/sys/kernel/printk", "7 4 1 3"}, {"/proc/sys/kernel/keys/gc_delay", "1"}, {"/proc/sys/vm/oom_kill_allocating_task", "1"}, {"/proc/sys/kernel/ctrl-alt-del", "0"}, {"/proc/sys/kernel/cad_pid", tmppid}, }; for (size_t i = 0; i < sizeof(files) / sizeof(files[0]); i++) { if (!write_file(files[i].name, files[i].data)) { } } kill(cad_pid, SIGKILL); while (waitpid(cad_pid, NULL, 0) != cad_pid) ; } 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 < 6; 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[1] = {0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x20000280, "exfat\000", 6); memcpy((void*)0x200000c0, "./file2\000", 8); memcpy( (void*)0x200002c0, "\x78\x9c\xec\xdc\x09\xb8\x4f\x55\xf7\x38\xf0\xb5\xf6\xde\x87\xeb\x66" "\xf8\x26\x99\xcf\xda\xeb\xf0\x4d\x86\x4d\x92\x84\x92\x64\x48\x92\x24" "\x24\x73\x42\x92\x24\x49\x92\xb8\x64\x4a\x42\x12\x32\xde\x24\x73\xc8" "\x9c\x6e\xba\xe6\x79\xc8\x9c\x74\xf3\x4a\x92\x24\x24\x24\xd9\xff\xe7" "\x36\xfc\xfd\x7a\x87\x9f\xf7\x7d\x7f\xfd\xfe\xfa\xbf\x77\x7d\x9e\xe7" "\x3c\xf6\x72\xce\xda\x67\xed\xbb\x9e\xef\x3d\xc3\xf3\xdc\xef\xd7\x5d" "\x87\x55\x6f\x54\xa3\x4a\x7d\x66\x86\x7f\x87\xfe\x6d\x80\xbf\xfc\x93" "\x04\x00\x09\x00\x30\x10\x00\x72\x00\x40\x00\x00\x65\x73\x96\xcd\x99" "\xbe\x3f\x8b\xc6\xa4\x7f\xeb\x24\xe2\x7f\x49\x83\x19\x57\xba\x02\x71" "\x25\x49\xff\x33\x36\xe9\x7f\xc6\x26\xfd\xcf\xd8\xa4\xff\x19\x9b\xf4" "\x3f\x63\x93\xfe\x67\x6c\xd2\xff\x8c\x4d\xfa\x2f\x44\x86\x36\x2b\xdf" "\xd5\xb2\x65\xdc\x4d\xde\xff\xff\x7f\x4e\xfd\x4f\x92\xe5\xfa\x9f\x21" "\xe0\x3f\xda\x21\xfd\xff\x4f\xa3\xff\xa5\xa3\xa5\xff\x19\x9b\xf4\x3f" "\x63\x93\xfe\x67\x6c\xd2\xff\x8c\x2c\xb8\xd2\x05\x88\x2b\x4c\x3e\xff" "\x19\x9b\xf4\x5f\x88\x0c\xed\x0f\x7f\xa7\xbc\xe1\xdc\x95\x7e\xa7\x2d" "\xdb\xbf\xb0\x09\x21\x84\x10\x42\x08\x21\x84\x10\x42\x08\x21\x84\x10" "\x42\x08\x21\x84\x10\x42\x08\x21\x84\x10\x42\x08\x21\x84\x10\x42\x08" "\x21\x84\x10\x42\x08\x21\x84\x10\x42\x08\x21\x84\x10\x42\x08\x21\x84" "\x10\x42\x08\x21\x84\x10\x42\x08\x21\x84\x10\x42\x08\x21\x84\x10\x42" "\x08\x21\x84\x10\x42\x08\x21\x84\x10\x42\x08\x21\x84\x10\x42\x08\x21" "\x84\x10\x42\x08\x21\x84\x10\x42\x08\x21\x84\x10\x42\x08\x21\x84\x10" "\x42\x08\x21\x84\x10\x42\x08\x21\x84\x10\x42\x08\x21\x84\x10\x42\x08" "\x21\x84\x10\x42\x08\x21\x84\x10\x42\x08\x21\x84\x10\xff\x0f\x9c\xf3" "\x97\x18\x00\xf8\x6d\x7c\xa5\xeb\x12\x42\x08\x21\x84\x10\x42\x08\x21" "\xc4\x1f\xc7\xbf\x7b\xa5\x2b\x10\x42\x08\x21\x84\x10\x42\x08\x21\xc4" "\xff\x3e\x04\x05\x1a\x0c\x04\x90\x09\x32\x43\x02\x64\x81\x44\xb8\x0a" "\xb2\x42\x36\xc8\x0e\x39\x20\x06\x57\x43\x4e\xb8\x06\x72\xc1\xb5\x90" "\x1b\xf2\x40\x5e\xc8\x07\xf9\xa1\x00\x14\x84\x10\x08\x2c\x30\x44\x50" "\x08\x0a\x43\x1c\xae\x83\x22\x70\x3d\x14\x85\x62\x50\x1c\x4a\x80\x83" "\x92\x50\x0a\x6e\x80\xd2\x70\x23\x94\x81\x9b\xa0\x2c\xdc\x0c\xe5\xe0" "\x16\x28\x0f\x15\x7e\x3e\x67\xba\xdb\xa1\x32\xdc\x01\x55\xe0\x4e\xa8" "\x0a\xd5\xa0\x3a\xd4\x80\xbb\xa0\x26\xdc\x0d\xb5\xe0\x1e\xa8\x0d\xf7" "\x42\x1d\xb8\x0f\xea\xc2\xfd\x50\x0f\x1e\x80\xfa\xd0\x00\x1a\xc2\x83" "\xd0\x08\x1e\x82\xc6\xd0\x04\x9a\x42\x33\x68\x0e\x2d\xa0\xe5\x65\xf2" "\x93\x73\xfc\xbd\xfc\xe7\xa1\x07\xbc\x00\x3d\xa1\x17\x24\x41\x6f\xe8" "\x03\x2f\x42\x5f\xe8\x07\xfd\x61\x00\x0c\x84\x97\x60\x10\xbc\x0c\x83" "\xe1\x15\x18\x02\x43\x61\x18\xbc\x0a\xc3\xe1\x35\x18\x01\xaf\xc3\x48" "\x18\x05\xa3\xe1\x0d\x18\x03\x63\x61\x1c\x8c\x87\x09\x30\x11\x92\xe1" "\x4d\x98\x04\x6f\xc1\x64\x78\xfb\xa1\x6c\x30\x15\xa6\xc1\x74\x98\x01" "\x33\x61\x16\xbc\x03\xb3\x61\x0e\xcc\x85\x77\x61\x1e\xcc\x87\x05\x90" "\x9c\x65\x11\x2c\x86\x25\xf0\x1e\x2c\x85\xf7\x21\x05\x3e\x80\x65\xf0" "\x21\xa4\xc2\x72\x58\x01\x2b\x61\x15\xac\x86\x35\xb0\x16\xd6\xc1\x7a" "\xd8\x00\x1b\x61\x13\x6c\x86\x2d\xb0\x15\xb6\xc1\x47\xb0\x1d\x76\xc0" "\x4e\xd8\x05\xbb\x61\x0f\xec\x85\x8f\x61\x1f\x7c\x02\xfb\xe1\x53\x48" "\xc3\xcf\xfe\xc5\xfc\xb3\xbf\xcf\x87\x6e\x08\x08\xa8\x50\xa1\x41\x83" "\x99\x30\x13\x26\x60\x02\x26\x62\x22\x66\xc5\xac\x98\x1d\xb3\x63\x0c" "\x63\x98\x13\x73\x62\x2e\xcc\x85\xb9\x31\x37\xe6\xc5\xbc\x98\x84\xf9" "\xb1\x20\x16\x44\x42\x42\x46\xc6\x42\x58\x08\xe3\x18\xc7\x22\x58\x04" "\x8b\x62\x51\x2c\x8e\xc5\xd1\xa1\xc3\x52\x58\x0a\x4b\xe3\x8d\x58\x06" "\xcb\x60\x59\x2c\x8b\xe5\xb0\x1c\x96\xc7\x0a\x58\x01\x6f\xc5\x5b\xb1" "\x12\x56\xc2\xca\x58\x19\xab\x60\x15\xac\x8a\x55\xb1\x3a\x56\xc7\xbb" "\xf0\x2e\xbc\x1b\x6b\x61\x2d\xac\x8d\xb5\xb1\x0e\xd6\xc1\xba\x58\x17" "\xeb\x61\x3d\xac\x8f\xf5\xb1\x21\x36\xc4\x46\xd8\x08\x1b\x63\x63\x6c" "\x8a\x4d\xb1\x39\x36\xc7\x96\xd8\x12\x5b\x61\x2b\x6c\x8d\xad\xb1\x2d" "\xb6\xc5\x76\xd8\x0e\xdb\x63\x7b\xec\x80\x1d\xb0\x23\x76\xc4\x4e\xd8" "\x09\x3b\x63\x67\xec\x82\x5d\xb0\x2b\x76\xc5\x6e\xf8\x1c\x3e\x87\xcf" "\xe3\xf3\xf8\x02\xbe\x80\xbd\xb0\xaa\xea\x8d\x7d\xb0\x0f\xf6\xc5\xbe" "\xd8\x1f\x07\xe0\x00\x7c\x09\x07\xe1\xcb\xf8\x32\xbe\x82\x43\x70\x28" "\x0e\xc3\x57\xf1\x55\x7c\x0d\x47\xe0\x19\x1c\x89\xa3\x70\x34\x8e\xc6" "\x4a\x6a\x2c\x8e\xc3\xf1\xc8\x6a\x22\x26\x63\x32\x66\x86\x49\x38\x19" "\x27\xe3\x14\x9c\x8a\x53\x71\x3a\xce\xc0\x99\x38\x0b\x67\xe1\x6c\x9c" "\x83\x73\xf0\x5d\x9c\x87\xf3\x71\x3e\x2e\xc4\x85\xb8\x18\x97\xe0\x12" "\x5c\x8a\xef\x63\x0a\xa6\xe0\x32\x3c\x8b\xa9\xb8\x1c\x57\xe0\x4a\x5c" "\x85\xab\x71\x15\xae\xc5\x75\xb8\x16\x37\xe0\x46\xdc\x80\x9b\x71\x33" "\x6e\xc5\xad\xf8\x11\x7e\x84\x3b\x70\x07\xee\xc2\x5d\xb8\x07\xf7\xe0" "\xc7\xf8\x31\x7e\x82\x9f\xe0\x10\x4c\xc3\x34\x3c\x80\x07\xf0\x20\x1e" "\xc4\x43\x78\x08\x0f\xe3\x61\x3c\x82\x47\xf0\x28\x1e\xc5\x63\x78\x0c" "\x8f\xe3\x71\x3c\x81\x27\xf1\x14\x9e\xc4\xd3\x78\x1a\xcf\xe0\x59\x3c" "\x07\x00\xe7\xf1\x3c\x5e\xc0\x0b\x78\x11\x2f\xa6\x7f\xf8\x55\x3a\xa3" "\x8c\xca\xa4\x32\xa9\x04\x95\xa0\x12\x55\xa2\xca\xaa\xb2\xaa\xec\x2a" "\xbb\x8a\xa9\x98\xca\xa9\x72\xaa\x5c\x2a\x97\xca\xad\x72\xab\xbc\x2a" "\xaf\xca\xaf\xf2\xab\x82\xaa\xa0\x22\x45\x8a\x55\xa4\x0a\xa9\x42\x2a" "\xae\xe2\xaa\x88\x2a\xa2\x8a\xaa\xa2\xaa\xb8\x2a\xae\x9c\x72\xaa\x94" "\x2a\xa5\x4a\xab\xd2\xaa\x8c\x2a\xa3\xca\xaa\x9b\x55\x39\x75\x8b\x2a" "\xaf\x2a\xa8\x36\xee\x56\x75\xab\xaa\xa4\xda\xba\xca\xea\x0e\x55\x45" "\x55\x51\x55\x55\x35\x55\x5d\xd5\x50\x35\x54\x4d\x55\x53\xd5\x52\xb5" "\x54\x6d\x55\x5b\xd5\x51\x75\x54\x5d\x75\xbf\xaa\xa7\x7a\x63\x7f\x6c" "\xa0\xd2\x3b\xd3\x48\x0d\xc5\xc6\x6a\x18\x36\x55\xcd\x54\x73\xd5\x42" "\xbd\x86\x0f\xab\x56\x6a\x04\xb6\x56\x6d\x54\x5b\xf5\xa8\x1a\x85\x23" "\xb1\xbd\x6a\xe5\x3a\xa8\x27\x54\x47\x35\x0e\x3b\xa9\xa7\xd4\x78\x7c" "\x5a\x75\x51\x13\xb1\xab\x7a\x56\x75\x53\xcf\xa9\xee\xea\x79\xd5\x43" "\xb5\x76\x3d\x55\x2f\x35\x05\x7b\xab\x3e\x6a\x3a\xf6\x55\xfd\x54\x7f" "\x35\x40\xcd\xc6\x6a\x2a\xbd\x63\xd5\xd5\x2b\xea\xf9\xcc\x43\xd5\x30" "\xf5\xaa\x5a\x8c\xaf\xa9\x11\xea\x75\x35\x52\x8d\x52\xa3\xd5\x1b\x6a" "\x8c\x1a\xab\xc6\xa9\xf1\x6a\x82\x9a\xa8\x92\xd5\x9b\x6a\x92\x7a\x4b" "\x4d\x56\x6f\xab\x29\x6a\xaa\x9a\xa6\xa6\xab\x19\x6a\xa6\x9a\xa5\xde" "\x51\xb3\xd5\x1c\x35\x57\xbd\xab\xe6\xa9\xf9\x6a\x81\x5a\xa8\x16\xa9" "\xc5\x6a\x89\x7a\x4f\x2d\x55\xef\xab\x14\xf5\x81\x5a\xa6\x3e\x54\xa9" "\x6a\xb9\x5a\xa1\x56\xaa\x55\x6a\xb5\x5a\xa3\xd6\xaa\x75\x6a\xbd\xda" "\xa0\x36\xaa\x4d\x6a\xb3\xda\xa2\xb6\xaa\x6d\xea\x23\xb5\x5d\xed\x50" "\x3b\xd5\x2e\xb5\x5b\xed\x51\x7b\xd5\xc7\x6a\x9f\xfa\x44\xed\x57\x9f" "\xaa\x34\xf5\x99\x3a\xa0\xfe\xa2\x0e\xaa\xcf\xd5\x21\xf5\x85\x3a\xac" "\xbe\x54\x47\xd4\x57\xea\xa8\xfa\x5a\x1d\x53\xdf\xa8\xe3\xea\x5b\x75" "\x42\x9d\x54\xa7\xd4\x77\xea\xb4\xfa\x5e\x9d\x51\x67\xd5\x39\xf5\x83" "\x3a\xaf\x7e\x54\x17\xd4\x4f\xea\xa2\xf2\x0a\x34\x6a\xa5\xb5\x36\x3a" "\xd0\x99\x74\x66\x9d\xa0\xb3\xe8\x44\x7d\x95\xce\xaa\xb3\xe9\xec\x3a" "\x87\x8e\xe9\xab\x75\x4e\x7d\x8d\xce\xa5\xaf\xd5\xb9\x75\x1e\x9d\xd7" "\xe4\xd3\xf9\x75\x01\x5d\x50\x87\x9a\xb4\xd5\xac\x23\x5d\x48\x17\xd6" "\x71\x7d\x9d\x2e\xa2\xaf\xd7\x45\x75\x31\x5d\x5c\x97\xd0\x4e\x97\xd4" "\xa5\xf4\x0d\xba\xb4\xbe\x51\x97\xd1\x37\xe9\xb2\xfa\x66\x5d\x4e\xdf" "\xa2\xcb\xeb\x0a\xba\xa2\x07\x7d\x9b\xae\xa4\x6f\xd7\x95\xf5\x1d\xba" "\x8a\xbe\x53\x57\xd5\xd5\x74\x75\x5d\x43\xdf\xa5\x6b\xea\xbb\x75\x2d" "\x7d\x8f\xae\xad\xef\xd5\x75\xf4\x7d\xba\xae\xbe\x5f\xd7\xd3\x0f\xe8" "\xfa\xba\x81\x6e\xa8\x1f\xd4\x8d\xf4\x43\xba\xb1\x6e\xa2\x9b\xea\x66" "\xba\xb9\x6e\xa1\x5b\xea\x87\x75\x2b\xfd\x88\x6e\xad\xdb\xe8\xb6\xfa" "\x51\xdd\x4e\x3f\xa6\xdb\xeb\xc7\x75\x07\xfd\x84\xee\xa8\x9f\xd4\x9d" "\xf4\x53\xba\xb3\x7e\x5a\x77\xd1\xcf\xe8\xae\xfa\x59\xdd\x4d\x3f\xa7" "\xbb\xeb\x9f\xf4\x45\xed\x75\x4f\xdd\x4b\x27\xe9\xde\xba\x8f\x7e\x51" "\xf7\xd5\xfd\x74\x7f\x3d\x40\x0f\xd4\x2f\xe9\x41\xfa\x65\x3d\x58\xbf" "\xa2\x87\xe8\xa1\x7a\x98\x7e\x55\x0f\xd7\xaf\xe9\x11\xfa\x75\x3d\x52" "\x8f\xd2\xa3\xf5\x1b\x7a\x8c\x1e\xab\xc7\xe9\xf1\x7a\x82\x9e\xa8\x93" "\xf5\x9b\x7a\x92\x7e\x4b\x4f\xd6\x6f\xeb\x29\x7a\xaa\x9e\xa6\xa7\xeb" "\x19\x7a\xa6\xee\xff\xeb\x4c\x73\xff\x89\xfc\xb7\xfe\x4e\xfe\xe0\x9f" "\xcf\xbe\x55\x6f\xd3\x1f\xe9\xed\x7a\x87\xde\xa9\x77\xe9\xdd\x7a\x8f" "\xde\xab\xf7\xea\x7d\x7a\x9f\xde\xaf\xf7\xeb\x34\x9d\xa6\x0f\xe8\x03" "\xfa\xa0\x3e\xa8\x0f\xe9\x43\xfa\xb0\x3e\xac\x8f\xe8\x23\xfa\xa8\x3e" "\xaa\x8f\xe9\x63\xfa\xb8\x3e\xae\x4f\xe8\x93\xfa\x07\xfd\x9d\x3e\xad" "\xbf\xd7\x67\xf4\x59\x7d\x56\xff\xa0\xcf\xeb\xf3\xfa\xc2\xaf\x3f\x03" "\x30\x68\x94\xd1\xc6\x98\xc0\x64\x32\x99\x4d\x82\xc9\x62\x12\xcd\x55" "\x26\xab\xc9\x66\xb2\x9b\x1c\x26\x66\xae\x36\x39\xcd\x35\x26\x97\xb9" "\xd6\xe4\x36\x79\x4c\x5e\x93\xcf\xe4\x37\x05\x4c\x41\x13\x1a\x32\xd6" "\xb0\x89\x4c\x21\x53\xd8\xc4\xcd\x75\xa6\x88\xb9\xde\x14\x35\xc5\x4c" "\x71\x53\xc2\x38\x53\xd2\x94\x32\x37\xfc\x8f\xf3\x2f\x57\x5f\x4b\xd3" "\xd2\xb4\x32\xad\x4c\x6b\xd3\xda\xb4\x35\x6d\x4d\x3b\xd3\xce\xb4\x37" "\xed\x4d\x07\xd3\xc1\x74\x34\x1d\x4d\x27\xd3\xc9\x74\x36\x9d\x4d\x17" "\xd3\xc5\x74\x35\x5d\x4d\x37\xd3\xcd\x74\x37\xdd\x4d\x0f\xd3\xc3\xf4" "\x34\x3d\x4d\x92\x49\x32\x7d\xcc\x8b\xa6\xaf\xe9\x67\xfa\x9b\x01\x66" "\xa0\x79\xc9\x0c\x32\x83\xcc\x60\x33\xd8\x0c\x31\x43\xcc\x30\x33\xcc" "\x0c\x37\xc3\xcd\x08\x33\xc2\x8c\x34\x23\xcd\x68\x33\xda\x8c\x31\x63" "\xcc\x38\x33\xce\x4c\x30\x13\x4c\xb2\xcf\x61\x26\x99\x49\x66\xb2\x99" "\x6c\xa6\x98\x29\x66\xda\xc0\x1c\x66\x86\x99\x61\x66\x99\x59\x66\xb6" "\x99\x6d\xe6\x9a\xb9\x66\x9e\x99\x67\x16\x98\x05\x66\x91\x59\x64\x96" "\x98\x25\x66\xa9\x59\x6a\x52\x4c\x8a\x59\x66\x96\x99\x54\xb3\xdc\x2c" "\x37\x2b\xcd\x4a\xb3\xda\xac\x36\x6b\xcd\x5a\xb3\xde\xac\x37\x1b\xcd" "\x46\xb3\xd9\x6c\x36\xa9\x66\x9b\xd9\x66\xb6\x9b\xed\x66\xa7\xd9\x69" "\x76\x9b\xdd\x66\xaf\xd9\x6b\xf6\x99\x7d\x66\xbf\xd9\x6f\xd2\x4c\x9a" "\x39\x60\x0e\x98\x83\xe6\xa0\x39\x64\x0e\x99\xc3\xe6\xb0\x39\x62\x8e" "\x98\xa3\xe6\xa8\x39\x66\x8e\x99\xe3\xe6\xb8\x39\x61\x4e\x98\x53\xe6" "\x94\x39\x6d\x4e\x9b\x33\xe6\x8c\x39\x67\xce\x99\xf3\xe6\xbc\xb9\x60" "\x2e\x98\x8b\xe6\x62\xfa\x6d\x5f\xa0\x02\x15\x98\xc0\x04\x99\x82\x4c" "\x41\x42\x90\x10\x24\x06\x89\x41\xd6\x20\x6b\x90\x3d\xc8\x1e\xc4\x82" "\x58\x90\x33\xc8\x19\xe4\x0a\xae\x0d\x72\x07\x79\x82\xbc\x41\xbe\x20" "\x7f\x50\x20\x28\x18\x84\x01\x05\x36\xe0\x20\x0a\x0a\x05\x85\x83\x78" "\x70\x5d\x50\x24\xb8\x3e\x28\x1a\x14\x0b\x8a\x07\x25\x02\x17\x94\x0c" "\x4a\x05\x37\x04\xa5\x83\x1b\x83\x32\xc1\x4d\x41\xd9\xe0\xe6\xa0\x5c" "\x70\x4b\x50\x3e\xa8\x10\x54\x0c\x6e\x0d\x6e\x0b\x2a\x05\xb7\x07\x95" "\x83\x3b\x82\x2a\xc1\x9d\x41\xd5\xa0\x5a\x50\x3d\xa8\x11\xdc\x15\xd4" "\x0c\xee\x0e\x6a\x05\xf7\x04\xb5\x83\x7b\x83\x3a\xc1\x7d\x41\xdd\xe0" "\xfe\xa0\x5e\xf0\x40\x50\x3f\x68\x10\x34\x0c\x1e\x0c\x1a\x05\x0f\x05" "\x8d\x83\x26\x41\xd3\xa0\x59\xd0\x3c\x68\x11\xb4\xfc\x43\xe7\xf7\xfe" "\x4c\x9e\x47\x5c\xcf\xb0\x57\x98\x14\xf6\x0e\xfb\x84\x2f\x86\x7d\xc3" "\x7e\x61\xff\x70\x40\x38\x30\x7c\x29\x1c\x14\xbe\x1c\x0e\x0e\x5f\x09" "\x87\x84\x43\xc3\x61\xe1\xab\xe1\xf0\xf0\xb5\x70\x44\xf8\x7a\x38\x32" "\x1c\x15\x8e\x0e\xdf\x08\xc7\x84\x63\xc3\x71\xe1\xf8\x70\x42\x38\x31" "\x4c\x0e\xdf\x0c\x27\x85\x6f\x85\x93\xc3\xb7\xc3\x29\xe1\xd4\x70\x5a" "\x30\x3d\x9c\x11\xce\x0c\x67\x85\xef\x84\xb3\xc3\x39\xe1\xdc\xf0\xdd" "\x70\x5e\x38\x3f\x5c\x10\x2e\x0c\x17\x85\x8b\x43\xfc\xe5\x96\x18\x52" "\xc2\x0f\xc2\x65\xe1\x87\x61\x6a\xb8\x3c\x5c\x11\xae\x0c\x57\x85\xab" "\xc3\x35\xe1\xda\x70\x5d\xb8\x3e\xdc\x10\x6e\x0c\x37\x85\x9b\xcb\x0e" "\xfa\xe5\xd0\x70\x7b\xb8\x23\xdc\x19\xee\x0a\x77\x87\x7b\xc2\xbd\xe1" "\xc7\xe1\xbe\xf0\x93\x70\x7f\xf8\x69\x98\x16\x7e\x16\x1e\x08\xff\x12" "\x1e\x0c\x3f\x0f\x0f\x85\x5f\x84\x87\xc3\x2f\xc3\x23\xe1\x57\xe1\xd1" "\xf0\xeb\xf0\x58\xf8\x4d\x78\x3c\xfc\x36\x3c\x11\x9e\x0c\x4f\x85\xdf" "\x85\xa7\xc3\xef\xc3\x33\xe1\xd9\xf0\x5c\xf8\x43\x78\x3e\xfc\x31\xbc" "\x10\xfe\x14\x5e\x0c\x7d\xfa\xcd\x7d\xfa\xe5\x9d\x0c\x19\xca\x44\x99" "\x28\x81\x12\x28\x91\x12\x29\x2b\x65\xa5\xec\x94\x9d\x62\x14\xa3\x9c" "\x94\x93\x72\x51\x2e\xca\x4d\xb9\x29\x2f\xe5\xa5\xfc\x94\x9f\x0a\x52" "\x41\x4a\xc7\xc4\x54\x88\x0a\x51\x9c\xe2\x54\x84\x8a\x50\x51\x2a\x4a" "\xc5\xa9\x38\x39\x72\x54\x8a\x4a\x51\x69\x2a\x4d\x65\xa8\x0c\x95\xa5" "\xb2\x54\x8e\xca\x51\x79\x2a\x4f\x15\xa9\x22\xdd\x46\xb7\xd1\xed\x74" "\x3b\xdd\x41\x77\xd0\x9d\x74\x27\x55\xa3\x6a\x54\x83\x6a\x50\x4d\xaa" "\x49\xb5\xa8\x16\xd5\xa6\xda\x54\x87\xea\x50\x5d\xaa\x4b\xf5\xa8\x1e" "\xd5\xa7\xfa\xd4\x90\x1a\x52\x23\x6a\x44\x8d\xa9\x31\x35\xa5\xa6\xd4" "\x9c\x9a\x53\x4b\x6a\x49\xad\xa8\x15\xb5\xa6\xd6\xd4\x96\xda\x52\x3b" "\x6a\x47\xed\xa9\x3d\x75\xa0\x0e\xd4\x91\x3a\x52\x27\xea\x44\x9d\xa9" "\x33\x75\xa1\x2e\xd4\x95\xba\x52\x37\xea\x46\xdd\xa9\x3b\xf5\xa0\x1e" "\xd4\x93\x7a\x52\x12\x25\x51\x1f\xea\x43\x7d\xa9\x2f\xf5\xa7\xfe\x34" "\x90\x06\xd2\x20\x1a\x44\x83\x69\x30\x0d\xa1\x21\x34\x8c\x86\xd1\x70" "\x1a\x4e\x23\x68\x04\x8d\xa4\x51\x34\x9a\xde\xa0\x31\x34\x96\xc6\xd1" "\x78\x9a\x40\x13\x29\x99\x92\x69\x12\x4d\xa2\xc9\x34\x99\xa6\xd0\x14" "\x9a\x46\xd3\x68\x06\xcd\xa0\x59\x34\x8b\x66\xd3\x6c\x9a\x4b\x73\x69" "\x1e\xcd\xa3\x05\xb4\x80\x16\xd1\x22\x5a\x42\x4b\x68\x29\x2d\xa5\x14" "\x4a\xa1\x65\xb4\x8c\x52\x29\x95\x56\xd0\x0a\x5a\x45\xab\x68\x0d\xad" "\xa1\x75\xb4\x8e\x36\xd0\x06\xda\x44\x9b\x68\x0b\x6d\xa1\x6d\xb4\x8d" "\xb6\xd3\x76\xda\x49\x3b\x69\x37\xed\xa6\xbd\xb4\x97\xf6\xd1\x3e\xda" "\x4f\xfb\x29\x8d\xd2\xe8\x00\x1d\xa0\x83\x74\x90\x0e\xd1\x21\x3a\x4c" "\x87\xe9\x08\x1d\xa1\xa3\x74\x94\x8e\xd1\x31\x3a\x4e\xc7\xe9\x04\x9d" "\xa0\x53\x74\x8a\x4e\xd3\x69\x3a\x43\x67\xe8\x1c\x9d\xa3\xf3\xf4\x23" "\x5d\xa0\x9f\xe8\x22\x79\x4a\xb0\x59\x6c\xa2\xbd\xca\x66\xb5\xd9\x6c" "\x76\x9b\xc3\xfe\x75\x9c\xd7\xe6\xb3\xf9\x6d\x01\x5b\xd0\x86\x36\xb7" "\xcd\xf3\xbb\x98\xac\xb5\x45\x6d\x31\x5b\xdc\x96\xb0\xce\x96\xb4\xa5" "\xec\x0d\x7f\x13\x97\xb7\x15\x6c\x45\x7b\xab\xbd\xcd\x56\xb2\xb7\xdb" "\xca\xb6\xbc\xcd\x02\xff\x35\xae\x69\xef\xb6\xb5\xec\x3d\xb6\xb6\xbd" "\xd7\xd6\xb0\x77\xfd\x2e\xae\x63\xef\xb3\x75\xed\x43\xb6\x9e\x6d\x62" "\xeb\xdb\x66\xb6\xa1\x6d\x61\x1b\xd9\x87\x6c\x63\xdb\xc4\x36\xb5\xcd" "\x6c\x73\xdb\xc2\xb6\xb3\x8f\xd9\xf6\xf6\x71\xdb\xc1\x3e\x61\x3b\xda" "\x27\xff\x26\x5e\x6a\xdf\xb7\xeb\xec\x7a\xbb\xc1\x6e\xb4\xfb\xec\x27" "\xf6\x9c\xfd\xc1\x1e\xb5\x5f\xdb\xf3\xf6\x47\xdb\xd3\xf6\xb2\x03\xed" "\x4b\x76\x90\x7d\xd9\x0e\xb6\xaf\xd8\x21\x76\xe8\xef\x63\x00\x3b\xda" "\xbe\x61\xc7\xd8\xb1\x76\x9c\x1d\x6f\x27\xd8\x89\x7f\x13\x4f\xb3\xd3" "\xed\x0c\x3b\xd3\xce\xb2\xef\xd8\xd9\x76\xce\xdf\xc4\x4b\xec\x7b\x76" "\x9e\x4d\xb1\x0b\xec\x42\xbb\xc8\x2e\xfe\x39\x4e\xaf\x29\xc5\x7e\x60" "\x97\xd9\x0f\x6d\xaa\x5d\x6e\x57\xd8\x95\x76\x95\x5d\x6d\xd7\xd8\xb5" "\xff\xb7\xd6\x95\x76\xb3\xdd\x62\xb7\xda\xbd\xf6\x63\xbb\xdd\xee\xb0" "\x3b\xed\x2e\xbb\xdb\xee\xf9\x39\x4e\x5f\xc7\x7e\xfb\xa9\x4d\xb3\x9f" "\xd9\x23\xf6\x2b\x7b\xd0\x7e\x6e\x0f\xd9\x63\xf6\xb0\xfd\xf2\xe7\x38" "\x7d\x7d\xc7\xec\x37\xf6\xb8\xfd\xd6\x9e\xb0\x27\xed\x29\xfb\x9d\x3d" "\x6d\xbf\xb7\x67\xec\xd9\x9f\xd7\x9f\xbe\xf6\xef\xec\x4f\xf6\xa2\xf5" "\x16\x18\x59\xb1\x66\xc3\x01\x67\xe2\xcc\x9c\xc0\x59\x38\x91\xaf\xe2" "\xac\x9c\x8d\xb3\x73\x0e\x8e\xf1\xd5\x9c\x93\xaf\xe1\x5c\x7c\x2d\xe7" "\xe6\x3c\x9c\x97\xf3\x71\x7e\x2e\xc0\x05\x39\x64\x62\xcb\xcc\x11\x17" "\xe2\xc2\x1c\xe7\xeb\xb8\x08\x5f\xcf\x45\xb9\x18\x17\xe7\x12\xec\xb8" "\x24\x97\xe2\x1b\xb8\x34\xdf\xc8\x65\xf8\x26\x2e\xcb\x37\x73\x39\xbe" "\x85\xcb\x73\x05\xae\xc8\xb7\xf2\x6d\x5c\x89\x6f\xe7\xca\x7c\x07\x57" "\xe1\x3b\xb9\x2a\x57\xe3\xea\x5c\x83\xef\xe2\x9a\x7c\x37\xd7\xe2\x7b" "\xb8\x36\xdf\xcb\x75\xf8\x3e\xae\xcb\xf7\x73\x3d\x7e\x80\xeb\x73\x03" "\x6e\xc8\x0f\x72\x23\x7e\x88\x1b\x73\x13\x6e\xca\xcd\xb8\x39\xb7\xe0" "\x96\xfc\x30\xb7\xe2\x47\xb8\x35\xb7\xe1\xb6\xfc\x28\xb7\xe3\xc7\xb8" "\x3d\x3f\xce\x1d\xf8\x09\xee\xc8\x4f\x72\x27\x7e\x8a\x3b\xf3\xd3\xdc" "\x85\x9f\xe1\xae\xfc\x2c\x77\xe3\xe7\xb8\x3b\x3f\xcf\x3d\xf8\x05\xee" "\xc9\xbd\x38\x89\x7b\x73\x1f\x7e\x91\xfb\x72\x3f\xee\xcf\x03\x78\x20" "\xbf\xc4\x83\xf8\x65\x1e\xcc\xaf\xf0\x10\x1e\xca\xc3\xf8\x55\x1e\xce" "\xaf\xf1\x08\x7e\x9d\x47\xf2\x28\x1e\xcd\x6f\xf0\x18\x1e\xcb\xe3\x78" "\x3c\x4f\xe0\x89\x9c\xcc\x6f\xf2\x24\x7e\x8b\x27\xf3\xdb\x3c\x85\xa7" "\xf2\x34\x9e\xce\x33\x78\x26\xcf\xe2\x77\x78\x36\xcf\xe1\xb9\xfc\x2e" "\xcf\xe3\xf9\xbc\x80\x17\xf2\x22\x5e\xcc\x4b\xf8\x3d\x5e\xca\xef\x73" "\x0a\x7f\xc0\xcb\xf8\x43\x4e\xe5\xe5\xbc\x82\x57\xf2\x2a\x5e\xcd\x6b" "\x78\x2d\xaf\xe3\xf5\xbc\x81\x37\xf2\x26\xde\xcc\x5b\x78\x2b\x6f\xe3" "\x8f\x78\x3b\xef\xe0\x9d\xbc\x8b\x77\xf3\x1e\xde\xcb\x1f\xf3\x3e\xfe" "\x84\xf7\xf3\xa7\x9c\xc6\x9f\xf1\x01\xfe\x0b\x1f\xe4\xcf\xf9\x10\x7f" "\xc1\x87\xf9\x4b\x3e\xc2\x5f\xf1\x51\xfe\x9a\x8f\xf1\x37\x7c\x9c\xbf" "\xe5\x13\x7c\x92\x4f\xf1\x77\x7c\x9a\xbf\xe7\x33\x7c\x96\xcf\xf1\x0f" "\x7c\x9e\x7f\xe4\x0b\xfc\x13\x5f\x64\xcf\x10\x61\xa4\x22\x1d\x99\x28" "\x88\x32\x45\x99\xa3\x84\x28\x4b\x94\x18\x5d\x15\x65\x8d\xb2\x45\xd9" "\xa3\x1c\x51\x2c\xba\x3a\xca\x19\x5d\x13\xe5\x8a\xae\x8d\x72\x47\x79" "\xa2\xbc\x51\xbe\x28\x7f\x54\x20\x2a\x18\x85\x11\x45\x36\xe2\x28\x8a" "\x0a\x45\x85\xa3\x78\x74\x5d\x54\x24\xba\x3e\x2a\x1a\x15\x8b\x8a\x47" "\x25\x22\x17\x95\x8c\x4a\x45\x37\x44\xa5\xa3\x1b\xa3\x32\xd1\x4d\x51" "\xd9\xe8\xe6\xa8\x5c\x74\x4b\x54\x3e\xaa\x10\x55\x8c\x6e\x8d\x6e\x8b" "\x2a\x45\xb7\x47\x95\xa3\x3b\xa2\x2a\xd1\x9d\x51\xd5\xa8\x5a\x54\x3d" "\xaa\x11\xdd\x15\xd5\x8c\xee\x8e\x6a\x45\xf7\x44\xb5\xa3\x7b\xa3\x32" "\xd1\x7d\x51\xdd\xe8\xfe\xa8\x5e\xf4\x40\x54\x3f\x6a\x10\x35\x8c\x1e" "\x8c\x1a\x45\x0f\x45\x8d\xa3\x26\x51\xd3\xa8\x59\xd4\x3c\x6a\x11\xb5" "\x8c\x1e\x8e\x5a\x45\x8f\x44\xad\xa3\x36\x51\xdb\xe8\xd1\xa8\x5d\xf4" "\x58\xd4\x3e\x7a\x3c\xea\x10\x3d\x11\x75\x8c\x9e\xbc\xb4\xbf\x58\xf0" "\xcb\xd5\xf4\xaf\xf6\x27\x45\xbd\x23\xfd\xeb\x1b\xb2\x7b\xf4\xa2\xf8" "\xe2\xf8\x92\xf8\x7b\xf1\xa5\xf1\xf7\xe3\x29\xf1\x0f\xe2\xcb\xe2\x1f" "\xc6\x53\xe3\xcb\xe3\x2b\xe2\x2b\xe3\xab\xe2\xab\xe3\x6b\xe2\x6b\xe3" "\xeb\xe2\xeb\xe3\x1b\xe2\x1b\xe3\x9b\xe2\x9b\xe3\x5b\xe2\x5b\xe3\xde" "\xd7\xc8\x0c\x0e\xd3\x1f\x84\xc1\xb8\xc0\x65\x72\x99\x5d\x82\xcb\xe2" "\x12\xdd\x55\x2e\xab\xcb\xe6\xb2\xbb\x1c\x2e\xe6\xae\x76\x39\xdd\x35" "\x2e\x97\xbb\xd6\xe5\x76\x79\x5c\x5e\x97\xcf\xe5\x77\x05\x5c\x41\x17" "\x3a\x72\xd6\xb1\x8b\x5c\x21\x57\xd8\xc5\xdd\x75\xae\x88\xbb\xde\x15" "\x75\xc5\x5c\x71\x57\xc2\x39\x57\xd2\x95\x72\x2d\x5c\x4b\xd7\xd2\xb5" "\x72\x8f\xb8\xd6\xae\x8d\x6b\xeb\x1e\x75\x8f\xba\xc7\xdc\x63\xee\xf1" "\x84\x5f\x0b\x77\x9d\xdc\x53\xae\xb3\x7b\xda\x75\x71\xcf\xb8\x67\xdc" "\xb3\xae\x9b\x7b\xce\x75\x77\xcf\xbb\x1e\xee\x05\xd7\xd3\xf5\x72\x49" "\x2e\xc9\xf5\x71\x7d\x5c\x5f\xd7\xd7\xf5\x77\xfd\xdd\x40\x37\xd0\x0d" "\x72\x83\xdc\x60\x37\xd8\x0d\x71\x43\xdc\x30\x37\xcc\x0d\x77\xc3\xdd" "\x08\x37\xc2\x8d\x74\x23\xdd\x68\x37\xda\x8d\x71\x63\xdc\x38\x37\xce" "\x4d\x70\x13\x5c\xb2\x4b\x76\x93\xdc\x24\x37\xd9\x4d\x76\x53\xdc\x14" "\x37\xcd\x4d\x73\x33\xdc\x0c\x37\xcb\xcd\x72\xb3\xdd\x6c\x37\xd7\xcd" "\x75\xf3\xdc\x3c\xb7\xc0\x2d\x70\x8b\xdc\x22\xb7\xc4\x2d\x71\x4b\xdd" "\x52\x97\xe2\x52\xdc\x32\xb7\xcc\xa5\xba\x54\xb7\xc2\xad\x70\xab\xdc" "\x2a\xb7\xc6\xad\x71\xeb\xdc\x3a\xb7\xc1\x6d\x70\x9b\xdc\x26\xb7\xc5" "\x6d\x71\xdb\xdc\x36\xb7\xdd\x6d\x77\x3b\xdd\x4e\xb7\xdb\xed\x76\x7b" "\xdd\x5e\xb7\xcf\xed\x73\xfb\xdd\x7e\x97\xe6\xd2\xdc\x01\x77\xc0\x1d" "\x74\x07\xdd\x21\xf7\x85\x3b\xec\xbe\x74\x47\xdc\x57\xee\xa8\xfb\xda" "\x1d\x73\xdf\xb8\xe3\xee\x5b\x77\xc2\x9d\x74\xa7\x9c\xd7\xa7\xdd\xf7" "\xee\x8c\x3b\xeb\xce\xb9\x1f\xdc\x79\xf7\xa3\xbb\xe0\x7e\x72\x17\x9d" "\x77\xc9\xb1\x37\x63\x93\x62\x6f\xc5\x26\xc7\xde\x8e\x4d\x89\x4d\x8d" "\x4d\x8b\x4d\x8f\xcd\x88\xcd\x8c\xcd\x8a\xbd\x13\x9b\x1d\x9b\x13\x9b" "\x1b\x7b\x37\x36\x2f\x36\x3f\xb6\x20\xb6\x30\xb6\x28\xb6\x38\xb6\x24" "\xf6\x5e\x6c\x69\xec\xfd\x58\x4a\xec\x83\xd8\xb2\xd8\x87\xb1\xd4\xd8" "\xf2\xd8\x8a\xd8\xca\xd8\xaa\xd8\xea\x98\xf7\x05\xb6\x47\xbe\x90\x2f" "\xec\xe3\xfe\x3a\x5f\xc4\x5f\xef\x8b\xfa\x62\xbe\xb8\x2f\xe1\x9d\x2f" "\xe9\x4b\xf9\x1b\x7c\x69\x7f\xa3\x2f\xe3\x6f\xf2\x65\xfd\xcd\xbe\x9c" "\xbf\xc5\x97\xf7\x15\x7c\x45\xdf\xc4\x37\xf5\xcd\x7c\x73\xdf\xc2\xb7" "\xf4\x0f\xfb\x56\xfe\x11\xdf\xda\xb7\xf1\x6d\xfd\xa3\xbe\x9d\x7f\xcc" "\xb7\xf7\x8f\xfb\x0e\xfe\x09\xdf\xd1\x3f\xe9\x3b\xf9\xa7\x7c\x67\xff" "\xb4\xef\xe2\x9f\xf1\x5d\xfd\xb3\xf3\x7f\xed\xb2\xef\xe1\x5f\xf0\x3d" "\x7d\x2f\x9f\xe4\x7b\xfb\x3e\xfe\x45\xdf\xd7\xf7\xf3\xfd\xfd\x00\x3f" "\xd0\xbf\xe4\x07\xf9\x97\xfd\x60\xff\x8a\x1f\xe2\x87\xfa\x61\xfe\x55" "\x3f\xdc\xbf\xe6\x47\xf8\xd7\xfd\x48\x3f\xca\x8f\xf6\x6f\xf8\x31\x7e" "\xac\x1f\xe7\xc7\xfb\x09\x7e\xa2\x4f\xf6\x6f\xfa\x49\xfe\x2d\x3f\xd9" "\xbf\xed\xa7\xf8\xa9\x7e\x9a\x9f\xee\x67\xf8\x99\x7e\x96\x7f\xc7\xcf" "\xf6\x73\xfc\x5c\xff\xae\x9f\xe7\xe7\xfb\x05\x7e\xa1\x5f\xe4\x17\xfb" "\x25\xfe\x3d\xbf\xd4\xbf\xef\x53\xfc\x07\x7e\x99\xff\xd0\xa7\xfa\xe5" "\x7e\x85\x5f\xe9\x57\xf9\xd5\x7e\x8d\x5f\xeb\xd7\xf9\xf5\x7e\x83\xdf" "\xe8\x37\xf9\xcd\x7e\x8b\xdf\xea\xb7\xf9\x8f\xfc\x76\xbf\xc3\xef\xf4" "\xbb\xfc\x6e\xbf\xc7\xef\xf5\x1f\xfb\x7d\xfe\x13\xbf\xdf\x7f\xea\xd3" "\xfc\x67\xfe\x80\xff\x8b\x3f\xe8\x3f\xf7\x87\xfc\x17\xfe\xb0\xff\xd2" "\x1f\xf1\x5f\xf9\xa3\xfe\x6b\x7f\xcc\x7f\xe3\x8f\xfb\x6f\xfd\x09\x7f" "\xd2\x9f\xf2\xdf\xf9\xd3\xfe\x7b\x7f\xc6\x9f\xf5\xe7\xfc\x0f\xfe\xbc" "\xff\xd1\x5f\xf0\x3f\xf9\x8b\xf2\x37\x6b\x42\x08\x21\x84\x10\xff\x14" "\x7d\x99\xfd\xbd\xff\xce\xff\xa9\x5f\xb7\x74\x7d\x00\x20\xdb\x8e\x7c" "\x87\xff\x7a\xce\x4d\xb9\x7f\x19\xf7\x53\xfb\x3a\xc6\x00\xe0\x89\x5e" "\x5d\x1b\xfc\xb6\x35\x68\x90\x94\x94\xf4\xeb\xb1\xa9\x1a\x82\xc2\x0b" "\x01\x20\x76\x29\xff\xe7\xef\x1f\xf8\x35\x5e\x0e\x6d\xe1\x31\xe8\x00" "\x6d\xa0\xf4\xdf\xad\xaf\x9f\xaa\xf8\xf3\x7d\xdf\x7f\x37\x7f\xfc\x66" "\x80\x44\x80\x2c\xbf\xe5\xa4\x3f\x1e\x25\xc2\x5f\xcf\x7f\xe3\x3f\x98" "\xbf\xc9\x7b\x7c\xb9\xf9\x17\x02\x14\x2d\x7c\x29\x27\xfd\x44\xbf\xc5" "\x97\xe6\x2f\xf3\x0f\xe6\xdf\xd3\xee\x32\xf3\x67\xf9\x3c\x19\xa0\xf5" "\x7f\xc9\xc9\x0a\x97\xe2\x4b\xf3\x97\x82\x47\xe0\x49\xe8\xf0\xbb\x23" "\x85\x10\x42\x08\x21\x84\x10\x42\x88\x5f\xf4\x53\xe7\xbb\x5d\xee\xf9" "\x36\xfd\xf9\x3c\xbf\xb9\x94\x93\x19\x2e\xc5\x97\x7b\x3e\xbf\x8c\xca" "\x7f\xc4\x1a\x84\x10\x42\x08\x21\x84\x10\x42\x08\xf1\xdf\x7b\xfa\xb9" "\xee\x8f\x3f\xdc\xa1\x43\x9b\xce\xff\xc9\x83\xcc\x7f\x8e\x32\xfe\x04" "\x03\x04\x80\x3f\x41\x19\x32\xf8\xf3\x0f\xae\xf4\x6f\x26\x21\x84\x10" "\x42\x08\x21\xc4\x1f\xed\xd2\x4d\xff\x95\xae\x44\x08\x21\x84\x10\x42" "\x08\x21\x84\x10\x42\x08\x21\x84\x10\x42\x08\x21\x84\x10\x42\x08\x21" "\x84\x10\x42\x08\x21\x84\x10\x42\x08\x21\x84\x10\x42\x08\x21\x84\xc8" "\xb8\xfe\xfd\x6f\x08\x53\xff\xf4\xc1\x57\x7a\x8d\x42\x08\x21\x84\x10" "\x42\x08\x21\x84\x10\x42\x08\x21\x84\x10\x42\x08\x21\x84\x10\x42\x08" "\x21\x84\x10\x42\x08\x21\x84\x10\x42\x08\x21\x84\x10\x42\x08\x21\x84" "\x10\x42\x08\x21\x84\x10\x42\x08\x21\xc4\x95\xf6\x7f\x02\x00\x00\xff" "\xff\xe6\x0d\x55\xd3", 5377); syz_mount_image(/*fs=*/0x20000280, /*dir=*/0x200000c0, /*flags=MS_SYNCHRONOUS|MS_NODIRATIME*/ 0x810, /*opts=*/0x200018c0, /*chdir=*/0xfd, /*size=*/0x1501, /*img=*/0x200002c0); break; case 1: memcpy((void*)0x20000000, "./bus\000", 6); syscall(__NR_open, /*file=*/0x20000000ul, /*flags=O_NOFOLLOW|O_NOCTTY|O_NOATIME|O_CREAT|O_RDWR*/ 0x60142ul, /*mode=*/0ul); break; case 2: memcpy((void*)0x20000380, "/dev/loop", 9); *(uint8_t*)0x20000389 = 0x30 + procid * 1; *(uint8_t*)0x2000038a = 0; memcpy((void*)0x20000140, "./bus\000", 6); syscall(__NR_mount, /*src=*/0x20000380ul, /*dst=*/0x20000140ul, /*type=*/0ul, /*flags=MS_BIND*/ 0x1000ul, /*data=*/0ul); break; case 3: memcpy((void*)0x20000500, "./bus\000", 6); res = syscall(__NR_open, /*file=*/0x20000500ul, /*flags=*/0ul, /*mode=*/0ul); if (res != -1) r[0] = res; break; case 4: *(uint64_t*)0x200007c0 = 0; *(uint64_t*)0x200007c8 = 0; *(uint64_t*)0x200007d0 = 0; *(uint64_t*)0x200007d8 = 1; *(uint64_t*)0x200007e0 = 0x8001; *(uint32_t*)0x200007e8 = 0; *(uint32_t*)0x200007ec = 0; *(uint32_t*)0x200007f0 = 0; *(uint32_t*)0x200007f4 = 0xa; memcpy((void*)0x200007f8, "\xef\x35\x9f\x41\x3b\xb9\x38\x52\xf7\xd6\xa4\xae\x6d\xdd\xfb\xd1" "\xce\x5d\x29\xc2\xee\x5e\x5c\x9d\x00\x0f\xf8\xee\x09\xe7\x37\xff" "\x0e\xdf\x11\x0f\xf4\x11\x76\x39\xc2\xeb\x4b\x78\xc6\x6e\xe6\x77" "\xdf\x70\x19\x05\xb9\xaa\xfa\xb4\xaf\xaa\xf7\x55\xa3\xf6\xa0\x04", 64); memcpy((void*)0x20000838, "\xcb\xa3\xd6\x25\x78\x08\x20\xd1\xcb\xf7\xdb\x71\x03\x82\x59\xca" "\x17\x1c\xe1\xa3\x11\xef\x97\xe4\x29\x8d\x1e\x14\xef\x01\x06\x00" "\x00\xe9\x00\x96\x00\xfd\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00", 64); memcpy((void*)0x20000878, "\x93\x00\xe6\xd6\xa8\x9e\xf3\x0b\xea\x2a\x00\x92\x00\x00\x10\x00" "\x00\x00\xaf\xf5\x71\xec\x31\x99\xbd\xe4\x00\x00\x00\x00\x00\x00", 32); *(uint64_t*)0x20000898 = 0; *(uint64_t*)0x200008a0 = 0; syscall(__NR_ioctl, /*fd=*/r[0], /*cmd=*/0x4c04, /*arg=*/0x200007c0ul); break; case 5: memcpy((void*)0x20000e00, "./" "file0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\000", 252); syscall(__NR_creat, /*file=*/0x20000e00ul, /*mode=*/0ul); break; } } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x21000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1, /*offset=*/0ul); setup_sysctl(); setup_cgroups(); const char* reason; (void)reason; for (procid = 0; procid < 5; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; }