// https://syzkaller.appspot.com/bug?id=220f0f15abcf729919a39c0c9a7c10eccd3e7dd2 // 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 #ifndef __NR_bpf #define __NR_bpf 321 #endif static unsigned long long procid; static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { int state; } event_t; static void event_init(event_t* ev) { ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { if (ev->state) exit(1); __atomic_store_n(&ev->state, 1, __ATOMIC_RELEASE); syscall(SYS_futex, &ev->state, FUTEX_WAKE | FUTEX_PRIVATE_FLAG, 1000000); } static void event_wait(event_t* ev) { while (!__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, 0); } static int event_isset(event_t* ev) { return __atomic_load_n(&ev->state, __ATOMIC_ACQUIRE); } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; for (;;) { uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, &ts); if (__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) return 1; now = current_time_ms(); if (now - start > timeout) return 0; } } static bool write_file(const char* file, const char* what, ...) { char buf[1024]; va_list args; va_start(args, what); vsnprintf(buf, sizeof(buf), what, args); va_end(args); buf[sizeof(buf) - 1] = 0; int len = strlen(buf); int fd = open(file, O_WRONLY | O_CLOEXEC); if (fd == -1) return false; if (write(fd, buf, len) != len) { int err = errno; close(fd); errno = err; return false; } close(fd); return true; } struct nlmsg { char* pos; int nesting; struct nlattr* nested[8]; char buf[4096]; }; static void netlink_init(struct nlmsg* nlmsg, int typ, int flags, const void* data, int size) { memset(nlmsg, 0, sizeof(*nlmsg)); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf; hdr->nlmsg_type = typ; hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | flags; memcpy(hdr + 1, data, size); nlmsg->pos = (char*)(hdr + 1) + NLMSG_ALIGN(size); } static void netlink_attr(struct nlmsg* nlmsg, int typ, const void* data, int size) { struct nlattr* attr = (struct nlattr*)nlmsg->pos; attr->nla_len = sizeof(*attr) + size; attr->nla_type = typ; if (size > 0) memcpy(attr + 1, data, size); nlmsg->pos += NLMSG_ALIGN(attr->nla_len); } static void netlink_nest(struct nlmsg* nlmsg, int typ) { struct nlattr* attr = (struct nlattr*)nlmsg->pos; attr->nla_type = typ; nlmsg->pos += sizeof(*attr); nlmsg->nested[nlmsg->nesting++] = attr; } static void netlink_done(struct nlmsg* nlmsg) { struct nlattr* attr = nlmsg->nested[--nlmsg->nesting]; attr->nla_len = nlmsg->pos - (char*)attr; } static int netlink_send_ext(struct nlmsg* nlmsg, int sock, uint16_t reply_type, int* reply_len, bool dofail) { if (nlmsg->pos > nlmsg->buf + sizeof(nlmsg->buf) || nlmsg->nesting) exit(1); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf; hdr->nlmsg_len = nlmsg->pos - nlmsg->buf; struct sockaddr_nl addr; memset(&addr, 0, sizeof(addr)); addr.nl_family = AF_NETLINK; ssize_t n = sendto(sock, nlmsg->buf, hdr->nlmsg_len, 0, (struct sockaddr*)&addr, sizeof(addr)); if (n != (ssize_t)hdr->nlmsg_len) { if (dofail) exit(1); return -1; } n = recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0); if (reply_len) *reply_len = 0; if (n < 0) { if (dofail) exit(1); return -1; } if (n < (ssize_t)sizeof(struct nlmsghdr)) { errno = EINVAL; if (dofail) exit(1); return -1; } if (hdr->nlmsg_type == NLMSG_DONE) return 0; if (reply_len && hdr->nlmsg_type == reply_type) { *reply_len = n; return 0; } if (n < (ssize_t)(sizeof(struct nlmsghdr) + sizeof(struct nlmsgerr))) { errno = EINVAL; if (dofail) exit(1); return -1; } if (hdr->nlmsg_type != NLMSG_ERROR) { errno = EINVAL; if (dofail) exit(1); return -1; } errno = -((struct nlmsgerr*)(hdr + 1))->error; return -errno; } static int netlink_send(struct nlmsg* nlmsg, int sock) { return netlink_send_ext(nlmsg, sock, 0, NULL, true); } static int netlink_query_family_id(struct nlmsg* nlmsg, int sock, const char* family_name, bool dofail) { struct genlmsghdr genlhdr; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = CTRL_CMD_GETFAMILY; netlink_init(nlmsg, GENL_ID_CTRL, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(nlmsg, CTRL_ATTR_FAMILY_NAME, family_name, strnlen(family_name, GENL_NAMSIZ - 1) + 1); int n = 0; int err = netlink_send_ext(nlmsg, sock, GENL_ID_CTRL, &n, dofail); if (err < 0) { return -1; } uint16_t id = 0; struct nlattr* attr = (struct nlattr*)(nlmsg->buf + NLMSG_HDRLEN + NLMSG_ALIGN(sizeof(genlhdr))); for (; (char*)attr < nlmsg->buf + n; attr = (struct nlattr*)((char*)attr + NLMSG_ALIGN(attr->nla_len))) { if (attr->nla_type == CTRL_ATTR_FAMILY_ID) { id = *(uint16_t*)(attr + 1); break; } } if (!id) { errno = EINVAL; return -1; } recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0); return id; } static int netlink_next_msg(struct nlmsg* nlmsg, unsigned int offset, unsigned int total_len) { struct nlmsghdr* hdr = (struct nlmsghdr*)(nlmsg->buf + offset); if (offset == total_len || offset + hdr->nlmsg_len > total_len) return -1; return hdr->nlmsg_len; } static void netlink_add_device_impl(struct nlmsg* nlmsg, const char* type, const char* name, bool up) { struct ifinfomsg hdr; memset(&hdr, 0, sizeof(hdr)); if (up) hdr.ifi_flags = hdr.ifi_change = IFF_UP; netlink_init(nlmsg, RTM_NEWLINK, NLM_F_EXCL | NLM_F_CREATE, &hdr, sizeof(hdr)); if (name) netlink_attr(nlmsg, IFLA_IFNAME, name, strlen(name)); netlink_nest(nlmsg, IFLA_LINKINFO); netlink_attr(nlmsg, IFLA_INFO_KIND, type, strlen(type)); } static void netlink_add_device(struct nlmsg* nlmsg, int sock, const char* type, const char* name) { netlink_add_device_impl(nlmsg, type, name, false); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_veth(struct nlmsg* nlmsg, int sock, const char* name, const char* peer) { netlink_add_device_impl(nlmsg, "veth", name, false); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_nest(nlmsg, VETH_INFO_PEER); nlmsg->pos += sizeof(struct ifinfomsg); netlink_attr(nlmsg, IFLA_IFNAME, peer, strlen(peer)); netlink_done(nlmsg); netlink_done(nlmsg); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_xfrm(struct nlmsg* nlmsg, int sock, const char* name) { netlink_add_device_impl(nlmsg, "xfrm", name, true); netlink_nest(nlmsg, IFLA_INFO_DATA); int if_id = 1; netlink_attr(nlmsg, 2, &if_id, sizeof(if_id)); netlink_done(nlmsg); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_hsr(struct nlmsg* nlmsg, int sock, const char* name, const char* slave1, const char* slave2) { netlink_add_device_impl(nlmsg, "hsr", name, false); netlink_nest(nlmsg, IFLA_INFO_DATA); int ifindex1 = if_nametoindex(slave1); netlink_attr(nlmsg, IFLA_HSR_SLAVE1, &ifindex1, sizeof(ifindex1)); int ifindex2 = if_nametoindex(slave2); netlink_attr(nlmsg, IFLA_HSR_SLAVE2, &ifindex2, sizeof(ifindex2)); netlink_done(nlmsg); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_linked(struct nlmsg* nlmsg, int sock, const char* type, const char* name, const char* link) { netlink_add_device_impl(nlmsg, type, name, false); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_vlan(struct nlmsg* nlmsg, int sock, const char* name, const char* link, uint16_t id, uint16_t proto) { netlink_add_device_impl(nlmsg, "vlan", name, false); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_attr(nlmsg, IFLA_VLAN_ID, &id, sizeof(id)); netlink_attr(nlmsg, IFLA_VLAN_PROTOCOL, &proto, sizeof(proto)); netlink_done(nlmsg); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_macvlan(struct nlmsg* nlmsg, int sock, const char* name, const char* link) { netlink_add_device_impl(nlmsg, "macvlan", name, false); netlink_nest(nlmsg, IFLA_INFO_DATA); uint32_t mode = MACVLAN_MODE_BRIDGE; netlink_attr(nlmsg, IFLA_MACVLAN_MODE, &mode, sizeof(mode)); netlink_done(nlmsg); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_add_geneve(struct nlmsg* nlmsg, int sock, const char* name, uint32_t vni, struct in_addr* addr4, struct in6_addr* addr6) { netlink_add_device_impl(nlmsg, "geneve", name, false); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_attr(nlmsg, IFLA_GENEVE_ID, &vni, sizeof(vni)); if (addr4) netlink_attr(nlmsg, IFLA_GENEVE_REMOTE, addr4, sizeof(*addr4)); if (addr6) netlink_attr(nlmsg, IFLA_GENEVE_REMOTE6, addr6, sizeof(*addr6)); netlink_done(nlmsg); netlink_done(nlmsg); int err = netlink_send(nlmsg, sock); if (err < 0) { } } #define IFLA_IPVLAN_FLAGS 2 #define IPVLAN_MODE_L3S 2 #undef IPVLAN_F_VEPA #define IPVLAN_F_VEPA 2 static void netlink_add_ipvlan(struct nlmsg* nlmsg, int sock, const char* name, const char* link, uint16_t mode, uint16_t flags) { netlink_add_device_impl(nlmsg, "ipvlan", name, false); netlink_nest(nlmsg, IFLA_INFO_DATA); netlink_attr(nlmsg, IFLA_IPVLAN_MODE, &mode, sizeof(mode)); netlink_attr(nlmsg, IFLA_IPVLAN_FLAGS, &flags, sizeof(flags)); netlink_done(nlmsg); netlink_done(nlmsg); int ifindex = if_nametoindex(link); netlink_attr(nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static void netlink_device_change(struct nlmsg* nlmsg, int sock, const char* name, bool up, const char* master, const void* mac, int macsize, const char* new_name) { struct ifinfomsg hdr; memset(&hdr, 0, sizeof(hdr)); if (up) hdr.ifi_flags = hdr.ifi_change = IFF_UP; hdr.ifi_index = if_nametoindex(name); netlink_init(nlmsg, RTM_NEWLINK, 0, &hdr, sizeof(hdr)); if (new_name) netlink_attr(nlmsg, IFLA_IFNAME, new_name, strlen(new_name)); if (master) { int ifindex = if_nametoindex(master); netlink_attr(nlmsg, IFLA_MASTER, &ifindex, sizeof(ifindex)); } if (macsize) netlink_attr(nlmsg, IFLA_ADDRESS, mac, macsize); int err = netlink_send(nlmsg, sock); if (err < 0) { } } static int netlink_add_addr(struct nlmsg* nlmsg, int sock, const char* dev, const void* addr, int addrsize) { struct ifaddrmsg hdr; memset(&hdr, 0, sizeof(hdr)); hdr.ifa_family = addrsize == 4 ? AF_INET : AF_INET6; hdr.ifa_prefixlen = addrsize == 4 ? 24 : 120; hdr.ifa_scope = RT_SCOPE_UNIVERSE; hdr.ifa_index = if_nametoindex(dev); netlink_init(nlmsg, RTM_NEWADDR, NLM_F_CREATE | NLM_F_REPLACE, &hdr, sizeof(hdr)); netlink_attr(nlmsg, IFA_LOCAL, addr, addrsize); netlink_attr(nlmsg, IFA_ADDRESS, addr, addrsize); return netlink_send(nlmsg, sock); } static void netlink_add_addr4(struct nlmsg* nlmsg, int sock, const char* dev, const char* addr) { struct in_addr in_addr; inet_pton(AF_INET, addr, &in_addr); int err = netlink_add_addr(nlmsg, sock, dev, &in_addr, sizeof(in_addr)); if (err < 0) { } } static void netlink_add_addr6(struct nlmsg* nlmsg, int sock, const char* dev, const char* addr) { struct in6_addr in6_addr; inet_pton(AF_INET6, addr, &in6_addr); int err = netlink_add_addr(nlmsg, sock, dev, &in6_addr, sizeof(in6_addr)); if (err < 0) { } } static 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 static void setup_gadgetfs(); static void setup_binderfs(); static void setup_fusectl(); static void sandbox_common_mount_tmpfs(void) { write_file("/proc/sys/fs/mount-max", "100000"); if (mkdir("./syz-tmp", 0777)) exit(1); if (mount("", "./syz-tmp", "tmpfs", 0, NULL)) exit(1); if (mkdir("./syz-tmp/newroot", 0777)) exit(1); if (mkdir("./syz-tmp/newroot/dev", 0700)) exit(1); unsigned bind_mount_flags = MS_BIND | MS_REC | MS_PRIVATE; if (mount("/dev", "./syz-tmp/newroot/dev", NULL, bind_mount_flags, NULL)) exit(1); if (mkdir("./syz-tmp/newroot/proc", 0700)) exit(1); if (mount("syz-proc", "./syz-tmp/newroot/proc", "proc", 0, NULL)) exit(1); if (mkdir("./syz-tmp/newroot/selinux", 0700)) exit(1); const char* selinux_path = "./syz-tmp/newroot/selinux"; if (mount("/selinux", selinux_path, NULL, bind_mount_flags, NULL)) { if (errno != ENOENT) exit(1); if (mount("/sys/fs/selinux", selinux_path, NULL, bind_mount_flags, NULL) && errno != ENOENT) exit(1); } if (mkdir("./syz-tmp/newroot/sys", 0700)) exit(1); if (mount("/sys", "./syz-tmp/newroot/sys", 0, bind_mount_flags, NULL)) exit(1); if (mount("/sys/kernel/debug", "./syz-tmp/newroot/sys/kernel/debug", NULL, bind_mount_flags, NULL) && errno != ENOENT) exit(1); if (mount("/sys/fs/smackfs", "./syz-tmp/newroot/sys/fs/smackfs", NULL, bind_mount_flags, NULL) && errno != ENOENT) exit(1); if (mount("/proc/sys/fs/binfmt_misc", "./syz-tmp/newroot/proc/sys/fs/binfmt_misc", NULL, bind_mount_flags, NULL) && errno != ENOENT) exit(1); if (mkdir("./syz-tmp/newroot/syz-inputs", 0700)) exit(1); if (mount("/syz-inputs", "./syz-tmp/newroot/syz-inputs", NULL, bind_mount_flags | MS_RDONLY, NULL) && errno != ENOENT) exit(1); if (mkdir("./syz-tmp/pivot", 0777)) exit(1); if (syscall(SYS_pivot_root, "./syz-tmp", "./syz-tmp/pivot")) { if (chdir("./syz-tmp")) exit(1); } else { if (chdir("/")) exit(1); if (umount2("./pivot", MNT_DETACH)) exit(1); } if (chroot("./newroot")) exit(1); if (chdir("/")) exit(1); setup_gadgetfs(); setup_binderfs(); setup_fusectl(); } static void setup_gadgetfs() { if (mkdir("/dev/gadgetfs", 0777)) { } if (mount("gadgetfs", "/dev/gadgetfs", "gadgetfs", 0, NULL)) { } } static void setup_fusectl() { if (mount(0, "/sys/fs/fuse/connections", "fusectl", 0, 0)) { } } static void setup_binderfs() { if (mkdir("/dev/binderfs", 0777)) { } if (mount("binder", "/dev/binderfs", "binder", 0, NULL)) { } } static void loop(); static void sandbox_common() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); if (getppid() == 1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = (200 << 20); setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 32 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 136 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); if (unshare(CLONE_NEWNS)) { } if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL)) { } if (unshare(CLONE_NEWIPC)) { } if (unshare(0x02000000)) { } if (unshare(CLONE_NEWUTS)) { } if (unshare(CLONE_SYSVSEM)) { } typedef struct { const char* name; const char* value; } sysctl_t; static const sysctl_t sysctls[] = { {"/proc/sys/kernel/shmmax", "16777216"}, {"/proc/sys/kernel/shmall", "536870912"}, {"/proc/sys/kernel/shmmni", "1024"}, {"/proc/sys/kernel/msgmax", "8192"}, {"/proc/sys/kernel/msgmni", "1024"}, {"/proc/sys/kernel/msgmnb", "1024"}, {"/proc/sys/kernel/sem", "1024 1048576 500 1024"}, }; unsigned i; for (i = 0; i < sizeof(sysctls) / sizeof(sysctls[0]); i++) write_file(sysctls[i].name, sysctls[i].value); } static int wait_for_loop(int pid) { if (pid < 0) exit(1); int status = 0; while (waitpid(-1, &status, __WALL) != pid) { } return WEXITSTATUS(status); } static void drop_caps(void) { struct __user_cap_header_struct cap_hdr = {}; struct __user_cap_data_struct cap_data[2] = {}; cap_hdr.version = _LINUX_CAPABILITY_VERSION_3; cap_hdr.pid = getpid(); if (syscall(SYS_capget, &cap_hdr, &cap_data)) exit(1); const int drop = (1 << CAP_SYS_PTRACE) | (1 << CAP_SYS_NICE); cap_data[0].effective &= ~drop; cap_data[0].permitted &= ~drop; cap_data[0].inheritable &= ~drop; if (syscall(SYS_capset, &cap_hdr, &cap_data)) exit(1); } static int do_sandbox_none(void) { if (unshare(CLONE_NEWPID)) { } int pid = fork(); if (pid != 0) return wait_for_loop(pid); 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_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); 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); } 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 < 11; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 50); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); close_fds(); } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); setup_test(); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[4] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: // socket$inet_tcp arguments: [ // domain: const = 0x2 (8 bytes) // type: const = 0x1 (8 bytes) // proto: const = 0x0 (4 bytes) // ] // returns sock_tcp res = syscall(__NR_socket, /*domain=*/2ul, /*type=*/1ul, /*proto=*/0); if (res != -1) r[0] = res; break; case 1: // bind$inet arguments: [ // fd: sock_in (resource) // addr: ptr[in, sockaddr_in] { // sockaddr_in { // family: const = 0x2 (2 bytes) // port: int16be = 0x4e20 (2 bytes) // addr: union ipv4_addr { // multicast1: const = 0xe0000001 (4 bytes) // } // pad = 0x0 (8 bytes) // } // } // addrlen: len = 0x10 (8 bytes) // ] *(uint16_t*)0x200000e5b000 = 2; *(uint16_t*)0x200000e5b002 = htobe16(0x4e20); *(uint32_t*)0x200000e5b004 = htobe32(0xe0000001); syscall(__NR_bind, /*fd=*/r[0], /*addr=*/0x200000e5b000ul, /*addrlen=*/0x10ul); break; case 2: // connect$inet arguments: [ // fd: sock_in (resource) // addr: ptr[in, sockaddr_in] { // sockaddr_in { // family: const = 0x2 (2 bytes) // port: int16be = 0x4e20 (2 bytes) // addr: union ipv4_addr { // local: ipv4_addr_t[const[170, int8]] { // a0: const = 0xac (1 bytes) // a1: const = 0x14 (1 bytes) // a2: const = 0x14 (1 bytes) // a3: const = 0xaa (1 bytes) // } // } // pad = 0x0 (8 bytes) // } // } // addrlen: len = 0x10 (8 bytes) // ] *(uint16_t*)0x200000ccb000 = 2; *(uint16_t*)0x200000ccb002 = htobe16(0x4e20); *(uint8_t*)0x200000ccb004 = 0xac; *(uint8_t*)0x200000ccb005 = 0x14; *(uint8_t*)0x200000ccb006 = 0x14; *(uint8_t*)0x200000ccb007 = 0xaa; syscall(__NR_connect, /*fd=*/r[0], /*addr=*/0x200000ccb000ul, /*addrlen=*/0x10ul); break; case 3: // bpf$PROG_LOAD arguments: [ // cmd: const = 0x5 (8 bytes) // arg: ptr[in, bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], fd_bpf_prog[opt]]] { // bpf_prog_t[flags[bpf_prog_type, int32], bpf_prog_attach_types, // bpf_btf_id[opt], fd_bpf_prog[opt]] { // type: bpf_prog_type = 0x1 (4 bytes) // ninsn: bytesize8 = 0x3 (4 bytes) // insns: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {18 00 00 00 03 00 00 00 00 00 00 00 a0 12 // 54 4f 95 00 2b 00 00 00 00 00 93 ad ff a8 22 55 f6 74 41 2d // 02 00 00 00 00 00 00 5a b5 27 ee 36 97 f1 ed 44 36 dd 11 64 // b1 b3 f4 27 f6 ba 6b 34 f9 81 25 f3 0e 63 1d 27 36 83 62 6e // 00 dc 25 4d 57 0d 4a 6b 78 a5 83 34 88 cf e4 10 09 00 00 00 // 4a a9 00 00 3d 3c d6 2f 00 15 8e 6e ee 85 01 00 00 00 52 0a // 00 00 15 1d 01 00 00 00 01 00 bf 00 00 00 00 3b bd 42 4c 6e // 6c af be 93 09 ab a2 18 81 28 68 a5 1d 12 9e 78 f6 ae 17 0b // f5 a5 20 01 a3 cd 00 00 41 f0 db 74 59 6f d7 2c 00 2a 60 c1 // bc 7d c8 c3 8b 00 00 24 d8 89 77 65 2b 36 b9 dd 11 45 d0 3f // f4 5f 70 68 5c 6b d9 ff 41 c6 9b 7d e4 75 8c 10 96 a1 dc 52 // f2 9e 8b 70 1d 2d 17 eb c4 06 e8 9d cb b7 67 7e 65 28 b0 85 // 6e 31 eb 94 74 c0 10 6f c4 8e 1f 8c 1a 5f 69 45 ac 24 cf 60 // 80 68 f6 ff 21 e8 8b 3c fc 22 df 01 d5 1e 24 24 43 61 8c 02 // e0 a4 28 da 65 13 66 e4 ba c9 d9 73 28 fa 2a 82 b5 e8 74 1e // 02 05 6d 93 3b ed f5 9f f2 32 ce bc 68 b9 1a f5 04 79 38 74 // 67 82 42 62 85 2c 79 39 db 56 72 d0 7c db e8 e1 48 bf 56 49 // 7e 5d 56 d0 6c 75 51 b8 70 b2 85 1c 3f 0a 1a ab 71 58 ed ee // cc d9 2e 3a 88 dc 0f 43 21 87 ce 92 d7 b1 7a 21 c8 f1 b3 36 // 9e bf cb 4c b2 94 66 01 b0 f0 4e db 25 6c 60 4f 06 87 73 f6 // db 9d 66 1b d7 f0 e2 53 6f 00 00 00 00 00 00 00 00 55 21 45 // 8b 7d 1e 34 1c 6f 86 4f 98 3d 74 5f 58 65 aa d4 1d 29 15 8a // e7 60 2a 2d 6c d4 15 e8 35 1e bc 28 3d f5 4d 6b ec 66 47 09 // ff 03 f1 aa 3d c7 f1 58 0a ce 9b f2 af d2 8d 71 57 e6 7f b9 // 8d 12 1a 96 eb 37 38 45 25 50 12 e0 28 cb 26 54 d4 93 a0 b4 // b3 5f aa e1 76 f9 9b 74 5e da 29 67 19 9c c9 36 85 bb 53 7e // 8e 48 71 d4 ac f3 e3 dc 10 e1 3e f2 27 f6 27 a4 00 00 ad 1f // a2 53 d3 3f a7 4f 17 2d 00 07 ae 4e 1e 34 7c 0c ff 28 23 5a // 6b b7 aa 38 04 b9 07 a8 f2 88 0c 5c b1 cb 38 5e 6a dd 14 65 // 20 03 c7 cd d3 32 4f 07 d1 34 d3 ed 07 f1 c1 09 00 00 00 09 // dd 87 2e c6 4f a6 c7 18 bb d1 aa 59 11 40 cf f0 be 4c 6f 8d // f0 84 c5 e9 73 4a e3 0a a9 af dc 71 25 f0 1a b0 3a 9b 10 74 // 40 71 36 b4 50 60 00 f0 91 6a ad a0 35 df 2e 04 52 a9 b3 9e // 73 ae eb 6e af 14 65 2d da 68 9e 20 51 d9 b7 eb 85 f3 f2 d5 // ae 2c 51 94 4d a8 d7 39 1d 5b 6b 97 41 9a 3b 76 60 0c d1 aa // 0a fe 5f 8f 46 df 4c 51 24 ca 42 5d 37 4b 37 18 67 a7 9b 31 // c6 61 7f c3 32 71 91 f3 f5 14 57 3f 1e 30 d1 fd 2d 76 3f 3e // e9 21 8b 15 c1 d6 0b e2 16 8f ff cd 59 9a 2c b7 7f 12 4e 22 // f8 76 73 67 58 05 49 4d b8 21 f3 9b 50 d5 fd 8c 6b 2a 3a 32 // 4c 25 7b c9 7d ef 5f 07 f2 b7 7f 05 a4 f8 1a 9c f8 11 09 71 // b7 49 cc d7 40 89 ed 6b 86 f8 1c a3 d2 47 d8 f7 1d 29 0e d1 // b1 a1 1f 7a 67 12 51 70 c8 8c 3b 6a 50 69 63 32 22 64 01 b1 // 10 da 9c 44 07 ec a2 2d eb c9 93 35 58 3b 00 01 3c 31 30 97 // 8f a0 69 af 82 23 b3 8c ed 73 5c 2d 90 c6 d8 4c 30 a0 d8 7d // 42 64 74 89 b3 96 01 be 5c 27 69 6c f2 f1 66 25 c0 c1 02 00 // 00 00 00 00 00 00 09 00 00 00 84 2e 64 17 1f 39 63 84 10 86 // e3 79 7a 48 25 d0 81 f2 40 08 00 00 53 41 87 73 86 55 d7 a6 // 24 04 12 c8 f2 83 cc 0c 1e ba 28 66 dc 95 80 00 00 00 00 00 // 00 00 7f ff ff ff ff 55 4b 82 d9 c1 62 f3 55 60 76 b8 05 52 // d9 61 ca 74 d1 ff da cc f0 ea 5f 02 e0 16 3a 9c cb 90 87 e6 // c3 b3 91 7b b7 4f d3 d5 60 70 0a 1f ab 44 e7 7e 31 2b 3b 12 // 9e 00 03 02 d6 13 91 6c 9b cf 9f 00 00 fa c7 3a 5b 6b fb 01 // ef ad a8 00 e5 00 00 00 00 00 fd af 2f 7b 3b 79 a4 33 e0 80 // 74 ea 24 62 97 4a b2 cb d2 47 eb 1c fa 26 38 f5 6d ae e5 7e // d1 4b c7 4d e0 fd 87 a9 ce 63 81 90 f3 57 0e 0b 4c 80 ef 68 // 2d f2 22 37 27 09 55 af b6 00 88 46 55 7e e3 bc 09 fd a6 db // b6 55 0d 59 73 00 eb 82 a1 84 c9 6f fd e5 a3 0e 54 33 d8 66 // 66 5b 98 ca 20 02 c8 36 e8 9f ee f9 04 c2 2f f2 63 4b 7b fb // f5 c0 d5 86 cd a5 b4 5f d0 0d ed e1 e8 8a 4d 41 de e7 cc 8d // 08 34 fb 8d 12 46 38 fe c5 8f ae b4 c1 6a bb 44 0d f2 a6 94 // f4 cd ca a4 f6 5c 22 f0 00 00 00 00 00 00 00 00 00 00 00 00 // 00 d5 03 d7 99 06 95 81 02 00 00 00 00 00 00 00 00 00 00 1f // ff f0 ef 89 b2 a6 8d 2b b2 dd 16 3e 86 33 14 e8 44 98 01 b5 // 2b b9 3f 6c 90 84 65 9c e7 77 dd a8 56 3c 85 96 56 a3 57 77 // 02 89 a6 1f aa 95 a8 2b f1 cf b7 f2 f9 72 52 e9 32 2a be 28 // 2c 33 44 fc 67 38 b4 46 78 93 b9 bf 0d 1c 81 30 ae 6b 00 11 // 06 2a 35 37 64 13 c2 9f 7c 6f 7b de 29 b9 f4 bd dd 5e 32 86 // 61 f4 61 5e 62 7a 6f 60 8a d5 3a 41 68 fe 8e 5d 7d 93 4a a2 // 89 b4 bd 2b 87 00 00 00 00 00 00 00 00 00 00 00 00 00 00 fc // 4b 4f f5 00 00 00 9b 77 78 83 a0 2f fd 92 df c4 cb 41 14 b9 // f9 cf 4a d1 55 11 0c d3 ac e2 b3 22 ae 31 bf a2 78 47 c7 99 // c8 86 9a 1e a5 b9 8e 52 5e 63 83 ad 7f d9 79 51 70 e7 b1 1e // 24 76 03 00 00 00 00 14 59 c7 f6 06 d7 21 d3 97 96 76 bf fb // 30 49 16 6a b8 4a c1 06 19 91 bd 57 c2 56 6c 10 c2 96 4e 3f // 24 91 e4 79 3e 2b 70 59 0d cc 71 f1 10 da 96 36 6c 40 dd 44 // a2 c9 88 2d 3a a0 f8 a7 97 b8 fe a6 ef cf b5 27 6b 76 79 f1 // 55 59 cd aa bf 5f c1 4a dd 71 d0 bc a3 74 05 de d6 9b 77 ab // 4a 3d 74 87 fd 50 c5 e2 2a de f9 54 6a bb 7a 2d 9c 08 5b 18 // 9b 5f f3 0e 4e 0c 13 f6 08 70 fd e1 f8 8d 83 0b 11 00 21 35 // e8 e7 26 2f 29 b6 d7 92 3b fb e0 bd 2a 8b e1 79 e5 6b 41 ff // 37 92 ce e2 fc 37 ee e7 39 c3 54 f3 a0 0f 9d 8d 99 21 aa fc // 85 56 7e c9 83 00 8c e7 40 d8 80 4f 8e 70 5f 0d c5 9d 00 00 // 21 36 3e 8d f9 4f fa 75 b4 8d c8 c1 2d ef 68 1a 11 64 79 46 // 59 54 45 bf 1c b7 d2 77 8c d2 7a 6b 3b 29 66 b0 8b e6 00 00 // 00 20 a8 a7 11 d1 93 ba e0 ab 2d b9 ed 9c 6c b3 c3 de 42 ab // 89 52 44 14 ca e9 22 14 1f 7b af 17 eb b7 90 ad 60 bd 03 87 // 0c 39 d1 ad 12 c7 50 83 7e 63 f9 88 0f d7 02 59 e3 55 90 af // b4 84 3c d4 e9 98 93 98 ea a8 af ef b3 aa 13 ca b8 d0 15 cb // af 15 61 d9 53 62 de dd 73 b8 f8 cb f8 26 9c ac 09 1c fa aa // 3c 7e 46 d6 e7 91 45 fc 0f 1d 1b 38 37 52 cc b4 05 15 a7 72 // 35 6d 74 69 14 54 02 16 ad f4 af a2 52 72 0e c6 da d3 a9 86 // 71 ec da ff 46 cd df fb 1f 05 a0 c0 97 60 70 d6 03 a4 42 d0 // 14 82 23 69 fa 3e ac bb 69 bd 1b 0a 07 43 57 ac d5 d0 21 61 // fe d1 46 ad 3a a1 5d 2b 81 01 b7 bd 1e 09 1a da 78 ec d5 01 // 81 f4 b3 5c ae 1b 29 af f9 14 94 c9 16 32 3b 61 f8 15 c4 e0 // 70 16 57 08 7a d1 1e ef 97 95 29 21 36 5b c8 98 ba 2c 76 a9 // b6 e0 05 2f 43 b1 ad 2d fd f3 f9 58 fc 1d 32 e6 92 bc 88 46 // c7 8a 95 6a da 45 3c 67 c1 c2 cd c4 f8 b1 c9 4e 9a dc 10 6e // 85 b3 1e 03 0d 95 5c 55 78 e1 07 a6 e8 ca 0d 4d d0 53 44 c3 // e2 af 25 d9 a3 b0 f7 80 56 24 01 6a ea b2 71 a7 5f 0b ac b1 // 01 a1 56 ef 89 48 06 45 69 15 4a 7d e0 8f 80 e4 df 4c 33 9b // 69 43 1b 0a 56 71 09 7d 89 21 2b 46 5b 0b 32 27 5d ea e1 0a // 77 e3 34 c9 fc 07 4d 18 1b de b5 be 80 a6 24 9d 47 2e 78 e6 // be 57 a5 cc d3 54 cf 18 1e 09 96 05 a6 44 ec ad e2 21 a2 be // 92 62 10 b2 69 0d 09 e4 b7 a3 de a2 54 03 39 74 39 97 9c 27 // d5 61 32 62 de 10 ba ce cf ff 2d 58 43 7f 42 2d f4 25 2c 01 // 87 95 31 0c 25 e8 fc e1 8e d3 66 ac 2c aa de 56 4c a8 69 72 // 7a 7d 63 c2 62 71 e1 7d 7a ba 48 97 18 35 53 03 11 54 52 73 // d3 ca ad eb 5d 20 17 dc dd ab 8f 38 f2 06 8f 68 a4 11 1d dd // 58 7b 5d f4 b5 d8 f1 ce 00 23 1a 20 92 eb 2e 79 7c 49 1a 1e // 66 f7 36 06 fd 95 bb e0 f1 05 21 86 2b 62 62 f0 25 9d a5 1f // f7 51 7a ce 73 61 46 0a 46 69 a9 7f 7d 0b f0 95 c2 78 7f 00 // bd bf ee 19 67 0d 1e 0e c5 e6 c3 cb 09 97 2f a4 d9 49 86 15 // 7b 96 d6 69 51 77 c9 9d 83 71 66 51 12 93 20 92 43 52 cd a7 // b8 ea d9 1c 33 01 af 62 0c 1e 8d 70 3d d2 9a d7 7f 54 83 67 // 79 60 0b b0 db 3e cf bd 36 fa 81 64 fa bd cf 2e 58 b7 20 e8 // e1 c0 3a 74 da f5 93 f9 2a 8e cc 03 f8 c8 e3 af 9a e0 7d c0 // 37 80 cc 0d 69 00 00 00 00 00 00 00 00 19 98 73 19 92 ce b2 // 7d cc 0b e5 be 4d ec ef e4 1b 78 bc 18 47 bf 54 b0 87 e0 95 // 17 2f 06 cf a6 d4 bf 95 8b 1d 45 44 94 7f f1 23 06 55 19 9d // b4 f4 75 00 60 47 fe 83 ca ca 97 75 8d ff a5 3c ee 76 4f 85 // 93 2e b2 0d 54 24 1b 2d 51 5c 08 26 df e1 f0 f4 0a e9 20 45 // 5a 45 48 fb 35 e2 a3 45 c0 5b 1c 25 2b 78 77 bb 3d 83 4b 0b // 35 79 a3 62 49 14 6f 83 2e f2 58 df 51 27 31 8c 70 17 ac 1a // 99 6c 4f 90 2f 82 de b6 0f d1 13 cc f8 12 d5 5f fd 62 50 57 // bd 4f f3 96 09 92 b8 5b c8 d3 2e df ca 38 6b e1 6b 1c 54 9a // ec 52 e3 1e 14 05 f8 6c 77 60 28 29 01 75 0b 73 2e c0 6b 0d // b7 35 22 2a 56 f3 eb b1 6f ad 3e 92 69 49 52 30 cd 88 b0 ea // 2e 3a ff a1 96 a2 f0 ad f7 33 bc 6a fd 37 a6 59 ec c9 33 d6 // 36 c1 b2 7d 3a 16 c5 ea 25 30 1f 9b 57 89 e4 aa 8e 72 28 e3 // 00 2f 14 6a a5 e5 75 bb 74 b1 eb b8 21 47 ed f8 16 1d 36 27 // 04 37 70 58 e8 87 c6 08 be 87 19 ea 1b 6c 49 0f 79 e0 83 2e // 2d dd 7e 21 7c 7a dd dd 47 31 e0 32 d7 eb 35 bd c3 81 60 c6 // 76 d8 40 e2 e8 be 90 33 a6 86 cf 70 61 f5 f5 5e 28 51 73 6a // 04 00 f3 ba d8 ac 05 c0 48 e2 0d 8c 03 b6 80 08 a7 0b 8f 80 // c9 3e bd 2a ba bb 5c 65 fe 9a bc 46 42 d7 ef d7 b6 b3 9c 68 // a1 6d 75 a7 85 2d fc 37 a6 a5 0c b2 8a 9b 6f 68 5a 46 be 14 // 01 a8 be 77 48 a7 1f cd c8 5b a2 04 9e 96 c4 e6 dc e5 9b 88 // cd 54 72 72 6b c2 37 fb cf 3f fc bf 32 e2 aa c9 b2 f9 d6 01 // 3b 59 78 0d ed 72 3b 08 c7 67 fa 09 1e 2f a4 d5 18 63 50 0f // cd 50 41 bc c9 8a 68 55 04 83 57 43 19 41 13 ea 0b 97 b4 f9 // dd c3 95 b9 ac 4d ef ef ad d3 7a 88 71 fd 91 f3 1a 56 eb 96 // ec f9 00 00 00 00 00 00 00 94 91 21 54 21 0d 72 7b 8e 9a 0d // ed 21 17 1a 98 60 c0 df df 84 14 2e 90 c0 87 5e 89 36 77 b1 // e5 bd 9c 1e e8 91 f4 80 90 0b 59 f2 5d d4 fe 84 a2 8e 59 9d // 41 dd de 4f 20 da 81 de a2 67 e9 3e 61 d0 fd ed 6b 60 ea b3 // 7d 44 01 05 99 58 70 e7 bb 21 64 04 7e d1 64 86 a0 14 d4 4c // f3 66 f2 91 5c bc 79 65 45 f3 6a f1 f7 b5 fd 8d fc cf e1 19 // a5 cd ba 78 a4 47 f1 06 84 4c 34 79 20 4f 57 4e fb 1f 00 ea // 24 b2 c5 14 c1 aa 38 85 7b be ed 63 17 59 e6 c1 2f 8f 0c df // 4b 45 c6 7a 4b 55 e3 33 0e f4 cb 71 8b b3 96 19 3a a8 9c 37 // d7 38 44 52 6b 9a 81 12 06 84 8a cf d8 88 a8 14 15 92 57 f4 // f9 ed ad e9 d0 e5 40 e8 a8 5e e4 e3 bb 03 a3 75 21 06 ec 75 // e5 35 10 76 0e b7 92 ce f6 3c 2a 38 bf 70 77 ba cd d7 74 6b // 7d dd 45 9e 7e c1 ef ee f1 90 1b 4b a6 9a 7a 51 7d 12 68 82 // 4b 48 c3 63 86 8f 91 99 aa 9f f1 0d b8 3d 34 d7 7b c1 44 a1 // 77 a0 a4 d6 07 41 f1 b5 7f df 5b ce e1 79 39 8f 27 aa 8a a0 // 4c 1e 62 7d 37 73 c3 7c 75 85 80 2b 8a d4 47 9f 84 46 fc f1 // 6a 8e 90 87 da bf 39 58 d6 99 df 49 58 5f d0 78 ec 2b fd 75 // ae a8 15 d5 be 6e 6b 93 05 7c df c6 42 65 a5 c6 82 4f 13 e3 // 95 1e e0 64 14 c7 c4 35 ba f7 6b 92 de 3a 4c bf 87 68 26 56 // 66 84 29 46 0a 6c 0d 38 65 9e b1 38 d9 c5 f4 a3 45 05 f1 4d // 3d 01 b9 c0 1d 42 e4 69 6b 01 c4 fe c6 fd 67 4f 61 a2 ae 8b // 27 bd c5 07 9b e4 09 58 af 02 86 00 8c 3c c3 84 4b 24 1d a1 // da c4 86 31 e2 39 94 e6 71 4d 61 d9 1d 3f d6 0b 74 1f 1f cf // 42 81 8e 45 ba 8a 94 9a 2d 5b dd df 2e ca 65 01 91 eb 0f 65 // 01 27 ef 31 01 ad 86 84 91 3a ae a7 58 ad 1d fd c0 78 f5 83 // 12 7a 24 94 ef 02 94 aa 0f 9a bf a4 c9 ee eb a1 68 19 df 44 // 42 02 aa 5e 6a d6 4d 63 08 d4 4f 50 86 63 32 6f 8c b6 e8 9a // 32 fc cd 56 cc 52 7b 38 2d 99 17 c9 5b 0f 61 2a 74 9d 5c 90 // dd bf 92 8a 8c 6c 3d d1 94 00 00 00 00 00 00} (length 0xd51) // } // } // } // license: ptr[in, buffer] { // buffer: {73 79 7a 6b 61 6c 6c 65 72 00} (length 0xa) // } // loglev: int32 = 0x4 (4 bytes) // logsize: len = 0x436 (4 bytes) // log: ptr[out, buffer] { // buffer: (DirOut) // } // kern_version: bpf_kern_version = 0x0 (4 bytes) // flags: bpf_prog_load_flags = 0x0 (4 bytes) // prog_name: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00} (length 0x10) prog_ifindex: ifindex (resource) // expected_attach_type: union bpf_prog_attach_types { // fallback: bpf_attach_types = 0x0 (4 bytes) // } // btf_fd: fd_btf (resource) // func_info_rec_size: const = 0x8 (4 bytes) // func_info: ptr[in, bpf_func_info] { // bpf_func_info { // insn_off: int32 = 0x0 (4 bytes) // type_id: int32 = 0x0 (4 bytes) // } // } // func_info_cnt: len = 0x7 (4 bytes) // line_info_rec_size: const = 0x10 (4 bytes) // line_info: nil // line_info_cnt: len = 0x0 (4 bytes) // attach_btf_id: bpf_btf_id (resource) // attach_prog_fd: fd_bpf_prog (resource) // core_relo_cnt: len = 0x0 (4 bytes) // fd_array: nil // core_relos: nil // core_relo_rec_size: const = 0x10 (4 bytes) // log_true_size: int32 = 0x0 (4 bytes) // prog_token_fd: union _bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], // fd_bpf_prog[opt]]_prog_token_fd_wrapper { // void: buffer: {} (length 0x0) // } // pad: union _bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], // fd_bpf_prog[opt]]_pad_wrapper { // value: const = 0x0 (4 bytes) // } // } // } // size: len = 0x48 (8 bytes) // ] // returns fd_bpf_prog *(uint32_t*)0x200000000100 = 1; *(uint32_t*)0x200000000104 = 3; *(uint64_t*)0x200000000108 = 0x2000000011c0; memcpy( (void*)0x2000000011c0, "\x18\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\xa0\x12\x54\x4f\x95" "\x00\x2b\x00\x00\x00\x00\x00\x93\xad\xff\xa8\x22\x55\xf6\x74\x41\x2d" "\x02\x00\x00\x00\x00\x00\x00\x5a\xb5\x27\xee\x36\x97\xf1\xed\x44\x36" "\xdd\x11\x64\xb1\xb3\xf4\x27\xf6\xba\x6b\x34\xf9\x81\x25\xf3\x0e\x63" "\x1d\x27\x36\x83\x62\x6e\x00\xdc\x25\x4d\x57\x0d\x4a\x6b\x78\xa5\x83" "\x34\x88\xcf\xe4\x10\x09\x00\x00\x00\x4a\xa9\x00\x00\x3d\x3c\xd6\x2f" "\x00\x15\x8e\x6e\xee\x85\x01\x00\x00\x00\x52\x0a\x00\x00\x15\x1d\x01" "\x00\x00\x00\x01\x00\xbf\x00\x00\x00\x00\x3b\xbd\x42\x4c\x6e\x6c\xaf" "\xbe\x93\x09\xab\xa2\x18\x81\x28\x68\xa5\x1d\x12\x9e\x78\xf6\xae\x17" "\x0b\xf5\xa5\x20\x01\xa3\xcd\x00\x00\x41\xf0\xdb\x74\x59\x6f\xd7\x2c" "\x00\x2a\x60\xc1\xbc\x7d\xc8\xc3\x8b\x00\x00\x24\xd8\x89\x77\x65\x2b" "\x36\xb9\xdd\x11\x45\xd0\x3f\xf4\x5f\x70\x68\x5c\x6b\xd9\xff\x41\xc6" "\x9b\x7d\xe4\x75\x8c\x10\x96\xa1\xdc\x52\xf2\x9e\x8b\x70\x1d\x2d\x17" "\xeb\xc4\x06\xe8\x9d\xcb\xb7\x67\x7e\x65\x28\xb0\x85\x6e\x31\xeb\x94" "\x74\xc0\x10\x6f\xc4\x8e\x1f\x8c\x1a\x5f\x69\x45\xac\x24\xcf\x60\x80" "\x68\xf6\xff\x21\xe8\x8b\x3c\xfc\x22\xdf\x01\xd5\x1e\x24\x24\x43\x61" "\x8c\x02\xe0\xa4\x28\xda\x65\x13\x66\xe4\xba\xc9\xd9\x73\x28\xfa\x2a" "\x82\xb5\xe8\x74\x1e\x02\x05\x6d\x93\x3b\xed\xf5\x9f\xf2\x32\xce\xbc" "\x68\xb9\x1a\xf5\x04\x79\x38\x74\x67\x82\x42\x62\x85\x2c\x79\x39\xdb" "\x56\x72\xd0\x7c\xdb\xe8\xe1\x48\xbf\x56\x49\x7e\x5d\x56\xd0\x6c\x75" "\x51\xb8\x70\xb2\x85\x1c\x3f\x0a\x1a\xab\x71\x58\xed\xee\xcc\xd9\x2e" "\x3a\x88\xdc\x0f\x43\x21\x87\xce\x92\xd7\xb1\x7a\x21\xc8\xf1\xb3\x36" "\x9e\xbf\xcb\x4c\xb2\x94\x66\x01\xb0\xf0\x4e\xdb\x25\x6c\x60\x4f\x06" "\x87\x73\xf6\xdb\x9d\x66\x1b\xd7\xf0\xe2\x53\x6f\x00\x00\x00\x00\x00" "\x00\x00\x00\x55\x21\x45\x8b\x7d\x1e\x34\x1c\x6f\x86\x4f\x98\x3d\x74" "\x5f\x58\x65\xaa\xd4\x1d\x29\x15\x8a\xe7\x60\x2a\x2d\x6c\xd4\x15\xe8" "\x35\x1e\xbc\x28\x3d\xf5\x4d\x6b\xec\x66\x47\x09\xff\x03\xf1\xaa\x3d" "\xc7\xf1\x58\x0a\xce\x9b\xf2\xaf\xd2\x8d\x71\x57\xe6\x7f\xb9\x8d\x12" "\x1a\x96\xeb\x37\x38\x45\x25\x50\x12\xe0\x28\xcb\x26\x54\xd4\x93\xa0" "\xb4\xb3\x5f\xaa\xe1\x76\xf9\x9b\x74\x5e\xda\x29\x67\x19\x9c\xc9\x36" "\x85\xbb\x53\x7e\x8e\x48\x71\xd4\xac\xf3\xe3\xdc\x10\xe1\x3e\xf2\x27" "\xf6\x27\xa4\x00\x00\xad\x1f\xa2\x53\xd3\x3f\xa7\x4f\x17\x2d\x00\x07" "\xae\x4e\x1e\x34\x7c\x0c\xff\x28\x23\x5a\x6b\xb7\xaa\x38\x04\xb9\x07" "\xa8\xf2\x88\x0c\x5c\xb1\xcb\x38\x5e\x6a\xdd\x14\x65\x20\x03\xc7\xcd" "\xd3\x32\x4f\x07\xd1\x34\xd3\xed\x07\xf1\xc1\x09\x00\x00\x00\x09\xdd" "\x87\x2e\xc6\x4f\xa6\xc7\x18\xbb\xd1\xaa\x59\x11\x40\xcf\xf0\xbe\x4c" "\x6f\x8d\xf0\x84\xc5\xe9\x73\x4a\xe3\x0a\xa9\xaf\xdc\x71\x25\xf0\x1a" "\xb0\x3a\x9b\x10\x74\x40\x71\x36\xb4\x50\x60\x00\xf0\x91\x6a\xad\xa0" "\x35\xdf\x2e\x04\x52\xa9\xb3\x9e\x73\xae\xeb\x6e\xaf\x14\x65\x2d\xda" "\x68\x9e\x20\x51\xd9\xb7\xeb\x85\xf3\xf2\xd5\xae\x2c\x51\x94\x4d\xa8" "\xd7\x39\x1d\x5b\x6b\x97\x41\x9a\x3b\x76\x60\x0c\xd1\xaa\x0a\xfe\x5f" "\x8f\x46\xdf\x4c\x51\x24\xca\x42\x5d\x37\x4b\x37\x18\x67\xa7\x9b\x31" "\xc6\x61\x7f\xc3\x32\x71\x91\xf3\xf5\x14\x57\x3f\x1e\x30\xd1\xfd\x2d" "\x76\x3f\x3e\xe9\x21\x8b\x15\xc1\xd6\x0b\xe2\x16\x8f\xff\xcd\x59\x9a" "\x2c\xb7\x7f\x12\x4e\x22\xf8\x76\x73\x67\x58\x05\x49\x4d\xb8\x21\xf3" "\x9b\x50\xd5\xfd\x8c\x6b\x2a\x3a\x32\x4c\x25\x7b\xc9\x7d\xef\x5f\x07" "\xf2\xb7\x7f\x05\xa4\xf8\x1a\x9c\xf8\x11\x09\x71\xb7\x49\xcc\xd7\x40" "\x89\xed\x6b\x86\xf8\x1c\xa3\xd2\x47\xd8\xf7\x1d\x29\x0e\xd1\xb1\xa1" "\x1f\x7a\x67\x12\x51\x70\xc8\x8c\x3b\x6a\x50\x69\x63\x32\x22\x64\x01" "\xb1\x10\xda\x9c\x44\x07\xec\xa2\x2d\xeb\xc9\x93\x35\x58\x3b\x00\x01" "\x3c\x31\x30\x97\x8f\xa0\x69\xaf\x82\x23\xb3\x8c\xed\x73\x5c\x2d\x90" "\xc6\xd8\x4c\x30\xa0\xd8\x7d\x42\x64\x74\x89\xb3\x96\x01\xbe\x5c\x27" "\x69\x6c\xf2\xf1\x66\x25\xc0\xc1\x02\x00\x00\x00\x00\x00\x00\x00\x09" "\x00\x00\x00\x84\x2e\x64\x17\x1f\x39\x63\x84\x10\x86\xe3\x79\x7a\x48" "\x25\xd0\x81\xf2\x40\x08\x00\x00\x53\x41\x87\x73\x86\x55\xd7\xa6\x24" "\x04\x12\xc8\xf2\x83\xcc\x0c\x1e\xba\x28\x66\xdc\x95\x80\x00\x00\x00" "\x00\x00\x00\x00\x7f\xff\xff\xff\xff\x55\x4b\x82\xd9\xc1\x62\xf3\x55" "\x60\x76\xb8\x05\x52\xd9\x61\xca\x74\xd1\xff\xda\xcc\xf0\xea\x5f\x02" "\xe0\x16\x3a\x9c\xcb\x90\x87\xe6\xc3\xb3\x91\x7b\xb7\x4f\xd3\xd5\x60" "\x70\x0a\x1f\xab\x44\xe7\x7e\x31\x2b\x3b\x12\x9e\x00\x03\x02\xd6\x13" "\x91\x6c\x9b\xcf\x9f\x00\x00\xfa\xc7\x3a\x5b\x6b\xfb\x01\xef\xad\xa8" "\x00\xe5\x00\x00\x00\x00\x00\xfd\xaf\x2f\x7b\x3b\x79\xa4\x33\xe0\x80" "\x74\xea\x24\x62\x97\x4a\xb2\xcb\xd2\x47\xeb\x1c\xfa\x26\x38\xf5\x6d" "\xae\xe5\x7e\xd1\x4b\xc7\x4d\xe0\xfd\x87\xa9\xce\x63\x81\x90\xf3\x57" "\x0e\x0b\x4c\x80\xef\x68\x2d\xf2\x22\x37\x27\x09\x55\xaf\xb6\x00\x88" "\x46\x55\x7e\xe3\xbc\x09\xfd\xa6\xdb\xb6\x55\x0d\x59\x73\x00\xeb\x82" "\xa1\x84\xc9\x6f\xfd\xe5\xa3\x0e\x54\x33\xd8\x66\x66\x5b\x98\xca\x20" "\x02\xc8\x36\xe8\x9f\xee\xf9\x04\xc2\x2f\xf2\x63\x4b\x7b\xfb\xf5\xc0" "\xd5\x86\xcd\xa5\xb4\x5f\xd0\x0d\xed\xe1\xe8\x8a\x4d\x41\xde\xe7\xcc" "\x8d\x08\x34\xfb\x8d\x12\x46\x38\xfe\xc5\x8f\xae\xb4\xc1\x6a\xbb\x44" "\x0d\xf2\xa6\x94\xf4\xcd\xca\xa4\xf6\x5c\x22\xf0\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\xd5\x03\xd7\x99\x06\x95\x81\x02\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\xff\xf0\xef\x89\xb2\xa6\x8d" "\x2b\xb2\xdd\x16\x3e\x86\x33\x14\xe8\x44\x98\x01\xb5\x2b\xb9\x3f\x6c" "\x90\x84\x65\x9c\xe7\x77\xdd\xa8\x56\x3c\x85\x96\x56\xa3\x57\x77\x02" "\x89\xa6\x1f\xaa\x95\xa8\x2b\xf1\xcf\xb7\xf2\xf9\x72\x52\xe9\x32\x2a" "\xbe\x28\x2c\x33\x44\xfc\x67\x38\xb4\x46\x78\x93\xb9\xbf\x0d\x1c\x81" "\x30\xae\x6b\x00\x11\x06\x2a\x35\x37\x64\x13\xc2\x9f\x7c\x6f\x7b\xde" "\x29\xb9\xf4\xbd\xdd\x5e\x32\x86\x61\xf4\x61\x5e\x62\x7a\x6f\x60\x8a" "\xd5\x3a\x41\x68\xfe\x8e\x5d\x7d\x93\x4a\xa2\x89\xb4\xbd\x2b\x87\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfc\x4b\x4f\xf5" "\x00\x00\x00\x9b\x77\x78\x83\xa0\x2f\xfd\x92\xdf\xc4\xcb\x41\x14\xb9" "\xf9\xcf\x4a\xd1\x55\x11\x0c\xd3\xac\xe2\xb3\x22\xae\x31\xbf\xa2\x78" "\x47\xc7\x99\xc8\x86\x9a\x1e\xa5\xb9\x8e\x52\x5e\x63\x83\xad\x7f\xd9" "\x79\x51\x70\xe7\xb1\x1e\x24\x76\x03\x00\x00\x00\x00\x14\x59\xc7\xf6" "\x06\xd7\x21\xd3\x97\x96\x76\xbf\xfb\x30\x49\x16\x6a\xb8\x4a\xc1\x06" "\x19\x91\xbd\x57\xc2\x56\x6c\x10\xc2\x96\x4e\x3f\x24\x91\xe4\x79\x3e" "\x2b\x70\x59\x0d\xcc\x71\xf1\x10\xda\x96\x36\x6c\x40\xdd\x44\xa2\xc9" "\x88\x2d\x3a\xa0\xf8\xa7\x97\xb8\xfe\xa6\xef\xcf\xb5\x27\x6b\x76\x79" "\xf1\x55\x59\xcd\xaa\xbf\x5f\xc1\x4a\xdd\x71\xd0\xbc\xa3\x74\x05\xde" "\xd6\x9b\x77\xab\x4a\x3d\x74\x87\xfd\x50\xc5\xe2\x2a\xde\xf9\x54\x6a" "\xbb\x7a\x2d\x9c\x08\x5b\x18\x9b\x5f\xf3\x0e\x4e\x0c\x13\xf6\x08\x70" "\xfd\xe1\xf8\x8d\x83\x0b\x11\x00\x21\x35\xe8\xe7\x26\x2f\x29\xb6\xd7" "\x92\x3b\xfb\xe0\xbd\x2a\x8b\xe1\x79\xe5\x6b\x41\xff\x37\x92\xce\xe2" "\xfc\x37\xee\xe7\x39\xc3\x54\xf3\xa0\x0f\x9d\x8d\x99\x21\xaa\xfc\x85" "\x56\x7e\xc9\x83\x00\x8c\xe7\x40\xd8\x80\x4f\x8e\x70\x5f\x0d\xc5\x9d" "\x00\x00\x21\x36\x3e\x8d\xf9\x4f\xfa\x75\xb4\x8d\xc8\xc1\x2d\xef\x68" "\x1a\x11\x64\x79\x46\x59\x54\x45\xbf\x1c\xb7\xd2\x77\x8c\xd2\x7a\x6b" "\x3b\x29\x66\xb0\x8b\xe6\x00\x00\x00\x20\xa8\xa7\x11\xd1\x93\xba\xe0" "\xab\x2d\xb9\xed\x9c\x6c\xb3\xc3\xde\x42\xab\x89\x52\x44\x14\xca\xe9" "\x22\x14\x1f\x7b\xaf\x17\xeb\xb7\x90\xad\x60\xbd\x03\x87\x0c\x39\xd1" "\xad\x12\xc7\x50\x83\x7e\x63\xf9\x88\x0f\xd7\x02\x59\xe3\x55\x90\xaf" "\xb4\x84\x3c\xd4\xe9\x98\x93\x98\xea\xa8\xaf\xef\xb3\xaa\x13\xca\xb8" "\xd0\x15\xcb\xaf\x15\x61\xd9\x53\x62\xde\xdd\x73\xb8\xf8\xcb\xf8\x26" "\x9c\xac\x09\x1c\xfa\xaa\x3c\x7e\x46\xd6\xe7\x91\x45\xfc\x0f\x1d\x1b" "\x38\x37\x52\xcc\xb4\x05\x15\xa7\x72\x35\x6d\x74\x69\x14\x54\x02\x16" "\xad\xf4\xaf\xa2\x52\x72\x0e\xc6\xda\xd3\xa9\x86\x71\xec\xda\xff\x46" "\xcd\xdf\xfb\x1f\x05\xa0\xc0\x97\x60\x70\xd6\x03\xa4\x42\xd0\x14\x82" "\x23\x69\xfa\x3e\xac\xbb\x69\xbd\x1b\x0a\x07\x43\x57\xac\xd5\xd0\x21" "\x61\xfe\xd1\x46\xad\x3a\xa1\x5d\x2b\x81\x01\xb7\xbd\x1e\x09\x1a\xda" "\x78\xec\xd5\x01\x81\xf4\xb3\x5c\xae\x1b\x29\xaf\xf9\x14\x94\xc9\x16" "\x32\x3b\x61\xf8\x15\xc4\xe0\x70\x16\x57\x08\x7a\xd1\x1e\xef\x97\x95" "\x29\x21\x36\x5b\xc8\x98\xba\x2c\x76\xa9\xb6\xe0\x05\x2f\x43\xb1\xad" "\x2d\xfd\xf3\xf9\x58\xfc\x1d\x32\xe6\x92\xbc\x88\x46\xc7\x8a\x95\x6a" "\xda\x45\x3c\x67\xc1\xc2\xcd\xc4\xf8\xb1\xc9\x4e\x9a\xdc\x10\x6e\x85" "\xb3\x1e\x03\x0d\x95\x5c\x55\x78\xe1\x07\xa6\xe8\xca\x0d\x4d\xd0\x53" "\x44\xc3\xe2\xaf\x25\xd9\xa3\xb0\xf7\x80\x56\x24\x01\x6a\xea\xb2\x71" "\xa7\x5f\x0b\xac\xb1\x01\xa1\x56\xef\x89\x48\x06\x45\x69\x15\x4a\x7d" "\xe0\x8f\x80\xe4\xdf\x4c\x33\x9b\x69\x43\x1b\x0a\x56\x71\x09\x7d\x89" "\x21\x2b\x46\x5b\x0b\x32\x27\x5d\xea\xe1\x0a\x77\xe3\x34\xc9\xfc\x07" "\x4d\x18\x1b\xde\xb5\xbe\x80\xa6\x24\x9d\x47\x2e\x78\xe6\xbe\x57\xa5" "\xcc\xd3\x54\xcf\x18\x1e\x09\x96\x05\xa6\x44\xec\xad\xe2\x21\xa2\xbe" "\x92\x62\x10\xb2\x69\x0d\x09\xe4\xb7\xa3\xde\xa2\x54\x03\x39\x74\x39" "\x97\x9c\x27\xd5\x61\x32\x62\xde\x10\xba\xce\xcf\xff\x2d\x58\x43\x7f" "\x42\x2d\xf4\x25\x2c\x01\x87\x95\x31\x0c\x25\xe8\xfc\xe1\x8e\xd3\x66" "\xac\x2c\xaa\xde\x56\x4c\xa8\x69\x72\x7a\x7d\x63\xc2\x62\x71\xe1\x7d" "\x7a\xba\x48\x97\x18\x35\x53\x03\x11\x54\x52\x73\xd3\xca\xad\xeb\x5d" "\x20\x17\xdc\xdd\xab\x8f\x38\xf2\x06\x8f\x68\xa4\x11\x1d\xdd\x58\x7b" "\x5d\xf4\xb5\xd8\xf1\xce\x00\x23\x1a\x20\x92\xeb\x2e\x79\x7c\x49\x1a" "\x1e\x66\xf7\x36\x06\xfd\x95\xbb\xe0\xf1\x05\x21\x86\x2b\x62\x62\xf0" "\x25\x9d\xa5\x1f\xf7\x51\x7a\xce\x73\x61\x46\x0a\x46\x69\xa9\x7f\x7d" "\x0b\xf0\x95\xc2\x78\x7f\x00\xbd\xbf\xee\x19\x67\x0d\x1e\x0e\xc5\xe6" "\xc3\xcb\x09\x97\x2f\xa4\xd9\x49\x86\x15\x7b\x96\xd6\x69\x51\x77\xc9" "\x9d\x83\x71\x66\x51\x12\x93\x20\x92\x43\x52\xcd\xa7\xb8\xea\xd9\x1c" "\x33\x01\xaf\x62\x0c\x1e\x8d\x70\x3d\xd2\x9a\xd7\x7f\x54\x83\x67\x79" "\x60\x0b\xb0\xdb\x3e\xcf\xbd\x36\xfa\x81\x64\xfa\xbd\xcf\x2e\x58\xb7" "\x20\xe8\xe1\xc0\x3a\x74\xda\xf5\x93\xf9\x2a\x8e\xcc\x03\xf8\xc8\xe3" "\xaf\x9a\xe0\x7d\xc0\x37\x80\xcc\x0d\x69\x00\x00\x00\x00\x00\x00\x00" "\x00\x19\x98\x73\x19\x92\xce\xb2\x7d\xcc\x0b\xe5\xbe\x4d\xec\xef\xe4" "\x1b\x78\xbc\x18\x47\xbf\x54\xb0\x87\xe0\x95\x17\x2f\x06\xcf\xa6\xd4" "\xbf\x95\x8b\x1d\x45\x44\x94\x7f\xf1\x23\x06\x55\x19\x9d\xb4\xf4\x75" "\x00\x60\x47\xfe\x83\xca\xca\x97\x75\x8d\xff\xa5\x3c\xee\x76\x4f\x85" "\x93\x2e\xb2\x0d\x54\x24\x1b\x2d\x51\x5c\x08\x26\xdf\xe1\xf0\xf4\x0a" "\xe9\x20\x45\x5a\x45\x48\xfb\x35\xe2\xa3\x45\xc0\x5b\x1c\x25\x2b\x78" "\x77\xbb\x3d\x83\x4b\x0b\x35\x79\xa3\x62\x49\x14\x6f\x83\x2e\xf2\x58" "\xdf\x51\x27\x31\x8c\x70\x17\xac\x1a\x99\x6c\x4f\x90\x2f\x82\xde\xb6" "\x0f\xd1\x13\xcc\xf8\x12\xd5\x5f\xfd\x62\x50\x57\xbd\x4f\xf3\x96\x09" "\x92\xb8\x5b\xc8\xd3\x2e\xdf\xca\x38\x6b\xe1\x6b\x1c\x54\x9a\xec\x52" "\xe3\x1e\x14\x05\xf8\x6c\x77\x60\x28\x29\x01\x75\x0b\x73\x2e\xc0\x6b" "\x0d\xb7\x35\x22\x2a\x56\xf3\xeb\xb1\x6f\xad\x3e\x92\x69\x49\x52\x30" "\xcd\x88\xb0\xea\x2e\x3a\xff\xa1\x96\xa2\xf0\xad\xf7\x33\xbc\x6a\xfd" "\x37\xa6\x59\xec\xc9\x33\xd6\x36\xc1\xb2\x7d\x3a\x16\xc5\xea\x25\x30" "\x1f\x9b\x57\x89\xe4\xaa\x8e\x72\x28\xe3\x00\x2f\x14\x6a\xa5\xe5\x75" "\xbb\x74\xb1\xeb\xb8\x21\x47\xed\xf8\x16\x1d\x36\x27\x04\x37\x70\x58" "\xe8\x87\xc6\x08\xbe\x87\x19\xea\x1b\x6c\x49\x0f\x79\xe0\x83\x2e\x2d" "\xdd\x7e\x21\x7c\x7a\xdd\xdd\x47\x31\xe0\x32\xd7\xeb\x35\xbd\xc3\x81" "\x60\xc6\x76\xd8\x40\xe2\xe8\xbe\x90\x33\xa6\x86\xcf\x70\x61\xf5\xf5" "\x5e\x28\x51\x73\x6a\x04\x00\xf3\xba\xd8\xac\x05\xc0\x48\xe2\x0d\x8c" "\x03\xb6\x80\x08\xa7\x0b\x8f\x80\xc9\x3e\xbd\x2a\xba\xbb\x5c\x65\xfe" "\x9a\xbc\x46\x42\xd7\xef\xd7\xb6\xb3\x9c\x68\xa1\x6d\x75\xa7\x85\x2d" "\xfc\x37\xa6\xa5\x0c\xb2\x8a\x9b\x6f\x68\x5a\x46\xbe\x14\x01\xa8\xbe" "\x77\x48\xa7\x1f\xcd\xc8\x5b\xa2\x04\x9e\x96\xc4\xe6\xdc\xe5\x9b\x88" "\xcd\x54\x72\x72\x6b\xc2\x37\xfb\xcf\x3f\xfc\xbf\x32\xe2\xaa\xc9\xb2" "\xf9\xd6\x01\x3b\x59\x78\x0d\xed\x72\x3b\x08\xc7\x67\xfa\x09\x1e\x2f" "\xa4\xd5\x18\x63\x50\x0f\xcd\x50\x41\xbc\xc9\x8a\x68\x55\x04\x83\x57" "\x43\x19\x41\x13\xea\x0b\x97\xb4\xf9\xdd\xc3\x95\xb9\xac\x4d\xef\xef" "\xad\xd3\x7a\x88\x71\xfd\x91\xf3\x1a\x56\xeb\x96\xec\xf9\x00\x00\x00" "\x00\x00\x00\x00\x94\x91\x21\x54\x21\x0d\x72\x7b\x8e\x9a\x0d\xed\x21" "\x17\x1a\x98\x60\xc0\xdf\xdf\x84\x14\x2e\x90\xc0\x87\x5e\x89\x36\x77" "\xb1\xe5\xbd\x9c\x1e\xe8\x91\xf4\x80\x90\x0b\x59\xf2\x5d\xd4\xfe\x84" "\xa2\x8e\x59\x9d\x41\xdd\xde\x4f\x20\xda\x81\xde\xa2\x67\xe9\x3e\x61" "\xd0\xfd\xed\x6b\x60\xea\xb3\x7d\x44\x01\x05\x99\x58\x70\xe7\xbb\x21" "\x64\x04\x7e\xd1\x64\x86\xa0\x14\xd4\x4c\xf3\x66\xf2\x91\x5c\xbc\x79" "\x65\x45\xf3\x6a\xf1\xf7\xb5\xfd\x8d\xfc\xcf\xe1\x19\xa5\xcd\xba\x78" "\xa4\x47\xf1\x06\x84\x4c\x34\x79\x20\x4f\x57\x4e\xfb\x1f\x00\xea\x24" "\xb2\xc5\x14\xc1\xaa\x38\x85\x7b\xbe\xed\x63\x17\x59\xe6\xc1\x2f\x8f" "\x0c\xdf\x4b\x45\xc6\x7a\x4b\x55\xe3\x33\x0e\xf4\xcb\x71\x8b\xb3\x96" "\x19\x3a\xa8\x9c\x37\xd7\x38\x44\x52\x6b\x9a\x81\x12\x06\x84\x8a\xcf" "\xd8\x88\xa8\x14\x15\x92\x57\xf4\xf9\xed\xad\xe9\xd0\xe5\x40\xe8\xa8" "\x5e\xe4\xe3\xbb\x03\xa3\x75\x21\x06\xec\x75\xe5\x35\x10\x76\x0e\xb7" "\x92\xce\xf6\x3c\x2a\x38\xbf\x70\x77\xba\xcd\xd7\x74\x6b\x7d\xdd\x45" "\x9e\x7e\xc1\xef\xee\xf1\x90\x1b\x4b\xa6\x9a\x7a\x51\x7d\x12\x68\x82" "\x4b\x48\xc3\x63\x86\x8f\x91\x99\xaa\x9f\xf1\x0d\xb8\x3d\x34\xd7\x7b" "\xc1\x44\xa1\x77\xa0\xa4\xd6\x07\x41\xf1\xb5\x7f\xdf\x5b\xce\xe1\x79" "\x39\x8f\x27\xaa\x8a\xa0\x4c\x1e\x62\x7d\x37\x73\xc3\x7c\x75\x85\x80" "\x2b\x8a\xd4\x47\x9f\x84\x46\xfc\xf1\x6a\x8e\x90\x87\xda\xbf\x39\x58" "\xd6\x99\xdf\x49\x58\x5f\xd0\x78\xec\x2b\xfd\x75\xae\xa8\x15\xd5\xbe" "\x6e\x6b\x93\x05\x7c\xdf\xc6\x42\x65\xa5\xc6\x82\x4f\x13\xe3\x95\x1e" "\xe0\x64\x14\xc7\xc4\x35\xba\xf7\x6b\x92\xde\x3a\x4c\xbf\x87\x68\x26" "\x56\x66\x84\x29\x46\x0a\x6c\x0d\x38\x65\x9e\xb1\x38\xd9\xc5\xf4\xa3" "\x45\x05\xf1\x4d\x3d\x01\xb9\xc0\x1d\x42\xe4\x69\x6b\x01\xc4\xfe\xc6" "\xfd\x67\x4f\x61\xa2\xae\x8b\x27\xbd\xc5\x07\x9b\xe4\x09\x58\xaf\x02" "\x86\x00\x8c\x3c\xc3\x84\x4b\x24\x1d\xa1\xda\xc4\x86\x31\xe2\x39\x94" "\xe6\x71\x4d\x61\xd9\x1d\x3f\xd6\x0b\x74\x1f\x1f\xcf\x42\x81\x8e\x45" "\xba\x8a\x94\x9a\x2d\x5b\xdd\xdf\x2e\xca\x65\x01\x91\xeb\x0f\x65\x01" "\x27\xef\x31\x01\xad\x86\x84\x91\x3a\xae\xa7\x58\xad\x1d\xfd\xc0\x78" "\xf5\x83\x12\x7a\x24\x94\xef\x02\x94\xaa\x0f\x9a\xbf\xa4\xc9\xee\xeb" "\xa1\x68\x19\xdf\x44\x42\x02\xaa\x5e\x6a\xd6\x4d\x63\x08\xd4\x4f\x50" "\x86\x63\x32\x6f\x8c\xb6\xe8\x9a\x32\xfc\xcd\x56\xcc\x52\x7b\x38\x2d" "\x99\x17\xc9\x5b\x0f\x61\x2a\x74\x9d\x5c\x90\xdd\xbf\x92\x8a\x8c\x6c" "\x3d\xd1\x94\x00\x00\x00\x00\x00\x00", 3409); *(uint64_t*)0x200000000110 = 0x2000002bf000; memcpy((void*)0x2000002bf000, "syzkaller\000", 10); *(uint32_t*)0x200000000118 = 4; *(uint32_t*)0x20000000011c = 0x436; *(uint64_t*)0x200000000120 = 0x200000000040; *(uint32_t*)0x200000000128 = 0; *(uint32_t*)0x20000000012c = 0; memset((void*)0x200000000130, 0, 16); *(uint32_t*)0x200000000140 = 0; *(uint32_t*)0x200000000144 = 0; *(uint32_t*)0x200000000148 = -1; *(uint32_t*)0x20000000014c = 8; *(uint64_t*)0x200000000150 = 0x200000000000; *(uint32_t*)0x200000000000 = 0; *(uint32_t*)0x200000000004 = 0; *(uint32_t*)0x200000000158 = 7; *(uint32_t*)0x20000000015c = 0x10; *(uint64_t*)0x200000000160 = 0; *(uint32_t*)0x200000000168 = 0; *(uint32_t*)0x20000000016c = 0; *(uint32_t*)0x200000000170 = -1; *(uint32_t*)0x200000000174 = 0; *(uint64_t*)0x200000000178 = 0; *(uint64_t*)0x200000000180 = 0; *(uint32_t*)0x200000000188 = 0x10; *(uint32_t*)0x20000000018c = 0; *(uint32_t*)0x200000000190 = 0; res = syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0x200000000100ul, /*size=*/0x48ul); if (res != -1) r[1] = res; break; case 4: // openat$cgroup_ro arguments: [ // fd: fd_cgroup (resource) // file: ptr[in, buffer] { // buffer: {6e 65 74 5f 70 72 69 6f 2e 70 72 69 6f 69 64 78 00} (length // 0x11) // } // flags: const = 0x275a (4 bytes) // mode: const = 0x0 (2 bytes) // ] // returns fd memcpy((void*)0x200000000180, "net_prio.prioidx\000", 17); res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x200000000180ul, /*flags=*/0x275a, /*mode=*/0); if (res != -1) r[2] = res; break; case 5: // write$binfmt_script arguments: [ // fd: fd_binfmt (resource) // data: ptr[in, binfmt_script] { // binfmt_script { // hdr: buffer: {23 21 20} (length 0x3) // bin: buffer: {} (length 0x0) // args: array[binfmt_script_arg] { // } // nl: const = 0xa (1 bytes) // data: buffer: {} (length 0x0) // } // } // len: bytesize = 0x208e24b (8 bytes) // ] memcpy((void*)0x200000000400, "#! ", 3); *(uint8_t*)0x200000000403 = 0xa; syscall(__NR_write, /*fd=*/r[2], /*data=*/0x200000000400ul, /*len=*/0x208e24bul); break; case 6: // mmap arguments: [ // addr: VMA[0xb36000] // len: len = 0xb36000 (8 bytes) // prot: mmap_prot = 0x2 (8 bytes) // flags: mmap_flags = 0x28011 (8 bytes) // fd: fd (resource) // offset: intptr = 0x0 (8 bytes) // ] syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0xb36000ul, /*prot=PROT_WRITE*/ 2ul, /*flags=MAP_STACK|MAP_POPULATE|MAP_FIXED|MAP_SHARED*/ 0x28011ul, /*fd=*/r[2], /*offset=*/0ul); break; case 7: // socket$kcm arguments: [ // domain: const = 0x29 (8 bytes) // type: kcm_socket_type = 0x5 (8 bytes) // proto: const = 0x0 (4 bytes) // ] // returns sock_kcm res = syscall(__NR_socket, /*domain=*/0x29ul, /*type=SOCK_SEQPACKET*/ 5ul, /*proto=*/0); if (res != -1) r[3] = res; break; case 8: // ioctl$sock_kcm_SIOCKCMATTACH arguments: [ // fd: sock_kcm (resource) // cmd: const = 0x89e0 (4 bytes) // arg: ptr[in, kcm_attach] { // kcm_attach { // fd: sock (resource) // bpf_fd: fd_bpf_prog (resource) // } // } // ] *(uint32_t*)0x200000000180 = r[0]; *(uint32_t*)0x200000000184 = r[1]; syscall(__NR_ioctl, /*fd=*/r[3], /*cmd=*/0x89e0, /*arg=*/0x200000000180ul); break; case 9: // sendmsg$rds arguments: [ // fd: sock_rds (resource) // msg: ptr[in, msghdr_rds] { // msghdr_rds { // addr: nil // addrlen: len = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // vec: ptr[in, array[iovec[out, array[int8]]]] { // array[iovec[out, array[int8]]] { // iovec[out, array[int8]] { // addr: ptr[out, buffer] { // buffer: (DirOut) // } // len: len = 0xfffffe09 (8 bytes) // } // } // } // vlen: len = 0x1 (8 bytes) // ctrl: nil // ctrllen: bytesize = 0x0 (8 bytes) // f: send_flags = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // } // } // f: send_flags = 0x0 (8 bytes) // ] *(uint64_t*)0x200000002940 = 0; *(uint32_t*)0x200000002948 = 0; *(uint64_t*)0x200000002950 = 0x200000002800; *(uint64_t*)0x200000002800 = 0x200000002980; *(uint64_t*)0x200000002808 = 0xfffffe09; *(uint64_t*)0x200000002958 = 1; *(uint64_t*)0x200000002960 = 0; *(uint64_t*)0x200000002968 = 0; *(uint32_t*)0x200000002970 = 0; syscall(__NR_sendmsg, /*fd=*/r[3], /*msg=*/0x200000002940ul, /*f=*/0ul); break; case 10: // write arguments: [ // fd: fd (resource) // buf: nil // count: len = 0x0 (8 bytes) // ] syscall(__NR_write, /*fd=*/r[3], /*buf=*/0ul, /*count=*/0ul); break; } } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); const char* reason; (void)reason; for (procid = 0; procid < 5; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; }