// https://syzkaller.appspot.com/bug?id=e34c036ff7e62fd215a65e5013f4db6c31a47bce // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef __NR_fsconfig #define __NR_fsconfig 431 #endif #ifndef __NR_fspick #define __NR_fspick 433 #endif #ifndef __NR_memfd_create #define __NR_memfd_create 319 #endif static unsigned long long procid; static __thread int clone_ongoing; static __thread int skip_segv; static __thread jmp_buf segv_env; static void segv_handler(int sig, siginfo_t* info, void* ctx) { if (__atomic_load_n(&clone_ongoing, __ATOMIC_RELAXED) != 0) { exit(sig); } uintptr_t addr = (uintptr_t)info->si_addr; const uintptr_t prog_start = 1 << 20; const uintptr_t prog_end = 100 << 20; int skip = __atomic_load_n(&skip_segv, __ATOMIC_RELAXED) != 0; int valid = addr < prog_start || addr > prog_end; if (skip && valid) { _longjmp(segv_env, 1); } exit(sig); } static void install_segv_handler(void) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = SIG_IGN; syscall(SYS_rt_sigaction, 0x20, &sa, NULL, 8); syscall(SYS_rt_sigaction, 0x21, &sa, NULL, 8); memset(&sa, 0, sizeof(sa)); sa.sa_sigaction = segv_handler; sa.sa_flags = SA_NODEFER | SA_SIGINFO; sigaction(SIGSEGV, &sa, NULL); sigaction(SIGBUS, &sa, NULL); } #define NONFAILING(...) \ ({ \ int ok = 1; \ __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); \ if (_setjmp(segv_env) == 0) { \ __VA_ARGS__; \ } else \ ok = 0; \ __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); \ ok; \ }) 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 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, bool dofail) { struct genlmsghdr genlhdr; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = NL80211_CMD_SET_INTERFACE; netlink_init(nlmsg, nl80211_family, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(nlmsg, NL80211_ATTR_IFINDEX, &ifindex, sizeof(ifindex)); netlink_attr(nlmsg, NL80211_ATTR_IFTYPE, &iftype, sizeof(iftype)); int err = netlink_send_ext(nlmsg, sock, 0, NULL, dofail); if (err < 0) { } return err; } static int nl80211_join_ibss(struct nlmsg* nlmsg, int sock, int nl80211_family, uint32_t ifindex, struct join_ibss_props* props, bool dofail) { struct genlmsghdr genlhdr; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = NL80211_CMD_JOIN_IBSS; netlink_init(nlmsg, nl80211_family, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(nlmsg, NL80211_ATTR_IFINDEX, &ifindex, sizeof(ifindex)); netlink_attr(nlmsg, NL80211_ATTR_SSID, props->ssid, props->ssid_len); netlink_attr(nlmsg, NL80211_ATTR_WIPHY_FREQ, &(props->wiphy_freq), sizeof(props->wiphy_freq)); if (props->mac) netlink_attr(nlmsg, NL80211_ATTR_MAC, props->mac, ETH_ALEN); if (props->wiphy_freq_fixed) netlink_attr(nlmsg, NL80211_ATTR_FREQ_FIXED, NULL, 0); int err = netlink_send_ext(nlmsg, sock, 0, NULL, dofail); if (err < 0) { } return err; } static int get_ifla_operstate(struct nlmsg* nlmsg, int ifindex, bool dofail) { struct ifinfomsg info; memset(&info, 0, sizeof(info)); info.ifi_family = AF_UNSPEC; info.ifi_index = ifindex; int sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock == -1) { return -1; } netlink_init(nlmsg, RTM_GETLINK, 0, &info, sizeof(info)); int n; int err = netlink_send_ext(nlmsg, sock, RTM_NEWLINK, &n, dofail); close(sock); if (err) { return -1; } struct rtattr* attr = IFLA_RTA(NLMSG_DATA(nlmsg->buf)); for (; RTA_OK(attr, n); attr = RTA_NEXT(attr, n)) { if (attr->rta_type == IFLA_OPERSTATE) return *((int32_t*)RTA_DATA(attr)); } return -1; } static int await_ifla_operstate(struct nlmsg* nlmsg, char* interface, int operstate, bool dofail) { int ifindex = if_nametoindex(interface); while (true) { usleep(1000); int ret = get_ifla_operstate(nlmsg, ifindex, dofail); if (ret < 0) return ret; if (ret == operstate) return 0; } return 0; } static int nl80211_setup_ibss_interface(struct nlmsg* nlmsg, int sock, int nl80211_family_id, char* interface, struct join_ibss_props* ibss_props, bool dofail) { int ifindex = if_nametoindex(interface); if (ifindex == 0) { return -1; } int ret = nl80211_set_interface(nlmsg, sock, nl80211_family_id, ifindex, NL80211_IFTYPE_ADHOC, dofail); if (ret < 0) { return -1; } ret = set_interface_state(interface, 1); if (ret < 0) { return -1; } ret = nl80211_join_ibss(nlmsg, sock, nl80211_family_id, ifindex, ibss_props, dofail); if (ret < 0) { return -1; } return 0; } static int hwsim80211_create_device(struct nlmsg* nlmsg, int sock, int hwsim_family, uint8_t mac_addr[ETH_ALEN]) { struct genlmsghdr genlhdr; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = HWSIM_CMD_NEW_RADIO; netlink_init(nlmsg, hwsim_family, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(nlmsg, HWSIM_ATTR_SUPPORT_P2P_DEVICE, NULL, 0); netlink_attr(nlmsg, HWSIM_ATTR_PERM_ADDR, mac_addr, ETH_ALEN); int err = netlink_send(nlmsg, sock); if (err < 0) { } return err; } static void initialize_wifi_devices(void) { int rfkill = open("/dev/rfkill", O_RDWR); if (rfkill == -1) { 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, true) < 0) exit(1); } for (int device_id = 0; device_id < WIFI_INITIAL_DEVICE_COUNT; device_id++) { char interface[6] = "wlan0"; interface[4] += device_id; int ret = await_ifla_operstate(&nlmsg, interface, IF_OPER_UP, true); if (ret < 0) exit(1); } close(sock); } static int runcmdline(char* cmdline) { int ret = system(cmdline); if (ret) { } return ret; } #define MAX_FDS 30 //% This code is derived from puff.{c,h}, found in the zlib development. The //% original files come with the following copyright notice: //% Copyright (C) 2002-2013 Mark Adler, all rights reserved //% version 2.3, 21 Jan 2013 //% This software is provided 'as-is', without any express or implied //% warranty. In no event will the author be held liable for any damages //% arising from the use of this software. //% Permission is granted to anyone to use this software for any purpose, //% including commercial applications, and to alter it and redistribute it //% freely, subject to the following restrictions: //% 1. The origin of this software must not be misrepresented; you must not //% claim that you wrote the original software. If you use this software //% in a product, an acknowledgment in the product documentation would be //% appreciated but is not required. //% 2. Altered source versions must be plainly marked as such, and must not be //% misrepresented as being the original software. //% 3. This notice may not be removed or altered from any source distribution. //% Mark Adler madler@alumni.caltech.edu //% BEGIN CODE DERIVED FROM puff.{c,h} #define MAXBITS 15 #define MAXLCODES 286 #define MAXDCODES 30 #define MAXCODES (MAXLCODES + MAXDCODES) #define FIXLCODES 288 struct puff_state { unsigned char* out; unsigned long outlen; unsigned long outcnt; const unsigned char* in; unsigned long inlen; unsigned long incnt; int bitbuf; int bitcnt; jmp_buf env; }; static int puff_bits(struct puff_state* s, int need) { long val = s->bitbuf; while (s->bitcnt < need) { if (s->incnt == s->inlen) longjmp(s->env, 1); val |= (long)(s->in[s->incnt++]) << s->bitcnt; s->bitcnt += 8; } s->bitbuf = (int)(val >> need); s->bitcnt -= need; return (int)(val & ((1L << need) - 1)); } static int puff_stored(struct puff_state* s) { s->bitbuf = 0; s->bitcnt = 0; if (s->incnt + 4 > s->inlen) return 2; unsigned len = s->in[s->incnt++]; len |= s->in[s->incnt++] << 8; if (s->in[s->incnt++] != (~len & 0xff) || s->in[s->incnt++] != ((~len >> 8) & 0xff)) return -2; if (s->incnt + len > s->inlen) return 2; if (s->outcnt + len > s->outlen) return 1; for (; len--; s->outcnt++, s->incnt++) { if (s->in[s->incnt]) s->out[s->outcnt] = s->in[s->incnt]; } return 0; } struct puff_huffman { short* count; short* symbol; }; static int puff_decode(struct puff_state* s, const struct puff_huffman* h) { int first = 0; int index = 0; int bitbuf = s->bitbuf; int left = s->bitcnt; int code = first = index = 0; int len = 1; short* next = h->count + 1; while (1) { while (left--) { code |= bitbuf & 1; bitbuf >>= 1; int count = *next++; if (code - count < first) { s->bitbuf = bitbuf; s->bitcnt = (s->bitcnt - len) & 7; return h->symbol[index + (code - first)]; } index += count; first += count; first <<= 1; code <<= 1; len++; } left = (MAXBITS + 1) - len; if (left == 0) break; if (s->incnt == s->inlen) longjmp(s->env, 1); bitbuf = s->in[s->incnt++]; if (left > 8) left = 8; } return -10; } static int puff_construct(struct puff_huffman* h, const short* length, int n) { int len; for (len = 0; len <= MAXBITS; len++) h->count[len] = 0; int symbol; for (symbol = 0; symbol < n; symbol++) (h->count[length[symbol]])++; if (h->count[0] == n) return 0; int left = 1; for (len = 1; len <= MAXBITS; len++) { left <<= 1; left -= h->count[len]; if (left < 0) return left; } short offs[MAXBITS + 1]; offs[1] = 0; for (len = 1; len < MAXBITS; len++) offs[len + 1] = offs[len] + h->count[len]; for (symbol = 0; symbol < n; symbol++) if (length[symbol] != 0) h->symbol[offs[length[symbol]]++] = symbol; return left; } static int puff_codes(struct puff_state* s, const struct puff_huffman* lencode, const struct puff_huffman* distcode) { static const short lens[29] = {3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258}; static const short lext[29] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0}; static const short dists[30] = { 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577}; static const short dext[30] = {0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13}; int symbol; do { symbol = puff_decode(s, lencode); if (symbol < 0) return symbol; if (symbol < 256) { if (s->outcnt == s->outlen) return 1; if (symbol) s->out[s->outcnt] = symbol; s->outcnt++; } else if (symbol > 256) { symbol -= 257; if (symbol >= 29) return -10; int len = lens[symbol] + puff_bits(s, lext[symbol]); symbol = puff_decode(s, distcode); if (symbol < 0) return symbol; unsigned dist = dists[symbol] + puff_bits(s, dext[symbol]); if (dist > s->outcnt) return -11; if (s->outcnt + len > s->outlen) return 1; while (len--) { if (dist <= s->outcnt && s->out[s->outcnt - dist]) s->out[s->outcnt] = s->out[s->outcnt - dist]; s->outcnt++; } } } while (symbol != 256); return 0; } static int puff_fixed(struct puff_state* s) { static int virgin = 1; static short lencnt[MAXBITS + 1], lensym[FIXLCODES]; static short distcnt[MAXBITS + 1], distsym[MAXDCODES]; static struct puff_huffman lencode, distcode; if (virgin) { lencode.count = lencnt; lencode.symbol = lensym; distcode.count = distcnt; distcode.symbol = distsym; short lengths[FIXLCODES]; int symbol; for (symbol = 0; symbol < 144; symbol++) lengths[symbol] = 8; for (; symbol < 256; symbol++) lengths[symbol] = 9; for (; symbol < 280; symbol++) lengths[symbol] = 7; for (; symbol < FIXLCODES; symbol++) lengths[symbol] = 8; puff_construct(&lencode, lengths, FIXLCODES); for (symbol = 0; symbol < MAXDCODES; symbol++) lengths[symbol] = 5; puff_construct(&distcode, lengths, MAXDCODES); virgin = 0; } return puff_codes(s, &lencode, &distcode); } static int puff_dynamic(struct puff_state* s) { static const short order[19] = {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; int nlen = puff_bits(s, 5) + 257; int ndist = puff_bits(s, 5) + 1; int ncode = puff_bits(s, 4) + 4; if (nlen > MAXLCODES || ndist > MAXDCODES) return -3; short lengths[MAXCODES]; int index; for (index = 0; index < ncode; index++) lengths[order[index]] = puff_bits(s, 3); for (; index < 19; index++) lengths[order[index]] = 0; short lencnt[MAXBITS + 1], lensym[MAXLCODES]; struct puff_huffman lencode = {lencnt, lensym}; int err = puff_construct(&lencode, lengths, 19); if (err != 0) return -4; index = 0; while (index < nlen + ndist) { int symbol; int len; symbol = puff_decode(s, &lencode); if (symbol < 0) return symbol; if (symbol < 16) lengths[index++] = symbol; else { len = 0; if (symbol == 16) { if (index == 0) return -5; len = lengths[index - 1]; symbol = 3 + puff_bits(s, 2); } else if (symbol == 17) symbol = 3 + puff_bits(s, 3); else symbol = 11 + puff_bits(s, 7); if (index + symbol > nlen + ndist) return -6; while (symbol--) lengths[index++] = len; } } if (lengths[256] == 0) return -9; err = puff_construct(&lencode, lengths, nlen); if (err && (err < 0 || nlen != lencode.count[0] + lencode.count[1])) return -7; short distcnt[MAXBITS + 1], distsym[MAXDCODES]; struct puff_huffman distcode = {distcnt, distsym}; err = puff_construct(&distcode, lengths + nlen, ndist); if (err && (err < 0 || ndist != distcode.count[0] + distcode.count[1])) return -8; return puff_codes(s, &lencode, &distcode); } static int puff(unsigned char* dest, unsigned long* destlen, const unsigned char* source, unsigned long sourcelen) { struct puff_state s = { .out = dest, .outlen = *destlen, .outcnt = 0, .in = source, .inlen = sourcelen, .incnt = 0, .bitbuf = 0, .bitcnt = 0, }; int err; if (setjmp(s.env) != 0) err = 2; else { int last; do { last = puff_bits(&s, 1); int type = puff_bits(&s, 2); err = type == 0 ? puff_stored(&s) : (type == 1 ? puff_fixed(&s) : (type == 2 ? puff_dynamic(&s) : -1)); if (err != 0) break; } while (!last); } *destlen = s.outcnt; return err; } //% END CODE DERIVED FROM puff.{c,h} #define ZLIB_HEADER_WIDTH 2 static int puff_zlib_to_file(const unsigned char* source, unsigned long sourcelen, int dest_fd) { if (sourcelen < ZLIB_HEADER_WIDTH) return 0; source += ZLIB_HEADER_WIDTH; sourcelen -= ZLIB_HEADER_WIDTH; const unsigned long max_destlen = 132 << 20; void* ret = mmap(0, max_destlen, PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANON, -1, 0); if (ret == MAP_FAILED) return -1; unsigned char* dest = (unsigned char*)ret; unsigned long destlen = max_destlen; int err = puff(dest, &destlen, source, sourcelen); if (err) { munmap(dest, max_destlen); errno = -err; return -1; } if (write(dest_fd, dest, destlen) != (ssize_t)destlen) { munmap(dest, max_destlen); return -1; } return munmap(dest, max_destlen); } static int setup_loop_device(unsigned char* data, unsigned long size, const char* loopname, int* loopfd_p) { int err = 0, loopfd = -1; int memfd = syscall(__NR_memfd_create, "syzkaller", 0); if (memfd == -1) { err = errno; goto error; } if (puff_zlib_to_file(data, size, memfd)) { err = errno; goto error_close_memfd; } loopfd = open(loopname, O_RDWR); if (loopfd == -1) { err = errno; goto error_close_memfd; } if (ioctl(loopfd, LOOP_SET_FD, memfd)) { if (errno != EBUSY) { err = errno; goto error_close_loop; } ioctl(loopfd, LOOP_CLR_FD, 0); usleep(1000); if (ioctl(loopfd, LOOP_SET_FD, memfd)) { err = errno; goto error_close_loop; } } close(memfd); *loopfd_p = loopfd; return 0; error_close_loop: close(loopfd); error_close_memfd: close(memfd); error: errno = err; return -1; } static void reset_loop_device(const char* loopname) { int loopfd = open(loopname, O_RDWR); if (loopfd == -1) { return; } if (ioctl(loopfd, LOOP_CLR_FD, 0)) { } close(loopfd); } static long syz_mount_image(volatile long fsarg, volatile long dir, volatile long flags, volatile long optsarg, volatile long change_dir, volatile unsigned long size, volatile long image) { unsigned char* data = (unsigned char*)image; int res = -1, err = 0, need_loop_device = !!size; char* mount_opts = (char*)optsarg; char* target = (char*)dir; char* fs = (char*)fsarg; char* source = NULL; char loopname[64]; if (need_loop_device) { int loopfd; memset(loopname, 0, sizeof(loopname)); snprintf(loopname, sizeof(loopname), "/dev/loop%llu", procid); if (setup_loop_device(data, size, loopname, &loopfd) == -1) return -1; close(loopfd); source = loopname; } mkdir(target, 0777); char opts[256]; memset(opts, 0, sizeof(opts)); if (strlen(mount_opts) > (sizeof(opts) - 32)) { } strncpy(opts, mount_opts, sizeof(opts) - 32); if (strcmp(fs, "iso9660") == 0) { flags |= MS_RDONLY; } else if (strncmp(fs, "ext", 3) == 0) { bool has_remount_ro = false; char* remount_ro_start = strstr(opts, "errors=remount-ro"); if (remount_ro_start != NULL) { char after = *(remount_ro_start + strlen("errors=remount-ro")); char before = remount_ro_start == opts ? '\0' : *(remount_ro_start - 1); has_remount_ro = ((before == '\0' || before == ',') && (after == '\0' || after == ',')); } if (strstr(opts, "errors=panic") || !has_remount_ro) strcat(opts, ",errors=continue"); } else if (strcmp(fs, "xfs") == 0) { strcat(opts, ",nouuid"); } res = mount(source, target, fs, flags, opts); if (res == -1) { err = errno; goto error_clear_loop; } res = open(target, O_RDONLY | O_DIRECTORY); if (res == -1) { err = errno; goto error_clear_loop; } if (change_dir) { res = chdir(target); if (res == -1) { err = errno; } } error_clear_loop: if (need_loop_device) reset_loop_device(loopname); errno = err; return res; } 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)) { } } 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); } #define FS_IOC_SETFLAGS _IOW('f', 2, long) static void remove_dir(const char* dir) { int iter = 0; DIR* dp = 0; retry: while (umount2(dir, MNT_DETACH | UMOUNT_NOFOLLOW) == 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, MNT_DETACH | UMOUNT_NOFOLLOW) == 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, MNT_DETACH | UMOUNT_NOFOLLOW)) 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, MNT_DETACH | UMOUNT_NOFOLLOW)) 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 reset_loop() { char buf[64]; snprintf(buf, sizeof(buf), "/dev/loop%llu", procid); int loopfd = open(buf, O_RDWR); if (loopfd != -1) { ioctl(loopfd, LOOP_CLR_FD, 0); close(loopfd); } } static void setup_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); write_file("/proc/self/oom_score_adj", "1000"); if (symlink("/dev/binderfs", "./binderfs")) { } } static void close_fds() { for (int fd = 3; fd < MAX_FDS; fd++) close(fd); } static void setup_usb() { if (chmod("/dev/raw-gadget", 0666)) exit(1); } #define SWAP_FILE "./swap-file" #define SWAP_FILE_SIZE (128 * 1000 * 1000) static void setup_swap() { swapoff(SWAP_FILE); unlink(SWAP_FILE); int fd = open(SWAP_FILE, O_CREAT | O_WRONLY | O_CLOEXEC, 0600); if (fd == -1) { exit(1); return; } fallocate(fd, FALLOC_FL_ZERO_RANGE, 0, SWAP_FILE_SIZE); close(fd); char cmdline[64]; sprintf(cmdline, "mkswap %s", SWAP_FILE); if (runcmdline(cmdline)) { exit(1); return; } if (swapon(SWAP_FILE, SWAP_FLAG_PREFER) == 1) { exit(1); return; } } 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) { int i, call, thread; for (call = 0; call < 4; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 50 + (call == 0 ? 4000 : 0)); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); close_fds(); } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); reset_loop(); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); setup_test(); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: NONFAILING(memcpy((void*)0x20000040, "nilfs2\000", 7)); NONFAILING(memcpy((void*)0x20000100, "./file0\000", 8)); NONFAILING(*(uint16_t*)0x200003c0 = 0); NONFAILING(*(uint32_t*)0x200003c2 = 0); NONFAILING(sprintf((char*)0x200003c6, "%020llu", (long long)-1)); NONFAILING(*(uint16_t*)0x200003da = 0); NONFAILING(sprintf((char*)0x200003dc, "0x%016llx", (long long)0)); NONFAILING(*(uint16_t*)0x200003ee = 0); NONFAILING(*(uint8_t*)0x200003f0 = 0); NONFAILING(*(uint8_t*)0x200003f1 = -1); NONFAILING(memcpy( (void*)0x200003f2, "\x0f\xde\x9b\x52\x2c\x63\xab\x93\xc9\x89\xb3\xb6\xa6\x14\x7a\x8c\x8a" "\x9d\x15\x53\x8a\xeb\xe5\x1c\xfa\x21\x6d\x08\x3b\x0a\x42\xe9\x33\xb6" "\x59\xd0\x76\x71\x06\x41\x4c\xbb\xff\x84\xd6\x52\x44\xad\xe2\x54\xeb" "\x3f\x4d\x76\x23\x95\x74\x55\x63\x79\xb8\x3b\x59\xbf\x52\x16\x2f\xae" "\x84\xd2\x2b\x26\x4e\x6d\x8b\x7c\x0b\xee\x55\xe6\x53\x00\x00\x00\x00" "\xe8\xde\x6b\xc2\x61\xe2\xa2\x8d\x34\x39\x97\x5d\x09\x70\x7f\x33\xe8" "\x72\xfd\x16\x00\x39\x67\xb2\x27\x4a\xa4\xc9\xe1\xda\x8f\x0d\x33\x2d" "\x5f\xff\xff\x04\x00\x00\x00\x00\x00\x00\x8e\xec\x7c\xeb\x65\x1c\x2d" "\x4d\xc2\x3e\x68\x72\xcd\xb0\x2e\x01\x6b\x44\xd0\x80\x3e\x24\x94\x21" "\xf8\xa9\xf1\x61\x99\xfd\x23\x7b\x80\x0c\xa6\x9a\x63\x66\xdb\x8c\x8a" "\x9f\x23\x2c\x9f\x74\x54\x5f\xa2\x1e\xb1\xb3\x25\x2d\xfa\x2d\x95\xdb" "\x2c\x87\x00\x47\xec\xa3\xe4\x3f\x34\x28\x91\x1e\x33\x64\xe6\x60\x90" "\x15\x43\x9e\x66\x4b\x1f\x47\xda\x45\x3b\x00\xbf\x3f\x89\x85\x69\x59" "\x45\x3b\xee\x3d\x37\x69\xe9\xa1\xc4\x7d\x0a\xa7\x0f\x09\x7a\xfa\x2c" "\x5c\x16\xaa\x5f\x6f\x08\xa3\xe6\xa9\xc6\x9d\xb2\x54\x02\x1e\xba\x4b" "\xe4\x50\xc9\x1e\x1e\x0d\xa7\x83\x51\xc4\x30\x2d\xc9\x19\x00\xbe\x15" "\x20\xd3\x4c\xcf\x25\x63\x38\x40\x2a\x46\x43\x0d\x0a\x79\x2e\x3c\x4e" "\x55\x55\x6e\x38\x21\xbd\x34\xcb\xa5\xa1\xe6\xe2\xeb\x9f\x80\xa9\x8d" "\xcb\xd6\x4a\x70\xbc\x7a\xee\xfd\x21\x84\xbb\x6b\xc7\x7b\x24\xa5\xdc" "\xfe\x06\x09\x00\xcf\xc4\x04\x96\xa1\xcb\xab\x5f\x72\xc1\x61\xe3\x09" "\xc0\x1d\x90\x16\xd5\x09\x60\x5d\x92\xc4\x0b\x59\xda\xa5\x2d\x78\x6b" "\xf0\x0c\xeb\x37\x8d\x08\xca\x5a\x48\x09\xaa\xe3\x70\x86\x99\x23\x64" "\x9b\x69\xa8\x9b\x70\x98\x33\x09\xd5\x61\x74\xb4\x28\x71\x69\xdd\x60" "\xac\x7a\x6e\x2f\xdf\xab\xee\x2e\xd7\x0e\x74\x68\x27\xc2\x3e\x2a\x79" "\x2c\x6d\x8e\xe9\xd3\x1a\xd5\x85\xe8\xba\xce\xc3\xa9\x6a\x99\xf0\x08" "\x96\x3c\x89\x5f\x31\xd3\x6a\x4e\x24\x9d\x05\xb2\x4b\x44\x08\x6a\x0f" "\x8a\xc6\x53\x5e\x8e\xef\x5e\xc6\xe5\x1b\xd0\xd2\x0d\xdb\x75\x74\xef" "\x23\x40\x8e\xae\x30\x0f\xae\x95\x4a\x4f\x4a", 470)); NONFAILING(sprintf((char*)0x200005c8, "%023llo", (long long)0)); NONFAILING(*(uint16_t*)0x200005df = 0); NONFAILING(memcpy( (void*)0x20001f40, "\x78\x9c\xec\xdd\x4d\x8c\x5b\x47\x1d\x00\xf0\x67\xef\x7a\xf3\x59\xe2" "\x94\x84\x86\xb4\xb4\x09\x85\xb6\x02\xba\xdb\xec\x86\xf0\x11\x41\x53" "\x35\x17\xa2\xa6\xe2\x56\xa9\xe2\x12\xa5\x69\x89\x48\x03\x22\x95\xa0" "\x55\x0e\x49\x4e\xdc\x68\x15\x85\x1b\xe2\x43\x9c\x7a\xa9\x00\x21\xd1" "\x0b\x8a\x7a\xe2\x52\x89\x46\xe2\xd2\x53\xe1\xc0\x81\x28\x48\x91\x38" "\x40\x4b\x62\x14\xef\x8c\xd7\xfe\xc7\xee\xb3\x93\xdd\x7d\xeb\xf5\xef" "\x27\x8d\xc7\xef\xcd\xd8\x33\xcf\xfb\xfc\xf6\x79\xde\x9b\x99\x02\x98" "\x58\xf5\xf6\x63\xa3\xfd\x78\xe9\xed\x8b\x87\xff\xf9\xc8\x3f\x36\xdd" "\x7a\xfe\x64\x27\x47\xb3\xfd\x38\xdd\xb5\x74\x2b\x77\x2d\x2d\x4f\x87" "\xf7\xfb\x60\x6a\x31\xbe\x71\xfd\xec\xf1\x7e\x71\xad\x98\x6f\x3f\xe6" "\xe5\xe2\xd9\x6b\x9d\xd7\x6e\x29\x8a\xe2\x5c\xb1\xa7\xb8\x5c\x34\x8b" "\xdd\x97\xae\xbc\xf1\xee\xfc\x33\x47\xcf\x1f\xb9\xb0\xf7\xbd\x37\x0f" "\x5e\x5d\x89\x6d\x07\x00\x80\x49\xf3\xed\xcb\x07\xf7\xef\xfc\xdb\x5f" "\xee\xdf\xfe\xe1\x5b\x0f\x1e\x2a\x36\x74\xd6\xe7\xf3\xf3\x66\x5a\xde" "\x9a\xce\xfb\x0f\xa5\x13\xff\x7c\xfe\x5f\x2f\x7a\x97\x6b\x5d\xa1\xdb" "\x4c\xc8\x37\x9d\x42\x3d\xe4\x9b\xea\x93\xaf\xbb\x9c\x46\xce\xb7\xb1" "\xf7\x75\xb1\xfc\x99\xf0\xbe\x8d\x01\xf9\x36\x94\x94\x3f\xd5\xb5\xae" "\xdf\x76\xc3\x38\xcb\xfb\x71\xb3\xa8\xd5\x67\x7b\x96\xeb\xf5\xd9\xd9" "\xc5\xdf\xe4\x45\xfb\x77\xfd\x4c\x6d\xf6\xf4\xc9\x53\x2f\x9e\xa9\xa8" "\xa2\xc0\xb2\xfb\xf7\x43\x45\x51\xec\x11\x84\x49\x0b\xad\x6d\x9d\x2f" "\x41\xe5\x75\xa9\x2e\x74\x7d\x0a\x00\x95\x8a\xd7\x0b\x6f\x73\x2e\xb6" "\x2c\xdc\x9d\xce\xbb\x4d\x0f\x57\xfe\xb5\xa7\xea\xfd\x5f\x0f\xcb\x60" "\xb5\xf7\x7f\xe5\xc7\xf7\xef\xad\xc7\x6a\x97\x5f\xb6\xfd\xbf\x39\xef" "\x88\xc3\xf2\x19\x7e\x6f\xda\xb8\xa2\xf5\x58\x6e\x79\xbb\xf2\xf7\x68" "\x6b\x5a\x8e\xd7\x11\xe2\xfd\x4b\xa3\x1e\x7f\xf2\xfb\x4d\x85\xf7\x6b" "\x0c\x59\xcf\x41\xd7\x11\xc6\xe5\xfa\xc2\xa0\x7a\x4e\xad\x72\x3d\xee" "\xd4\xa0\xfa\xc7\xfd\x62\xbd\xfa\x46\x8a\xf3\xe7\xf0\xcd\x90\xde\xfd" "\xfd\x89\x7f\xd3\x71\xf9\x1b\x03\xfd\xfd\x67\xcd\xb5\xff\x6f\x5a\xaa" "\x5c\xe5\x75\x11\x84\xf5\x1d\x5a\x55\x1e\x7c\x80\x35\x2d\xde\x37\xd7" "\x4a\x72\x7a\xbc\xaf\x2f\xa6\x6f\x28\x49\xdf\x58\x92\xbe\xa9\x24\x7d" "\x73\x49\xfa\x96\x92\x74\x98\x64\xbf\x7f\xe5\xa7\xc5\xeb\xb5\xa5\xdf" "\xf9\xf1\x37\xfd\x8d\xeb\x67\xdb\x5f\x96\x61\xdb\xc3\x72\x3b\xdb\x3d" "\x29\xfe\xc4\x88\xf5\x89\xed\x91\xa3\xb6\xc7\xc5\xfb\x7e\x47\x75\xb7" "\xe5\xc7\xfb\x89\x61\x2d\xfb\xe3\xb1\xe7\x4e\x7c\xf5\x85\xe7\xaf\x2c" "\xde\xff\x5f\xeb\xec\xff\x37\xd3\xfe\xbe\x27\x2d\x37\xd3\x77\xeb\x72" "\xca\x90\xdb\x0b\x63\xbb\x7a\xe7\xde\xff\x66\x6f\x39\xf5\x01\xf9\xee" "\x0d\xf5\xb9\xa7\x4f\xfe\xf6\xf3\x1d\xbd\xf9\x6a\x3b\x96\xde\xa7\xe8" "\x3a\xce\xdc\x56\x8f\x5d\xbd\xaf\xdb\x36\x28\xdf\x03\xbd\xf9\x9a\x21" "\xdf\xa6\x14\xe2\x55\x90\x78\x7e\xb2\x39\xbc\x2e\x9f\x7f\xe4\xe3\x6a" "\xfe\xbc\xa6\xc3\xf6\x36\xc2\x76\xcc\x84\x7a\xe4\xe3\xca\xf6\x14\x8f" "\xd7\xd5\x18\xd6\xaa\xbc\x3f\x0e\xba\xff\x3f\xef\x9f\xbb\x8a\x46\xed" "\xc5\x93\xa7\x4e\x3c\x91\x96\xf3\x7e\xfa\xe7\xa9\xc6\x86\x5b\xeb\xf7" "\xad\x72\xbd\x81\xbb\x37\x6c\xff\x9f\x5d\x45\x6f\xff\x9f\xad\x9d\xf5" "\x8d\x7a\xf7\x71\x61\xdb\xd2\xfa\x5a\xf7\x71\xa1\x19\xd6\xcf\x0f\x58" "\xbf\x90\x96\xf3\xff\xb9\xef\x4e\x6d\x6a\xaf\x9f\x3d\xfe\xfd\x53\x2f" "\x2c\xf7\xc6\xc3\x84\x3b\xf3\xea\x6b\xdf\x3b\x76\xea\xd4\x89\x1f\x7a" "\xe2\x89\x27\x9e\x74\x9e\x54\x7d\x64\x02\x56\xda\xdc\x2b\x2f\xff\x60" "\xee\xcc\xab\xaf\x3d\x7e\xf2\xe5\x63\x2f\x9d\x78\xe9\xc4\xe9\x85\x03" "\x07\x16\xe6\xe7\x0f\x7c\x6d\x61\xff\x5c\xfb\xbc\x7e\xae\xfb\xec\x1e" "\x58\x4f\x96\xfe\xe9\x57\x5d\x13\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x60\x58\x3f\x3a\x72\xf8\xca\x5f\xdf\xf9\xca\xfb\x8b\xfd\xff\x97\xfa" "\xff\xe5\xfe\xff\xf9\xce\xdf\xdc\xff\xff\x27\xa1\xff\x7f\xec\x27\x9f" "\xfb\xc1\xe7\x7e\x80\xdb\xfb\xa4\xb7\xf3\x84\x01\x56\x67\x42\xbe\x46" "\x0a\x9f\x0c\xf5\xdd\x11\xca\xd9\x19\x5e\xf7\xa9\x14\x77\xe6\xf1\x4b" "\xfd\xff\x73\x71\x71\x5c\xd7\x5c\x9f\xfb\xc2\xfa\x38\x7e\x6f\xce\x17" "\x86\x13\xb8\x6d\xbc\x94\x99\x30\x06\x49\x9c\x2f\xf0\xb3\x29\xbe\x90" "\xe2\x5f\x17\x50\xa1\xda\xcf\xfb\xaf\x4e\x71\xd9\xf8\xd6\x79\x5f\xcf" "\xe3\x53\x18\x97\x62\x3c\xe5\xbf\x5b\x1e\xcf\x24\x8f\x63\x92\xfb\x7f" "\x0f\x1a\xd7\x29\x1f\xff\xb7\xaf\x42\x1d\x59\x7e\xab\xd1\x9d\xb0\xea" "\x6d\x04\xfa\xfb\xd7\x9a\x1b\xff\x7b\xbd\x87\xae\x5f\x0c\x95\xd7\x45" "\x58\x6b\xe1\x46\xab\xd5\x5a\xcd\xf2\x5a\x2d\xb3\x78\x00\x6b\x43\xd5" "\xf3\x7f\xe6\x76\xcf\x1c\x9f\xfe\xd3\xb7\x36\xde\x0a\x39\xdb\xb5\xa7" "\x7a\x8f\x97\x71\xfc\x52\xb8\x1b\x55\xcf\x7f\x59\x59\xf9\xb9\x61\x71" "\x52\xb7\x7f\xc8\xf2\x97\x7b\xfe\xcf\xce\xfc\x77\x43\x1f\xff\xc2\x8c" "\x79\xcd\x3b\x2b\xf7\xbf\xbf\xb8\xfa\x7e\x57\xb1\xc5\xee\x61\xcb\x8f" "\xdb\x9f\xc7\x81\xde\x31\x5a\xf9\x1f\xa6\xf2\xf3\xd6\x3c\x5a\x0c\x57" "\x7e\xeb\x57\xa1\xfc\x78\x41\x68\x48\x1f\x85\xf2\x37\x0f\x59\x7e\xdc" "\xfe\x8b\xa3\x16\x9c\x0a\xfc\x5f\x2a\x3f\x7f\x6c\x8f\x3d\x3c\x6c\xf9" "\x8b\x6f\x50\xab\xf7\xd6\x23\xb6\x1b\xe7\xeb\x7f\xb1\xdd\x38\xbb\x11" "\xb6\x3f\x8f\xed\x39\xf2\xdf\xff\x0e\x27\x6a\xbc\x99\xca\x87\x49\x36" "\x2e\xf3\xcc\x8e\x6a\x5c\xe6\xff\x1d\x24\xde\x87\xf1\xe5\xb4\x9c\x0f" "\x84\xf9\x3e\x87\x38\xdf\xc9\xa8\xf5\xcf\xf7\x57\xe4\xff\x03\x3b\xc3" "\xfb\xd7\x4a\xfe\xbf\x99\xff\x77\xbc\x7d\x3d\xc5\x65\xdf\x87\x3c\xff" "\x6f\xde\x1f\x9b\x7d\x96\xeb\x5d\xcb\x8d\x3e\x9f\xed\x7a\x3d\xd6\xc0" "\xb8\xfa\xc0\xf5\x3f\x61\xcc\x43\xfb\x8c\x66\x0d\xd4\x63\x1c\x43\xab" "\xd5\x5a\xd9\x06\xad\x12\x95\x16\x4e\xe5\x9f\x7f\xd5\xbf\x13\xaa\x2e" "\xbf\xea\xcf\xbf\x4c\x9c\xff\x37\x9e\xc3\xc7\xf9\x7f\x63\x7a\x9c\xff" "\x37\xa6\xc7\xf9\x7f\x63\x7a\xbb\x5d\xf1\xa3\xa5\x49\x7b\x63\x7a\x9c" "\xff\x37\x7e\x9e\x71\xfe\xdf\x98\x7e\x5f\x28\x37\xce\x0f\xbc\xab\x24" "\xfd\xd3\x25\xe9\xbb\x4b\xd2\xef\x2f\x49\x7f\xa0\x24\xfd\x33\x25\xe9" "\x7b\x4b\xd2\x1f\x2c\x49\x7f\xa8\x24\xfd\xde\x92\xf4\x87\x4b\xd2\x3f" "\x57\x92\xfe\xf9\x92\xf4\x47\x4a\xd2\x1f\xfb\xf8\xf4\x85\x1f\x97\xbc" "\x7e\xbd\xcb\xfd\x51\x26\x75\xfb\x61\x92\xc5\xfe\x79\xbe\xff\x30\x39" "\xf2\xf5\x9f\x41\xdf\xff\x1d\x25\xe9\xc0\xf8\xfa\xd9\x5b\xfb\x9e\x7e" "\xfe\x77\xdf\x69\x2e\xf6\xff\x9f\xe9\xb4\x87\xe4\xeb\x78\x87\xd2\x72" "\x23\xfd\x76\x8e\xbf\x97\x62\xfb\xc9\x54\x4a\x7b\x27\x2d\xff\x3d\xa4" "\xaf\xf5\xf6\x0e\x98\x24\x71\xfc\x8c\xf8\xff\xfd\xd1\x92\x74\x60\x7c" "\xe5\xfb\xbc\x7c\xbf\x61\x02\xd5\xfa\x8f\xd8\x33\xec\xb8\x55\x83\xce" "\xf3\x19\x2f\x5f\x48\xf1\x17\x53\xfc\xa5\x14\x3f\x9e\xe2\xd9\x14\xcf" "\xa5\x78\x5f\x8a\xe7\x57\xa9\x7e\xac\x8c\xa7\x7f\xfb\x87\x83\xaf\xd7" "\x96\x7e\xef\x6f\x0b\xe9\xc3\xde\x4f\x1e\xfb\x03\xc5\x71\xa2\x16\x86" "\xac\x4f\x6c\x1f\x18\xf5\x7e\xf6\x38\x8e\xdf\xa8\xee\xb6\xfc\x3b\xec" "\x0e\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x50\x99\x7a\xfb\x71\xff\xfe\x5d" "\xb5\xa2\xb8\xf4\xf6\xc5\xc3\xcf\x1d\x3d\x39\x77\x6b\xcd\x93\x9d\x1c" "\xcd\xf6\xe3\x74\xd7\x52\xa3\xf3\xba\xa2\x78\x22\xc5\x53\x29\xfe\x65" "\x7a\x72\xe3\xfa\xd9\xe3\xdd\xf1\xcd\x14\xd7\x8a\xf9\xa2\x56\xd4\x3a" "\xeb\x8b\x67\xaf\x75\x4a\xda\x52\x14\xc5\xb9\x62\x4f\x71\xb9\x68\x16" "\xbb\x2f\x5d\x79\xe3\xdd\xf9\x67\x8e\x9e\x3f\x72\x61\xef\x7b\x6f\x1e" "\xbc\xba\x72\x9f\x00\x00\x00\x00\xac\x7f\xff\x0f\x00\x00\xff\xff\x62" "\x39\x19\x19", 2638)); NONFAILING(syz_mount_image( /*fs=*/0x20000040, /*dir=*/0x20000100, /*flags=MS_POSIXACL|MS_NOEXEC|MS_NODIRATIME|MS_NODEV*/ 0x1080c, /*opts=*/0x200003c0, /*chdir=*/3, /*size=*/0xa4e, /*img=*/0x20001f40)); break; case 1: NONFAILING(memcpy((void*)0x20000140, "./file2\000", 8)); syscall(__NR_truncate, /*file=*/0x20000140ul, /*len=*/0ul); break; case 2: NONFAILING(memcpy((void*)0x20000000, ".\000", 2)); res = syscall(__NR_fspick, /*dfd=*/0xffffff9c, /*path=*/0x20000000ul, /*flags=*/0ul); if (res != -1) r[0] = res; break; case 3: syscall(__NR_fsconfig, /*fd=*/r[0], /*cmd=*/7ul, /*key=*/0ul, /*value=*/0ul, /*aux=*/0ul); break; } } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x21000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1, /*offset=*/0ul); setup_usb(); setup_swap(); install_segv_handler(); for (procid = 0; procid < 5; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; }