// https://syzkaller.appspot.com/bug?id=8598354fc7b4b890dd8ef75f7dd1c19f769ca784 // 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 #ifndef __NR_memfd_create #define __NR_memfd_create 319 #endif static unsigned long long procid; 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 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 struct nlmsg nlmsg; #define WIFI_INITIAL_DEVICE_COUNT 2 #define WIFI_MAC_BASE \ { \ 0x08, 0x02, 0x11, 0x00, 0x00, 0x00 \ } #define WIFI_IBSS_BSSID \ { \ 0x50, 0x50, 0x50, 0x50, 0x50, 0x50 \ } #define WIFI_IBSS_SSID \ { \ 0x10, 0x10, 0x10, 0x10, 0x10, 0x10 \ } #define WIFI_DEFAULT_FREQUENCY 2412 #define WIFI_DEFAULT_SIGNAL 0 #define WIFI_DEFAULT_RX_RATE 1 #define HWSIM_CMD_REGISTER 1 #define HWSIM_CMD_FRAME 2 #define HWSIM_CMD_NEW_RADIO 4 #define HWSIM_ATTR_SUPPORT_P2P_DEVICE 14 #define HWSIM_ATTR_PERM_ADDR 22 #define IF_OPER_UP 6 struct join_ibss_props { int wiphy_freq; bool wiphy_freq_fixed; uint8_t* mac; uint8_t* ssid; int ssid_len; }; static int set_interface_state(const char* interface_name, int on) { struct ifreq ifr; int sock = socket(AF_INET, SOCK_DGRAM, 0); if (sock < 0) { return -1; } memset(&ifr, 0, sizeof(ifr)); strcpy(ifr.ifr_name, interface_name); int ret = ioctl(sock, SIOCGIFFLAGS, &ifr); if (ret < 0) { close(sock); return -1; } if (on) ifr.ifr_flags |= IFF_UP; else ifr.ifr_flags &= ~IFF_UP; ret = ioctl(sock, SIOCSIFFLAGS, &ifr); close(sock); if (ret < 0) { return -1; } return 0; } static int nl80211_set_interface(struct nlmsg* nlmsg, int sock, int nl80211_family, uint32_t ifindex, uint32_t iftype) { struct genlmsghdr genlhdr; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = NL80211_CMD_SET_INTERFACE; netlink_init(nlmsg, nl80211_family, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(nlmsg, NL80211_ATTR_IFINDEX, &ifindex, sizeof(ifindex)); netlink_attr(nlmsg, NL80211_ATTR_IFTYPE, &iftype, sizeof(iftype)); int err = netlink_send(nlmsg, sock); if (err < 0) { } return err; } static int nl80211_join_ibss(struct nlmsg* nlmsg, int sock, int nl80211_family, uint32_t ifindex, struct join_ibss_props* props) { struct genlmsghdr genlhdr; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = NL80211_CMD_JOIN_IBSS; netlink_init(nlmsg, nl80211_family, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(nlmsg, NL80211_ATTR_IFINDEX, &ifindex, sizeof(ifindex)); netlink_attr(nlmsg, NL80211_ATTR_SSID, props->ssid, props->ssid_len); netlink_attr(nlmsg, NL80211_ATTR_WIPHY_FREQ, &(props->wiphy_freq), sizeof(props->wiphy_freq)); if (props->mac) netlink_attr(nlmsg, NL80211_ATTR_MAC, props->mac, ETH_ALEN); if (props->wiphy_freq_fixed) netlink_attr(nlmsg, NL80211_ATTR_FREQ_FIXED, NULL, 0); int err = netlink_send(nlmsg, sock); if (err < 0) { } return err; } static int get_ifla_operstate(struct nlmsg* nlmsg, int ifindex) { struct ifinfomsg info; memset(&info, 0, sizeof(info)); info.ifi_family = AF_UNSPEC; info.ifi_index = ifindex; int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) { return -1; } netlink_init(nlmsg, RTM_GETLINK, 0, &info, sizeof(info)); int n; int err = netlink_send_ext(nlmsg, sock, RTM_NEWLINK, &n, true); close(sock); if (err) { return -1; } struct rtattr* attr = IFLA_RTA(NLMSG_DATA(nlmsg->buf)); for (; RTA_OK(attr, n); attr = RTA_NEXT(attr, n)) { if (attr->rta_type == IFLA_OPERSTATE) return *((int32_t*)RTA_DATA(attr)); } return -1; } static int await_ifla_operstate(struct nlmsg* nlmsg, char* interface, int operstate) { int ifindex = if_nametoindex(interface); while (true) { usleep(1000); int ret = get_ifla_operstate(nlmsg, ifindex); if (ret < 0) return ret; if (ret == operstate) return 0; } return 0; } static int nl80211_setup_ibss_interface(struct nlmsg* nlmsg, int sock, int nl80211_family_id, char* interface, struct join_ibss_props* ibss_props) { int ifindex = if_nametoindex(interface); if (ifindex == 0) { return -1; } int ret = nl80211_set_interface(nlmsg, sock, nl80211_family_id, ifindex, NL80211_IFTYPE_ADHOC); if (ret < 0) { return -1; } ret = set_interface_state(interface, 1); if (ret < 0) { return -1; } ret = nl80211_join_ibss(nlmsg, sock, nl80211_family_id, ifindex, ibss_props); if (ret < 0) { return -1; } return 0; } static int hwsim80211_create_device(struct nlmsg* nlmsg, int sock, int hwsim_family, uint8_t mac_addr[ETH_ALEN]) { struct genlmsghdr genlhdr; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = HWSIM_CMD_NEW_RADIO; netlink_init(nlmsg, hwsim_family, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(nlmsg, HWSIM_ATTR_SUPPORT_P2P_DEVICE, NULL, 0); netlink_attr(nlmsg, HWSIM_ATTR_PERM_ADDR, mac_addr, ETH_ALEN); int err = netlink_send(nlmsg, sock); if (err < 0) { } return err; } static void initialize_wifi_devices(void) { int rfkill = open("/dev/rfkill", O_RDWR); if (rfkill == -1) { if (errno != ENOENT && errno != EACCES) exit(1); } else { struct rfkill_event event = {0}; event.type = RFKILL_TYPE_ALL; event.op = RFKILL_OP_CHANGE_ALL; if (write(rfkill, &event, sizeof(event)) != (ssize_t)(sizeof(event))) exit(1); close(rfkill); } uint8_t mac_addr[6] = WIFI_MAC_BASE; int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC); if (sock < 0) { return; } int hwsim_family_id = netlink_query_family_id(&nlmsg, sock, "MAC80211_HWSIM", true); int nl80211_family_id = netlink_query_family_id(&nlmsg, sock, "nl80211", true); uint8_t ssid[] = WIFI_IBSS_SSID; uint8_t bssid[] = WIFI_IBSS_BSSID; struct join_ibss_props ibss_props = {.wiphy_freq = WIFI_DEFAULT_FREQUENCY, .wiphy_freq_fixed = true, .mac = bssid, .ssid = ssid, .ssid_len = sizeof(ssid)}; for (int device_id = 0; device_id < WIFI_INITIAL_DEVICE_COUNT; device_id++) { mac_addr[5] = device_id; int ret = hwsim80211_create_device(&nlmsg, sock, hwsim_family_id, mac_addr); if (ret < 0) exit(1); char interface[6] = "wlan0"; interface[4] += device_id; if (nl80211_setup_ibss_interface(&nlmsg, sock, nl80211_family_id, interface, &ibss_props) < 0) exit(1); } for (int device_id = 0; device_id < WIFI_INITIAL_DEVICE_COUNT; device_id++) { char interface[6] = "wlan0"; interface[4] += device_id; int ret = await_ifla_operstate(&nlmsg, interface, IF_OPER_UP); if (ret < 0) exit(1); } close(sock); } //% This code is derived from puff.{c,h}, found in the zlib development. The //% original files come with the following copyright notice: //% Copyright (C) 2002-2013 Mark Adler, all rights reserved //% version 2.3, 21 Jan 2013 //% This software is provided 'as-is', without any express or implied //% warranty. In no event will the author be held liable for any damages //% arising from the use of this software. //% Permission is granted to anyone to use this software for any purpose, //% including commercial applications, and to alter it and redistribute it //% freely, subject to the following restrictions: //% 1. The origin of this software must not be misrepresented; you must not //% claim that you wrote the original software. If you use this software //% in a product, an acknowledgment in the product documentation would be //% appreciated but is not required. //% 2. Altered source versions must be plainly marked as such, and must not be //% misrepresented as being the original software. //% 3. This notice may not be removed or altered from any source distribution. //% Mark Adler madler@alumni.caltech.edu //% BEGIN CODE DERIVED FROM puff.{c,h} #define MAXBITS 15 #define MAXLCODES 286 #define MAXDCODES 30 #define MAXCODES (MAXLCODES + MAXDCODES) #define FIXLCODES 288 struct puff_state { unsigned char* out; unsigned long outlen; unsigned long outcnt; const unsigned char* in; unsigned long inlen; unsigned long incnt; int bitbuf; int bitcnt; jmp_buf env; }; static int puff_bits(struct puff_state* s, int need) { long val = s->bitbuf; while (s->bitcnt < need) { if (s->incnt == s->inlen) longjmp(s->env, 1); val |= (long)(s->in[s->incnt++]) << s->bitcnt; s->bitcnt += 8; } s->bitbuf = (int)(val >> need); s->bitcnt -= need; return (int)(val & ((1L << need) - 1)); } static int puff_stored(struct puff_state* s) { s->bitbuf = 0; s->bitcnt = 0; if (s->incnt + 4 > s->inlen) return 2; unsigned len = s->in[s->incnt++]; len |= s->in[s->incnt++] << 8; if (s->in[s->incnt++] != (~len & 0xff) || s->in[s->incnt++] != ((~len >> 8) & 0xff)) return -2; if (s->incnt + len > s->inlen) return 2; if (s->outcnt + len > s->outlen) return 1; for (; len--; s->outcnt++, s->incnt++) { if (s->in[s->incnt]) s->out[s->outcnt] = s->in[s->incnt]; } return 0; } struct puff_huffman { short* count; short* symbol; }; static int puff_decode(struct puff_state* s, const struct puff_huffman* h) { int first = 0; int index = 0; int bitbuf = s->bitbuf; int left = s->bitcnt; int code = first = index = 0; int len = 1; short* next = h->count + 1; while (1) { while (left--) { code |= bitbuf & 1; bitbuf >>= 1; int count = *next++; if (code - count < first) { s->bitbuf = bitbuf; s->bitcnt = (s->bitcnt - len) & 7; return h->symbol[index + (code - first)]; } index += count; first += count; first <<= 1; code <<= 1; len++; } left = (MAXBITS + 1) - len; if (left == 0) break; if (s->incnt == s->inlen) longjmp(s->env, 1); bitbuf = s->in[s->incnt++]; if (left > 8) left = 8; } return -10; } static int puff_construct(struct puff_huffman* h, const short* length, int n) { int len; for (len = 0; len <= MAXBITS; len++) h->count[len] = 0; int symbol; for (symbol = 0; symbol < n; symbol++) (h->count[length[symbol]])++; if (h->count[0] == n) return 0; int left = 1; for (len = 1; len <= MAXBITS; len++) { left <<= 1; left -= h->count[len]; if (left < 0) return left; } short offs[MAXBITS + 1]; offs[1] = 0; for (len = 1; len < MAXBITS; len++) offs[len + 1] = offs[len] + h->count[len]; for (symbol = 0; symbol < n; symbol++) if (length[symbol] != 0) h->symbol[offs[length[symbol]]++] = symbol; return left; } static int puff_codes(struct puff_state* s, const struct puff_huffman* lencode, const struct puff_huffman* distcode) { static const short lens[29] = {3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258}; static const short lext[29] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0}; static const short dists[30] = { 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577}; static const short dext[30] = {0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13}; int symbol; do { symbol = puff_decode(s, lencode); if (symbol < 0) return symbol; if (symbol < 256) { if (s->outcnt == s->outlen) return 1; if (symbol) s->out[s->outcnt] = symbol; s->outcnt++; } else if (symbol > 256) { symbol -= 257; if (symbol >= 29) return -10; int len = lens[symbol] + puff_bits(s, lext[symbol]); symbol = puff_decode(s, distcode); if (symbol < 0) return symbol; unsigned dist = dists[symbol] + puff_bits(s, dext[symbol]); if (dist > s->outcnt) return -11; if (s->outcnt + len > s->outlen) return 1; while (len--) { if (dist <= s->outcnt && s->out[s->outcnt - dist]) s->out[s->outcnt] = s->out[s->outcnt - dist]; s->outcnt++; } } } while (symbol != 256); return 0; } static int puff_fixed(struct puff_state* s) { static int virgin = 1; static short lencnt[MAXBITS + 1], lensym[FIXLCODES]; static short distcnt[MAXBITS + 1], distsym[MAXDCODES]; static struct puff_huffman lencode, distcode; if (virgin) { lencode.count = lencnt; lencode.symbol = lensym; distcode.count = distcnt; distcode.symbol = distsym; short lengths[FIXLCODES]; int symbol; for (symbol = 0; symbol < 144; symbol++) lengths[symbol] = 8; for (; symbol < 256; symbol++) lengths[symbol] = 9; for (; symbol < 280; symbol++) lengths[symbol] = 7; for (; symbol < FIXLCODES; symbol++) lengths[symbol] = 8; puff_construct(&lencode, lengths, FIXLCODES); for (symbol = 0; symbol < MAXDCODES; symbol++) lengths[symbol] = 5; puff_construct(&distcode, lengths, MAXDCODES); virgin = 0; } return puff_codes(s, &lencode, &distcode); } static int puff_dynamic(struct puff_state* s) { static const short order[19] = {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; int nlen = puff_bits(s, 5) + 257; int ndist = puff_bits(s, 5) + 1; int ncode = puff_bits(s, 4) + 4; if (nlen > MAXLCODES || ndist > MAXDCODES) return -3; short lengths[MAXCODES]; int index; for (index = 0; index < ncode; index++) lengths[order[index]] = puff_bits(s, 3); for (; index < 19; index++) lengths[order[index]] = 0; short lencnt[MAXBITS + 1], lensym[MAXLCODES]; struct puff_huffman lencode = {lencnt, lensym}; int err = puff_construct(&lencode, lengths, 19); if (err != 0) return -4; index = 0; while (index < nlen + ndist) { int symbol; int len; symbol = puff_decode(s, &lencode); if (symbol < 0) return symbol; if (symbol < 16) lengths[index++] = symbol; else { len = 0; if (symbol == 16) { if (index == 0) return -5; len = lengths[index - 1]; symbol = 3 + puff_bits(s, 2); } else if (symbol == 17) symbol = 3 + puff_bits(s, 3); else symbol = 11 + puff_bits(s, 7); if (index + symbol > nlen + ndist) return -6; while (symbol--) lengths[index++] = len; } } if (lengths[256] == 0) return -9; err = puff_construct(&lencode, lengths, nlen); if (err && (err < 0 || nlen != lencode.count[0] + lencode.count[1])) return -7; short distcnt[MAXBITS + 1], distsym[MAXDCODES]; struct puff_huffman distcode = {distcnt, distsym}; err = puff_construct(&distcode, lengths + nlen, ndist); if (err && (err < 0 || ndist != distcode.count[0] + distcode.count[1])) return -8; return puff_codes(s, &lencode, &distcode); } static int puff(unsigned char* dest, unsigned long* destlen, const unsigned char* source, unsigned long sourcelen) { struct puff_state s = { .out = dest, .outlen = *destlen, .outcnt = 0, .in = source, .inlen = sourcelen, .incnt = 0, .bitbuf = 0, .bitcnt = 0, }; int err; if (setjmp(s.env) != 0) err = 2; else { int last; do { last = puff_bits(&s, 1); int type = puff_bits(&s, 2); err = type == 0 ? puff_stored(&s) : (type == 1 ? puff_fixed(&s) : (type == 2 ? puff_dynamic(&s) : -1)); if (err != 0) break; } while (!last); } *destlen = s.outcnt; return err; } //% END CODE DERIVED FROM puff.{c,h} #define ZLIB_HEADER_WIDTH 2 static int puff_zlib_to_file(const unsigned char* source, unsigned long sourcelen, int dest_fd) { if (sourcelen < ZLIB_HEADER_WIDTH) { errno = EMSGSIZE; return -1; } 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, 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 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, loopfd = -1, 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) { memset(loopname, 0, sizeof(loopname)); snprintf(loopname, sizeof(loopname), "/dev/loop%llu", procid); if (setup_loop_device(data, size, loopname, &loopfd) == -1) return -1; 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) { if (strstr(opts, "errors=panic") || strstr(opts, "errors=remount-ro") == 0) 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) { ioctl(loopfd, LOOP_CLR_FD, 0); close(loopfd); } errno = err; return res; } static void setup_common() { 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)) { } if (symlink("/dev/binderfs", "./binderfs")) { } } static void loop(); static void sandbox_common() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setsid(); 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); setup_common(); sandbox_common(); drop_caps(); if (unshare(CLONE_NEWNET)) { } write_file("/proc/sys/net/ipv4/ping_group_range", "0 65535"); initialize_wifi_devices(); setup_binderfs(); loop(); exit(1); } static void setup_sysctl() { char mypid[32]; snprintf(mypid, sizeof(mypid), "%d", getpid()); 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", mypid}, }; for (size_t i = 0; i < sizeof(files) / sizeof(files[0]); i++) { if (!write_file(files[i].name, files[i].data)) printf("write to %s failed: %s\n", files[i].name, strerror(errno)); } } uint64_t r[2] = {0xffffffffffffffff, 0xffffffffffffffff}; void loop(void) { intptr_t res = 0; memcpy((void*)0x20000c00, "udf\000", 4); memcpy((void*)0x20000c40, "./file0\000", 8); memcpy((void*)0x200000c0, "\x00\x26\x1c\x40\xd6\x9a\xf9\xea\xbf\xe0\x8d\x07\x02\x11\xcd\xdb\x52" "\xa2\xe4\x00\x16\xbb\x64\x45\xb3\x38\xb1\xc5\x34\xef\x1d\x25\xa0\x45" "\x39\x81\xc1\x2b\xab\xf8\x7d\x05\x00\xba\x8d\xd8\x1f\x00\x00\x00\x00" "\x6d\xae\x00\x00\x00\x00\x53\x77\x00\x00\x00\x00\x00\x00", 65); memcpy( (void*)0x20000cc0, "\x78\x9c\xec\xdd\x4f\x6c\x1c\xd7\x7d\x07\xf0\xdf\x1b\x92\x22\x25\xb7\x15" "\x13\x3b\x8a\xdd\xc6\xc5\xa6\x2d\x52\x99\xb1\x5c\xfd\x8b\xa9\x58\x85\xbb" "\xaa\x69\xb6\x01\x64\x99\x08\xc5\xdc\x02\x70\x45\x52\xea\xc2\xd4\x92\x20" "\xa9\x46\x36\xd2\x82\xe9\xa5\x87\x1e\x02\x14\x45\x0f\x39\x11\x68\x8d\x02" "\x29\x1a\x18\x4d\x11\xf4\xc8\xb6\x2e\x90\x5c\x7c\x28\x72\xea\x89\x68\x61" "\x23\x28\x7a\x60\x8b\x00\x39\x05\x0c\x66\xf6\x2d\xb9\xa4\x28\x4b\x16\x45" "\x89\xb4\x3f\x1f\x9b\xfa\xce\xce\xbc\x37\xf3\xde\xcc\x7a\x46\x16\xf4\xe6" "\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\xf1\xfb\xaf" "\x5e\x3a\x7d\x26\x3d\xee\x56\x00\x00\x8f\xd2\x95\xf1\xaf\x9e\x3e\xeb\xf9" "\x0f\x00\x9f\x28\x57\xfd\xff\x3f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x1c\x74\x29\x8a\x78\x32\x52\xcc\x5f\x59\x4f\x93\xd5\xe7\xb6\x81\xcb" "\xcd\xd6\xad\xdb\x13\x23\xa3\xbb\x57\x3b\x9a\xaa\x9a\x3d\x55\xf9\xf2\x67" "\xe0\xcc\xd9\x73\xe7\xbf\xf4\xe2\xf0\x85\x4e\x7e\x78\xfd\x87\xed\x99\x78" "\x7d\xfc\xea\xa5\xda\x2b\x73\x37\xe7\x17\x66\x16\x17\x67\xa6\x6b\x13\xad" "\xe6\xd4\xdc\xf4\xcc\x7d\xef\x61\xaf\xf5\x77\x1a\xaa\x4e\x40\xed\xe6\x1b" "\xb7\xa6\xaf\x5f\x5f\xac\x9d\x7d\xe1\xdc\xb6\xcd\xb7\x07\x3f\xe8\x7f\xe2" "\xc4\xe0\xc5\xe1\xe7\x4e\x3d\xdb\x29\x3b\x31\x32\x3a\x3a\xde\x55\xa6\xb7" "\xef\x81\x8f\x7e\x87\xbb\x8d\xf0\x38\x12\x45\x9c\x8a\x14\xcf\x7f\xef\x27" "\xa9\x11\x11\x45\xec\xfd\x5c\xdc\xe3\xbb\xb3\xdf\x8e\x56\x9d\x18\xaa\x3a" "\x31\x31\x32\x5a\x75\x64\xb6\xd9\x68\x2d\x95\x1b\xc7\x3a\x27\xa2\x88\xa8" "\x75\x55\xaa\x77\xce\xd1\x23\xb8\x16\x7b\x52\x8f\x58\x2e\x9b\x5f\x36\x78" "\xa8\xec\xde\xf8\x7c\x63\xa1\x71\x6d\x76\xa6\x36\xd6\x58\x58\x6a\x2e\x35" "\xe7\x5a\x63\xa9\xdd\xda\xb2\x3f\xb5\x28\xe2\x42\x8a\x58\x89\x88\xb5\xfe" "\x3b\x77\xd7\x17\x45\xf4\x46\x8a\xef\x1c\x5f\x4f\xd7\x22\xa2\xa7\x73\x1e" "\xbe\x58\x0d\x0c\xbe\x7b\x3b\x8a\x7d\xec\xe3\x7d\x28\xdb\x59\xeb\x8b\x58" "\x29\x0e\xc1\x35\x3b\xc0\xfa\xa3\x88\xd7\x22\xc5\x4f\xdf\x3d\x19\x53\xe5" "\x39\xcb\x3f\xf1\x85\x88\xd7\xca\xfc\x41\xc4\xdb\x65\xbe\x1c\x91\xca\x2f" "\xc6\xf9\x88\xf7\x77\xf9\x1e\x71\x38\xf5\x46\x11\x7f\x51\x5e\xff\x8b\xeb" "\x69\xba\xba\x1f\x74\xee\x2b\x97\xbf\x56\xfb\x4a\xeb\xfa\x5c\x57\xd9\xce" "\x7d\xe5\xd0\x3f\x1f\x1e\xa5\x03\x7e\x6f\x1a\x88\x22\x1a\xd5\x1d\x7f\x3d" "\x3d\xf8\x6f\x76\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x78" "\xd8\x8e\x46\x11\xcf\x44\x8a\x57\xff\xe3\x8f\xab\x71\xc5\x51\x8d\x4b\x3f" "\x7e\x71\xf8\x0f\x06\x7f\xb9\x7b\xcc\xf8\xd3\xf7\xd8\x4f\x59\xf6\x85\x88" "\x58\x2e\xee\x6f\x4c\xee\x91\x3c\x84\x78\x2c\x8d\xa5\xf4\x98\xc7\x12\x7f" "\x92\x0d\x44\x11\x7f\x92\xc7\xff\x7d\xeb\x71\x37\x06\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe0\x13\xad\x88\x1f\x47\x8a\x97\xde" "\x3b\x99\x56\xa2\x7b\x4e\xf1\x66\xeb\x46\xed\x6a\xe3\xda\x6c\x7b\x56\xd8" "\xce\xdc\xbf\x9d\x39\xd3\x37\x36\x36\x36\x6a\xa9\x9d\xf5\x9c\x93\x39\x97" "\x73\xae\xe4\x5c\xcd\xb9\x96\x33\x8a\x5c\x3f\x67\x3d\xe7\x64\xce\xe5\x9c" "\x2b\x39\x57\x73\xae\xe5\x8c\x9e\x5c\x3f\x67\x3d\xe7\x64\xce\xe5\x9c\x2b" "\x39\x57\x73\xae\xe5\x8c\xde\x5c\x3f\x67\x3d\xe7\x64\xce\xe5\x9c\x2b\x39" "\x57\x73\xae\xe5\x8c\x03\x32\x77\x2f\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\xc0\xc7\x49\x11\x45\xfc\x3c\x52\x7c\xfb\x1b\xeb\x29\x52\x44\xd4\x23" "\x26\xa3\x9d\xab\xfd\x8f\xbb\x75\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\xa9\x3f\x15\xf1\xfd\x48\x51\xfb" "\xc3\xfa\xe6\xba\xde\x88\x48\xd5\xbf\x6d\x27\xcb\x5f\xce\x47\xfd\x48\x99" "\x9f\x8e\xfa\x70\x99\x2f\x47\xfd\x52\xce\x46\x95\xbd\xf5\x6f\x3d\x86\xf6" "\xb3\x37\x7d\xa9\x88\x1f\x45\x8a\xfe\x81\x77\x36\x2f\x78\xbe\xfe\x7d\xed" "\x4f\x9b\x5f\x83\x78\xfb\x9b\x5b\x9f\x7e\xb5\xb7\x9d\x3d\x9d\x8d\x83\x1f" "\xf4\x3f\x71\xe2\xf8\xc5\xe1\xd1\x5f\x7f\xfa\x6e\xcb\x69\xb7\x06\x0c\x5d" "\x6e\xb6\x6e\xdd\xae\x4d\x8c\x8c\x8e\x8e\x77\xad\xee\xcd\x47\xff\x74\xd7" "\xba\xc1\x7c\xdc\xe2\xe1\x74\x9d\x88\x58\x7c\xf3\xad\x37\x1a\xb3\xb3\x33" "\x0b\x16\x2c\x58\xb0\xb0\xb9\xf0\xb8\xef\x4c\x3c\x0a\xe5\xf3\xff\xfd\x48" "\xf1\x3b\xef\xfd\x67\xe7\x81\xdf\x79\xfe\xff\x52\xfb\xd3\xe6\x13\x3e\x7e" "\xf6\xa7\x5b\xcf\xff\x97\x76\xee\x68\x9f\x9e\xff\x4f\x76\xad\x7b\x29\xff" "\x6e\xa4\xaf\x37\x62\x60\xe9\xe6\x7c\xdf\x89\x88\x81\xc5\x37\xdf\x3a\xd5" "\xbc\xd9\xb8\x31\x73\x63\xa6\x75\xfe\xf4\xe9\x2f\x0f\x0f\x7f\xf9\xdc\xe9" "\xbe\x23\x11\x03\xd7\x9b\xb3\x33\x5d\x4b\x7b\x3e\x55\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x8f\x56\x2a\xe2\xf7\x22\x45\xe3\x47\xeb" "\xa9\x16\x11\xb7\xab\xf1\x5a\x83\x17\x87\x9f\x3b\xf5\x6c\x4f\xf4\x54\xe3" "\xad\xb6\x8d\xdb\x7a\x7d\xfc\xea\xa5\xda\x2b\x73\x37\xe7\x17\x66\x16\x17" "\x67\xa6\x6b\x13\xad\xe6\xd4\xdc\xf4\xcc\xfd\x1e\x6e\xa0\x1a\xee\x35\x31" "\x32\xba\x2f\x9d\xb9\xa7\xa3\xfb\xdc\xfe\xa3\x03\xaf\xcc\xcd\xbf\xb9\xd0" "\xbc\xf1\x47\x4b\xbb\x6e\x3f\x36\x70\xe9\xda\xe2\xd2\x42\x63\x6a\xf7\xcd" "\x71\x34\x8a\x88\x7a\xf7\x9a\xa1\xaa\xc1\x13\x23\xa3\x55\xa3\x67\x9b\x8d" "\x56\x55\x75\x6c\xd7\xc1\x74\x1f\x5d\x5f\x2a\xe2\xbf\x22\xc5\xd4\xf9\x5a" "\xfa\x7c\x5e\x97\xc7\xff\xed\x1c\xe1\xbf\x6d\xfc\xff\xf2\xce\x1d\xed\xd3" "\xf8\xbf\x4f\x75\xad\x2b\x8f\x99\x52\x11\x3f\x8b\x14\xbf\xfd\x97\x4f\xc7" "\xe7\xab\x76\x1e\x8b\x3b\xce\x59\x2e\xf7\xb7\x91\x62\xe8\xc2\xe7\x72\xb9" "\x38\x52\x96\xeb\xb4\xa1\xfd\x5e\x81\xf6\xc8\xc0\xb2\xec\xff\x45\x8a\x7f" "\xfc\xf9\xf6\xb2\x9d\xf1\x90\x4f\x6e\x95\x3d\x73\xdf\x27\xf6\x90\x28\xaf" "\xff\xf1\x48\xf1\xfd\x3f\xff\x6e\xfc\x46\x5e\xb7\xfd\xfd\x0f\xbb\x5f\xff" "\x63\x3b\x77\xb4\x4f\xd7\xff\xa9\xae\x75\xc7\xb6\xbd\xaf\x60\xcf\x5d\x27" "\x5f\xff\x53\x91\xe2\xe5\x27\xdf\x89\xdf\xcc\xeb\x3e\xec\xfd\x1f\x9d\x77" "\x6f\x9c\xcc\x85\x37\xdf\xcf\xb1\x4f\xd7\xff\x33\x5d\xeb\x06\xf3\x71\x7f" "\xeb\xe1\x74\x1d\x00\x00\x00\x00\x00\x00\x00\x00\xe0\x50\xeb\x4b\x45\xfc" "\x5d\xa4\x78\x76\xb4\x37\xbd\x98\xd7\xdd\xcf\xdf\xff\x9b\xde\xb9\xa3\x7d" "\xfa\xfb\x5f\x9f\xed\x5a\x37\xfd\x88\xe6\x2b\xda\xf3\x49\x05\x00\x00\x00" "\x80\x03\xa2\x2f\x15\xf1\xe3\x48\x71\x63\xe9\x9d\xcd\x31\xd4\xdb\xc7\x7f" "\x77\x8d\xff\xfc\xdd\xad\xf1\x9f\x23\x69\xc7\xd6\xea\xcf\xf9\x7e\xa5\x7a" "\x6f\xc0\xc3\xfc\xf3\xbf\x6e\x83\xf9\xb8\x93\x7b\xef\x36\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1c\x28\x29\x15\xf1\x62\x9e" "\x4f\x7d\xf2\x1e\xf3\xa9\xaf\x46\x8a\x57\xff\xe7\xf9\x5c\x2e\x9d\x28\xcb" "\x75\xe6\x81\x1f\xac\x7e\x1d\xb8\x32\xd7\x3a\x75\x69\x76\x76\x6e\xaa\xb1" "\xd4\xb8\x36\x3b\x53\x1b\x9f\x6f\x4c\xcd\x94\x75\x9f\x8a\x14\xeb\x7f\xf3" "\xb9\x5c\xb7\xa8\xe6\x57\xef\xcc\x37\xdf\x9e\xe3\x7d\x6b\x2e\xf6\x85\x48" "\x31\xfa\xf7\x9d\xb2\xed\xb9\xd8\x3b\x73\x93\x3f\xb5\x55\xf6\x4c\x59\xf6" "\x53\x91\xe2\xbf\xff\x61\x7b\xd9\xce\x3c\xd6\x9f\xd9\x2a\x7b\xb6\x2c\xfb" "\xd7\x91\xe2\xeb\xff\xbc\x7b\xd9\x13\x5b\x65\xcf\x95\x65\xbf\x1b\x29\x7e" "\xf8\xf5\x5a\xa7\xec\xb1\xb2\x6c\xe7\xfd\xa8\x9f\xdd\x2a\xfb\xc2\xd4\xdc" "\xec\x1d\xaf\x42\x05\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x80\x8f\xaa\x2f\x15\xf1\x67\x91\xe2\x7f\x6f\xae\x6c\x8e\xe5\xcf\xf3" "\xff\xf7\x75\x7d\xac\xbc\xfd\xcd\xae\xf9\xfe\x77\xb8\x5d\xcd\xf3\x3f\x58" "\xcd\xff\x7f\xb7\xe5\x07\x99\xff\x7f\xf0\xe1\x74\x13\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0e\x95\x14\x45\xbc\x15" "\x29\xe6\xaf\xac\xa7\xd5\xfe\xf2\x73\xdb\xc0\xe5\x66\xeb\xd6\xed\x89\x91" "\xd1\xdd\xab\x1d\x4d\x55\xcd\x9e\xaa\x7c\xf9\x33\x70\xe6\xec\xb9\xf3\x5f" "\x7a\x71\xf8\x42\x27\x3f\xbc\xfe\xc3\xf6\x4c\xbc\x3e\x7e\xf5\x52\xed\x95" "\xb9\x9b\xf3\x0b\x33\x8b\x8b\x33\xd3\xb5\x89\x56\x73\x6a\x6e\x7a\xe6\xbe" "\xf7\xb0\xd7\xfa\x3b\x0d\x55\x27\xa0\x76\xf3\x8d\x5b\xd3\xd7\xaf\x2f\xd6" "\xce\xbe\x70\x6e\xdb\xe6\xdb\x83\x1f\xf4\x3f\x71\x62\xf0\xe2\xf0\x73\xa7" "\x9e\xed\x94\x9d\x18\x19\x1d\x1d\xef\x2a\xd3\xdb\xf7\xc0\x47\xbf\x43\xba" "\xcb\xfa\x23\x51\xc4\x5f\x45\x8a\xe7\xbf\xf7\x93\xf4\x2f\xfd\x11\x45\xec" "\xfd\x5c\xdc\xe3\xbb\xb3\xdf\x8e\x56\x9d\x18\xaa\x3a\x31\x31\x32\x5a\x75" "\x64\xb6\xd9\x68\x2d\x95\x1b\xc7\x3a\x27\xa2\x88\xa8\x75\x55\xaa\x77\xce" "\xd1\x23\xb8\x16\x7b\x52\x8f\x58\x2e\x9b\x5f\x36\x78\xa8\xec\xde\xf8\x7c" "\x63\xa1\x71\x6d\x76\xa6\x36\xd6\x58\x58\x6a\x2e\x35\xe7\x5a\x63\xa9\xdd" "\xda\xb2\x3f\xb5\x28\xe2\x42\x8a\x58\x89\x88\xb5\xfe\x3b\x77\xd7\x17\x45" "\xbc\x11\x29\xbe\x73\x7c\x3d\xfd\x6b\x7f\x44\x4f\xe7\x3c\x7c\xf1\xca\xf8" "\x57\x4f\x9f\xbd\x7b\x3b\x8a\x7d\xec\xe3\x7d\x28\xdb\x59\xeb\x8b\x58\x29" "\x0e\xc1\x35\x3b\xc0\xfa\xa3\x88\x7f\x8a\x14\x3f\x7d\xf7\x64\xfc\x5b\x7f" "\x44\x6f\xb4\x7f\xe2\x0b\x11\xaf\x95\xf9\x83\x88\xb7\xcb\x7c\x39\x22\x95" "\x5f\x8c\xf3\x11\xef\xef\xf2\x3d\xe2\x70\xea\x8d\x22\xfe\xbf\xbc\xfe\x17" "\xd7\xd3\xbb\xfd\xe5\xfd\xa0\x73\x5f\xb9\xfc\xb5\xda\x57\x5a\xd7\xe7\xba" "\xca\x76\xee\x2b\x87\xfe\xf9\xf0\x28\x1d\xf0\x7b\xd3\x40\x14\xf1\xc3\xea" "\x8e\xbf\x9e\xfe\xdd\x7f\xd7\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x07\x48\x11\xbf\x16\x29\x5e\x7a\xef\x64\xaa\xc6\x07\x6f\x8e\x29" "\x6e\xb6\x6e\xd4\xae\x36\xae\xcd\xb6\x87\xf5\x75\xc6\xfe\x75\xc6\x4c\x6f" "\x6c\x6c\x6c\xd4\x52\x3b\xeb\x39\x27\x73\x2e\xe7\x5c\xc9\xb9\x9a\x73\x2d" "\x67\x14\xb9\x7e\xce\x7a\xce\xc9\x9c\xcb\x39\x57\x72\xae\xe6\x5c\xcb\x19" "\x3d\xb9\x7e\xce\x7a\xce\xc9\x9c\xcb\x39\x57\x72\xae\xe6\x5c\xcb\x19\xbd" "\xb9\x7e\xce\x7a\xce\xc9\x9c\xcb\x39\x57\x72\xae\xe6\x5c\xcb\x19\x07\x64" "\xec\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xf0\xf1" "\x52\x54\xff\xa4\xf8\xf6\x37\xd6\xd3\x46\x7f\x7b\x7e\xe9\xc9\x68\xe7\xaa" "\xf9\x40\x3f\xf6\x7e\x11\x00\x00\xff\xff\x14\x0a\xfe\x9f", 3056); syz_mount_image(0x20000c00, 0x20000c40, 0, 0x200000c0, 1, 0xbf0, 0x20000cc0); memcpy((void*)0x20000000, "./bus\000", 6); syscall(__NR_mknod, 0x20000000ul, 0x6000ul, 0x700); memcpy((void*)0x200000c0, "./bus\000", 6); res = syscall(__NR_open, 0x200000c0ul, 0x14da42ul, 0ul); if (res != -1) r[0] = res; memcpy((void*)0x20000040, "/proc/self/exe\000", 15); res = syscall(__NR_openat, -1, 0x20000040ul, 0ul, 0ul); if (res != -1) r[1] = res; syscall(__NR_sendfile, r[0], r[1], 0ul, 0x80001d00c0d0ul); } int main(void) { syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul); syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul); setup_sysctl(); do_sandbox_none(); return 0; }