// https://syzkaller.appspot.com/bug?id=66a47f8ddcf8d46571cb3fc82fbba5edbbf12e0d // 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_memfd_create #define __NR_memfd_create 319 #endif static unsigned long long procid; static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static 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 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); } static int runcmdline(char* cmdline) { int ret = system(cmdline); if (ret) { } return ret; } 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 long syz_open_dev(volatile long a0, volatile long a1, volatile long a2) { if (a0 == 0xc || a0 == 0xb) { char buf[128]; sprintf(buf, "/dev/%s/%d:%d", a0 == 0xc ? "char" : "block", (uint8_t)a1, (uint8_t)a2); return open(buf, O_RDWR, 0); } else { unsigned long nb = a1; char buf[1024]; char* hash; strncpy(buf, (char*)a0, sizeof(buf) - 1); buf[sizeof(buf) - 1] = 0; while ((hash = strchr(buf, '#'))) { *hash = '0' + (char)(nb % 10); nb /= 10; } return open(buf, a2, 0); } } //% 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"); } else if (strncmp(fs, "gfs2", 4) == 0 && (strstr(opts, "errors=panic") || strstr(opts, "debug"))) { strcat(opts, ",errors=withdraw"); } 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_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)) { } if (symlink("/dev/binderfs", "./binderfs")) { } } 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(); if (unshare(CLONE_NEWNET)) { } write_file("/proc/sys/net/ipv4/ping_group_range", "0 65535"); initialize_tun(); sandbox_common_mount_tmpfs(); loop(); 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"); flush_tun(); } static void close_fds() { for (int fd = 3; fd < MAX_FDS; fd++) close(fd); } static const char* setup_binfmt_misc() { if (mount(0, "/proc/sys/fs/binfmt_misc", "binfmt_misc", 0, 0) && errno != EBUSY) { return NULL; } if (!write_file("/proc/sys/fs/binfmt_misc/register", ":syz0:M:0:\x01::./file0:") || !write_file("/proc/sys/fs/binfmt_misc/register", ":syz1:M:1:\x02::./file0:POC")) return "write(/proc/sys/fs/binfmt_misc/register) failed"; return NULL; } #define SWAP_FILE "./swap-file" #define SWAP_FILE_SIZE (128 * 1000 * 1000) static const char* setup_swap() { swapoff(SWAP_FILE); unlink(SWAP_FILE); int fd = open(SWAP_FILE, O_CREAT | O_WRONLY | O_CLOEXEC, 0600); if (fd == -1) return "swap file open failed"; fallocate(fd, FALLOC_FL_ZERO_RANGE, 0, SWAP_FILE_SIZE); close(fd); char cmdline[64]; sprintf(cmdline, "mkswap %s", SWAP_FILE); if (runcmdline(cmdline)) return "mkswap failed"; if (swapon(SWAP_FILE, SWAP_FLAG_PREFER) == 1) return "swapon failed"; return NULL; } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { int iter = 0; for (;; iter++) { reset_loop(); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { setup_test(); execute_one(); close_fds(); 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; } } } uint64_t r[1] = {0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // syz_mount_image$ext4 arguments: [ // fs: ptr[in, buffer] { // buffer: {65 78 74 34 00} (length 0x5) // } // dir: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 30 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 00} (length 0xfd) // } // flags: mount_flags = 0x4000 (8 bytes) // opts: ptr[in, fs_options[ext4_options]] { // fs_options[ext4_options] { // elems: array[fs_opt_elem[ext4_options]] { // fs_opt_elem[ext4_options] { // elem: union ext4_options { // nombcache: buffer: {6e 6f 6d 62 63 61 63 68 65} (length 0x9) // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[ext4_options] { // elem: union ext4_options { // errors_continue: buffer: {65 72 72 6f 72 73 3d 63 6f 6e 74 69 // 6e 75 65} (length 0xf) // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[ext4_options] { // elem: union ext4_options { // stripe: fs_opt["stripe", fmt[hex, int32]] { // name: buffer: {73 74 72 69 70 65} (length 0x6) // eq: const = 0x3d (1 bytes) // val: int32 = 0x7 (18 bytes) // } // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[ext4_options] { // elem: union ext4_options { // discard: buffer: {64 69 73 63 61 72 64} (length 0x7) // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[ext4_options] { // elem: union ext4_options { // max_dir_size_kb: fs_opt["max_dir_size_kb", fmt[hex, int32]] { // name: buffer: {6d 61 78 5f 64 69 72 5f 73 69 7a 65 5f 6b 62} // (length 0xf) eq: const = 0x3d (1 bytes) val: int32 = 0x0 (18 // bytes) // } // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[ext4_options] { // elem: union ext4_options { // debug_want_extra_isize: fs_opt["debug_want_extra_isize", // fmt[hex, int32]] { // name: buffer: {64 65 62 75 67 5f 77 61 6e 74 5f 65 78 74 72 // 61 5f 69 73 69 7a 65} (length 0x16) eq: const = 0x3d (1 // bytes) val: int32 = 0x84 (18 bytes) // } // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[ext4_options] { // elem: union ext4_options { // max_batch_time: fs_opt["max_batch_time", fmt[hex, int32]] { // name: buffer: {6d 61 78 5f 62 61 74 63 68 5f 74 69 6d 65} // (length 0xe) eq: const = 0x3d (1 bytes) val: int32 = 0x0 (18 // bytes) // } // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[ext4_options] { // elem: union ext4_options { // test_dummy_encryption: buffer: {74 65 73 74 5f 64 75 6d 6d 79 // 5f 65 6e 63 72 79 70 74 69 6f 6e} (length 0x15) // } // comma: const = 0x2c (1 bytes) // } // } // common: array[fs_opt_elem[fs_options_common]] { // } // null: const = 0x0 (1 bytes) // } // } // chdir: int8 = 0xd (1 bytes) // size: len = 0x5f6 (8 bytes) // img: ptr[in, buffer] { // buffer: (compressed buffer with length 0x5f6) // } // ] // returns fd_dir memcpy((void*)0x200000000140, "ext4\000", 5); memcpy((void*)0x200000000200, "./" "file0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\000", 253); memcpy((void*)0x200000001400, "nombcache", 9); *(uint8_t*)0x200000001409 = 0x2c; memcpy((void*)0x20000000140a, "errors=continue", 15); *(uint8_t*)0x200000001419 = 0x2c; memcpy((void*)0x20000000141a, "stripe", 6); *(uint8_t*)0x200000001420 = 0x3d; sprintf((char*)0x200000001421, "0x%016llx", (long long)7); *(uint8_t*)0x200000001433 = 0x2c; memcpy((void*)0x200000001434, "discard", 7); *(uint8_t*)0x20000000143b = 0x2c; memcpy((void*)0x20000000143c, "max_dir_size_kb", 15); *(uint8_t*)0x20000000144b = 0x3d; sprintf((char*)0x20000000144c, "0x%016llx", (long long)0); *(uint8_t*)0x20000000145e = 0x2c; memcpy((void*)0x20000000145f, "debug_want_extra_isize", 22); *(uint8_t*)0x200000001475 = 0x3d; sprintf((char*)0x200000001476, "0x%016llx", (long long)0x84); *(uint8_t*)0x200000001488 = 0x2c; memcpy((void*)0x200000001489, "max_batch_time", 14); *(uint8_t*)0x200000001497 = 0x3d; sprintf((char*)0x200000001498, "0x%016llx", (long long)0); *(uint8_t*)0x2000000014aa = 0x2c; memcpy((void*)0x2000000014ab, "test_dummy_encryption", 21); *(uint8_t*)0x2000000014c0 = 0x2c; *(uint8_t*)0x2000000014c1 = 0; memcpy( (void*)0x200000000c00, "\x78\x9c\xec\xdd\xcf\x6b\x1c\x55\x1c\x00\xf0\xef\x6c\x7e\x34\x69\xaa\x49" "\x8b\xa8\xf5\x60\x17\x44\x5a\xd0\x26\x4d\xda\x4a\x11\x0f\xed\x55\x4a\xa8" "\x3f\xf0\xe2\xc5\xd8\xa4\xb5\x76\xdb\x86\x26\xa2\xa9\x42\x53\xa8\x17\x41" "\xbc\x88\x08\x9e\x3c\x58\xc1\x3f\x42\x8b\xbd\xf6\xa4\x20\x78\xf0\xe2\x49" "\x0a\x45\xa5\x47\xc1\x95\xd9\xcc\xa4\xd9\xec\x6e\x7e\x6c\x93\x6c\xec\x7c" "\x3e\xb0\xcd\xcc\x7b\x33\xf3\xde\x74\xf3\xcd\x9b\x79\xfb\xde\x6c\x00\x85" "\x55\x4e\xff\x29\x45\xec\x8d\x88\xe9\x24\x62\x30\x99\x5f\xcc\xeb\x8e\x2c" "\xb3\xbc\xb0\xdd\xbd\xbf\x3f\x3a\x9d\xbe\x92\xa8\x56\x5f\xfb\x33\x89\x24" "\x4b\xcb\xb7\x4f\xb2\x9f\x03\xd9\xce\x7d\x11\xf1\xd3\x8f\x49\xec\xe9\x6a" "\x2c\x77\x66\xee\xca\xf9\x89\x4a\x65\xea\x72\xb6\x3e\x32\x7b\x61\x7a\x64" "\x66\xee\xca\xc1\x73\x17\x26\xce\x4e\x9d\x9d\xba\x38\xf6\xc2\xd8\xb1\xa3" "\x47\x8e\x1e\x1b\x3d\xd4\xd6\x79\x5d\x6d\x92\x76\xf2\xfa\xbb\xef\x0f\x7e" "\x32\xfe\xe6\x37\x5f\xfd\x93\x8c\x7e\xfb\xdb\x78\x12\xc7\xe3\xe5\x6c\xc3" "\xa5\xe7\x11\x11\xbf\x94\xda\x2a\xb5\x5e\x39\xca\xb5\xff\x93\xa4\x31\x6b" "\xe0\xd8\x06\x1c\x7f\x3b\xe8\xca\x7e\x4f\x96\xbe\xc5\x49\x77\x07\x2b\xc4" "\xba\xe4\xef\x5f\x4f\x44\x3c\x11\x83\xd1\x15\xf7\xdf\xbc\xc1\xf8\xf8\x95" "\x8e\x56\x0e\xd8\x54\xd5\x24\xa2\x0a\x14\x54\x22\xfe\xa1\xa0\xf2\xeb\x80" "\xfc\xde\x7e\xd9\x7d\x70\x6c\xc4\x7d\x30\xb0\x3d\xdd\x3d\xb1\xd0\x01\xd0" "\x18\xff\xdd\x0b\x7d\x83\xd1\x57\xeb\x1b\xd8\x79\x2f\x89\xa5\xdd\x3a\x49" "\x44\xb4\xd7\x33\x57\x6f\x57\x44\xdc\xbe\x35\x7e\xfd\xcc\xad\xf1\xeb\xd1" "\xd8\x0f\x07\x6c\xa2\xf9\x6b\x11\xf1\x64\xb3\xf8\x4f\x6a\xf1\x3f\x14\x7d" "\x31\x54\x8b\xff\x52\x5d\xfc\xa7\xd7\x05\xa7\xb2\x9f\x69\xfa\xab\x6d\x96" "\xbf\xbc\xab\xb8\x31\xfe\x0f\xb7\x79\x64\x60\x35\x0b\xf1\xdf\xb7\x62\xfc" "\x47\x8b\xf8\x7f\x6b\x49\xfc\xbf\xdd\x66\xf9\xe5\xfb\x8b\xef\xf4\xd7\xc5" "\x7f\x7f\xbb\xa7\x04\x00\x00\x00\x00\x00\x00\x85\x75\xf3\x44\x44\x3c\xdf" "\xec\xf3\xff\xd2\xe2\xf8\x9f\x68\x32\xfe\x67\x20\x22\x8e\x6f\x40\xf9\xe5" "\x65\xeb\x8d\x9f\xff\x97\xee\x6c\x40\x31\x40\x13\x77\x4f\x44\xbc\xd4\x74" "\xfc\x6f\x29\x1f\xfd\x3b\xd4\x95\x2d\x3d\x52\x1b\x0f\xd0\x93\x9c\x39\x57" "\x99\x3a\x14\x11\x8f\x46\xc4\x81\xe8\xd9\x91\xae\x8f\xae\x50\xc6\xc1\x4f" "\xf7\x7c\xd9\x2a\xaf\x9c\x8d\xff\xcb\x5f\x69\xf9\xb7\xb3\xb1\x80\x59\x3d" "\xee\x74\xef\xa8\xdf\x67\x72\x62\x76\xe2\x41\xcf\x1b\x88\xb8\x7b\x2d\xe2" "\xa9\xa6\xe3\x7f\x93\xc5\xf6\x3f\x69\xd2\xfe\xa7\x7f\x0f\xa6\xd7\x58\xc6" "\x9e\x67\x6f\x9c\x6a\x95\xb7\x7a\xfc\x03\x9b\xa5\xfa\x75\xc4\xfe\xa6\xed" "\xff\xfd\xa7\x56\x24\x2b\x3f\x9f\x63\xa4\x76\x3d\x30\x92\x5f\x15\x34\x7a" "\xfa\xc3\xcf\xbe\x6f\x55\x7e\xbb\xf1\xef\x11\x13\xf0\xe0\xd2\xf6\x7f\xe7" "\xca\xf1\x3f\x94\x2c\x7d\x5e\xcf\xcc\xfa\xcb\x38\x3c\xd7\x5d\x6d\x95\xd7" "\xee\xf5\x7f\x6f\xf2\x7a\xed\x91\x33\xbd\x59\xda\x07\x13\xb3\xb3\x97\x47" "\x23\x7a\x93\x93\x5d\x69\x6a\x5d\xfa\xd8\xfa\xeb\x0c\x0f\xa3\x3c\x1e\xf2" "\x78\x49\xe3\xff\xc0\x33\x2b\xf7\xff\x35\xbb\xfe\xef\x8f\x88\xf9\x65\xc7" "\x4e\xfe\xaa\x9f\x53\x9c\x7b\xfc\xdf\x81\xdf\x5b\xd5\xc7\xf5\x3f\x74\x4e" "\x1a\xff\x93\xeb\x6a\xff\xd7\xbf\x30\x76\x63\xe8\x87\x56\xe5\xaf\xad\xfd" "\x3f\x52\x6b\xeb\x0f\x64\x29\xfa\xff\x60\xc1\x17\x79\x98\xf6\xd6\xa7\x37" "\x46\xe1\x62\x40\xd7\x65\x6d\x75\x7d\x01\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe0\x61" "\x50\x8a\x88\x5d\x91\x94\x86\x17\x97\x4b\xa5\xe1\xe1\x88\x81\x88\x78\x2c" "\x76\x96\x2a\x97\x66\x66\x9f\x3b\x73\xe9\xbd\x8b\x93\x69\x5e\xed\xfb\xff" "\x4b\xf9\x37\xfd\x0e\x2e\xac\x27\xf9\xf7\xff\x0f\x2d\x59\x1f\x5b\xb6\x7e" "\x38\x22\x76\x47\xc4\xe7\x5d\xfd\xb5\xf5\xe1\xd3\x97\x2a\x93\x9d\x3e\x79" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xd8\x26\x06" "\x5a\xcc\xff\x4f\xfd\xd1\xd5\xe9\xda\x01\x9b\xae\xbb\xd3\x15\x00\x3a\xa6" "\x49\xfc\xff\xdc\x89\x7a\x00\x5b\x4f\xfb\x0f\xc5\x25\xfe\xa1\xb8\xc4\x3f" "\x14\x97\xf8\x87\xe2\x12\xff\x50\x5c\xe2\x1f\x8a\x4b\xfc\x43\x71\x89\x7f" "\x00\x00\x00\x00\x00\x78\xa8\xec\xde\x77\xf3\xd7\x24\x22\xe6\x5f\xec\xaf" "\xbd\x52\xbd\x59\x5e\x4f\x47\x6b\x06\x6c\xb6\x52\xa7\x2b\x00\x74\x8c\x47" "\xfc\x40\x71\x19\xfa\x03\xc5\xe5\x1e\x1f\x48\x56\xc9\xef\x6b\xb9\xd3\x6a" "\x7b\xae\x64\xfa\xf4\x03\xec\x0c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x85\xb3\x7f\xaf\xf9\xff\x50\x54\xe6\xff\x43\x71\x99\xff\x0f\xc5\x95\xcf" "\xff\xdf\xd7\xe1\x7a\x00\x5b\xcf\x3d\x3e\x10\xab\xcc\xe4\x6f\x3a\xff\x7f" "\xd5\xbd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x8d\x34\x33\x77\xe5" "\xfc\x44\xa5\x32\x75\x79\x23\x17\x76\xc4\x1a\x37\xfe\x6e\x33\x4a\x6f\x77" "\xe1\x8d\xed\x51\x8d\xad\x5c\xa8\x56\xab\x57\xd3\xdf\x82\xed\x52\x9f\xff" "\xf9\x42\x3e\x14\x7e\x8b\x4b\xef\x8e\xb5\x6d\x9c\xcf\xf5\x5b\xdb\x91\x3b" "\xf7\x37\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\xa8\xf7\x5f\x00\x00\x00\xff\xff\x1f\x7d\x23\xe3", 1526); syz_mount_image(/*fs=*/0x200000000140, /*dir=*/0x200000000200, /*flags=MS_REC*/ 0x4000, /*opts=*/0x200000001400, /*chdir=*/0xd, /*size=*/0x5f6, /*img=*/0x200000000c00); // chdir arguments: [ // dir: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 30 00} (length 0x8) // } // ] memcpy((void*)0x200000000140, "./file0\000", 8); syscall(__NR_chdir, /*dir=*/0x200000000140ul); // symlink arguments: [ // old: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 30 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 00} (length 0xfd) // } // new: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 30 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 // 61 61 61 00} (length 0xfe) // } // ] memcpy((void*)0x200000000540, "./" "file0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\000", 253); memcpy((void*)0x200000000640, "./" "file0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\000", 254); syscall(__NR_symlink, /*old=*/0x200000000540ul, /*new=*/0x200000000640ul); // syz_mount_image$ext4 arguments: [ // fs: ptr[in, buffer] { // buffer: {65 78 74 34 00} (length 0x5) // } // dir: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 30 00} (length 0x8) // } // flags: mount_flags = 0x8 (8 bytes) // opts: ptr[in, fs_options[ext4_options]] { // fs_options[ext4_options] { // elems: array[fs_opt_elem[ext4_options]] { // } // common: array[fs_opt_elem[fs_options_common]] { // } // null: const = 0x0 (1 bytes) // } // } // chdir: int8 = 0x1 (1 bytes) // size: len = 0x51a (8 bytes) // img: ptr[in, buffer] { // buffer: (compressed buffer with length 0x51a) // } // ] // returns fd_dir memcpy((void*)0x2000000004c0, "ext4\000", 5); memcpy((void*)0x200000000240, "./file0\000", 8); *(uint8_t*)0x200000000000 = 0; memcpy( (void*)0x200000001200, "\x78\x9c\xec\xdd\x4f\x6c\x23\x57\x19\x00\xf0\x6f\x26\xc9\xda\x9b\xa6\x4d" "\x0a\x3d\x00\x2a\x74\x29\x85\x05\xad\xd6\x4e\xbc\x6d\x54\xf5\x42\x39\x55" "\x08\x55\x42\xf4\xc8\x61\x1b\x12\x27\x8a\x62\xc7\x51\xec\x94\x26\xec\x21" "\x7b\xe4\x8e\x44\x25\x4e\x70\xe2\xcc\x01\x89\x03\x52\x4f\xdc\x91\x38\xc0" "\x8d\x4b\x39\x20\x15\x58\x81\x1a\x24\x24\x5c\x79\x6c\x67\x9d\x3f\x4e\xac" "\x6c\x62\x6f\xe3\xdf\x4f\x1a\xf9\xcd\xbc\xb1\xbf\xf7\x76\x34\xef\x59\x9f" "\x37\xf3\x02\x18\x5b\xb7\x22\x62\x3f\x22\x6e\x44\xc4\xbb\x11\x31\xdb\x39" "\x9e\x74\xb6\x78\xb3\xbd\xb5\xce\xfb\xe4\xd1\x83\xe5\x83\x47\x0f\x96\x93" "\x68\x36\xdf\xf9\x67\x92\xd5\xb7\x8e\x45\xcf\x7b\x5a\x9e\xe9\x7c\x66\x3e" "\x22\x7e\xf0\x56\xc4\x8f\x92\x63\x41\xff\x14\x51\xdf\xdd\xdb\x58\xaa\x54" "\xca\xdb\x9d\x43\xc5\x46\x75\xab\x58\xdf\xdd\xbb\xbb\x5e\x5d\x5a\x2b\xaf" "\x95\x37\x4b\xa5\xc5\x85\xc5\xf9\xd7\xef\xbd\x56\xba\xb4\xbe\xbe\x54\xfd" "\xcd\xc7\x37\x23\xe2\xf7\xbf\xfb\xf2\x47\x7f\xdc\xff\xd6\x4f\x5a\xcd\x9a" "\xe9\xd4\xf5\xf6\xe3\x32\xb5\xbb\x3e\x75\x18\xa7\x65\x32\x22\xbe\x77\x15" "\xc1\x46\x60\xa2\xd3\x9f\x1b\x17\x79\xf3\x85\xde\xc4\x65\x4a\x23\xe2\x73" "\x11\xf1\x72\x76\xff\xcf\xc6\x44\x76\x35\x8f\x3a\x7a\x99\xbe\x3d\xc4\xd6" "\x01\x00\x57\xa1\xd9\x9c\x8d\xe6\x6c\xef\x3e\x00\x70\xdd\xa5\x59\x0e\x2c" "\x49\x0b\x9d\x5c\xc0\x4c\xa4\x69\xa1\xd0\xce\xe1\xbd\x10\xd3\x69\xa5\x56" "\x6f\xdc\x59\xad\xed\x6c\xae\xb4\x73\x65\x73\x31\x95\xae\xae\x57\xca\xf3" "\x9d\x5c\xe1\x5c\x4c\x25\xab\xeb\x93\xe5\x85\xac\xdc\xdd\xaf\x94\x4b\xc7" "\xf6\xef\x45\xc4\xf3\x11\xf1\xb3\xdc\xcd\x6c\xbf\xb0\x5c\xab\xac\x8c\xf2" "\x8b\x0f\x00\x8c\xb1\x67\x8e\xcd\xff\xff\xc9\xb5\xe7\x7f\x00\xe0\x9a\xcb" "\x3f\x2e\xe6\x46\xd9\x0e\x00\x60\x78\xf2\xa3\x6e\x00\x00\x30\x74\xe6\x7f" "\x00\x18\x3f\xe6\x7f\x00\x18\x3f\xe6\x7f\x00\x18\x3f\xe6\x7f\x00\x18\x3f" "\xe6\x7f\x00\x18\x2b\xdf\x7f\xfb\xed\xd6\xd6\x3c\xe8\x3c\xff\x7a\xe5\xbd" "\xdd\x9d\x8d\xda\x7b\x77\x57\xca\xf5\x8d\x42\x75\x67\xb9\xb0\x5c\xdb\xde" "\x2a\xac\xd5\x6a\x6b\xd9\x33\x7b\xaa\xe7\x7d\x5e\xa5\x56\xdb\x5a\x78\x35" "\x76\xde\x2f\x36\xca\xf5\x46\xb1\xbe\xbb\x77\xbf\x5a\xdb\xd9\x6c\xdc\xcf" "\x9e\xeb\x7d\xbf\x3c\x35\x94\x5e\x01\x00\x67\x79\xfe\xa5\x0f\xff\x92\x44" "\xc4\xfe\x1b\x37\xb3\x2d\x7a\x9e\xf7\x7f\xee\x5c\xfd\xe2\x55\xb7\x0e\xb8" "\x4a\xe9\xa8\x1b\x00\x8c\xcc\xc4\xa8\x1b\x00\x8c\xcc\xc9\xd5\xbe\x80\x71" "\x21\x1f\x0f\xe3\xeb\xff\xcd\x66\x33\x7a\xd6\xee\x8d\x88\x87\x87\xa5\x9e" "\x87\x81\xf6\xfd\x2f\x42\x1f\x0c\x14\x26\xb5\x6e\x28\x3c\x7d\x6e\x7f\xf1" "\x09\xf2\xff\xc0\x67\x9a\xfc\x3f\x8c\xaf\x8b\xe5\xff\x7d\x97\x87\xeb\x40" "\xfe\x1f\xc6\x57\xb3\x99\x58\xf3\x1f\x00\xc6\x8c\x1c\x3f\x90\x9c\x53\xdf" "\xfb\xfb\xff\x7c\xb3\x67\x67\xb0\xdf\xff\x01\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe0\x5a" "\x9a\xc9\xb6\x24\x2d\x74\xd6\x02\x9f\x89\x34\x2d\x14\x22\x9e\x8d\x88\xb9" "\x98\x4a\x56\xd7\x2b\xe5\xf9\x88\x78\x2e\x22\xfe\x9c\x9b\xca\xb5\xf6\x17" "\x22\xc2\xba\x41\x00\xf0\x59\x96\xfe\x3d\xe9\xac\xff\x75\x7b\xf6\x95\x99" "\xe3\xb5\x37\x72\xff\xcd\x65\xaf\x11\xf1\xe3\x5f\xbc\xf3\xf3\xf7\x97\x1a" "\x8d\xed\x85\x88\x1b\xc9\xbf\x0e\x8f\x37\x3e\xe8\x1c\x2f\x8d\xa2\xfd\x00" "\xc0\x79\xba\xf3\x74\x77\x1e\xef\xfa\xe4\xd1\x83\xe5\xee\x36\xcc\xf6\x7c" "\xfc\x9d\xf6\xe2\xa2\xad\xb8\x07\x9d\xad\x5d\x33\x19\x93\xd9\x6b\x3e\xcb" "\x35\x4c\xff\x3b\xe9\xec\xb7\xb5\xbe\xaf\x4c\x5c\x42\xfc\xfd\x87\x11\xf1" "\x85\xd3\xfa\x9f\x64\xb9\x91\xb9\xce\xca\xa7\xc7\xe3\xb7\x62\x3f\x3b\xd4" "\xf8\xe9\x91\xf8\x69\x56\xd7\x7e\x6d\xfd\x5b\x7c\xfe\x12\xda\x02\xe3\xe6" "\xc3\xd6\xf8\xf3\xe6\x69\xf7\x5f\x1a\xb7\xb2\xd7\xd3\xef\xff\x7c\x36\x42" "\x3d\xb9\xee\xf8\x77\x70\x62\xfc\x4b\x0f\xc7\xbf\x89\x3e\xe3\xdf\xad\x41" "\x63\xbc\xfa\x87\xef\x9e\x38\xd8\x9c\x6d\xd7\x3d\x8c\xf8\xd2\x64\xc4\x41" "\xf7\xc3\x7b\xc6\x9f\x6e\xfc\xa4\x4f\xfc\x57\x06\x8c\xff\xd7\x17\xbf\xf2" "\x72\xbf\xba\xe6\x2f\x23\x6e\xc7\x69\xfd\x4f\x8e\xc4\x2a\x36\xaa\x5b\xc5" "\xfa\xee\xde\xdd\xf5\xea\xd2\x5a\x79\xad\xbc\x59\x2a\x2d\x2e\x2c\xce\xbf" "\x7e\xef\xb5\x52\x31\xcb\x51\x17\xbb\x99\xea\x93\xfe\xf1\xc6\x9d\xe7\xfa" "\xc5\x6f\xf5\x7f\xba\x4f\xfc\xfc\x39\xfd\xff\xfa\x80\xfd\xff\xd5\xff\xde" "\xfd\xe1\x57\xcf\x88\xff\xcd\xaf\x9d\x7e\xfd\x5f\x38\x23\x7e\x6b\x4e\xfc" "\xc6\x80\xf1\x97\xa6\x7f\x9b\xef\x57\xd7\x8a\xbf\xd2\xa7\xff\xe7\x5d\xff" "\x3b\x03\xc6\xff\xe8\x6f\x7b\x2b\x03\x9e\x0a\x00\x0c\x41\x7d\x77\x6f\x63" "\xa9\x52\x29\x6f\x3f\x79\x21\x7f\xe6\x39\xe9\x65\x84\x18\xa0\x90\x44\xec" "\x5f\x71\x88\xc7\x85\xdc\xaf\x7f\xfa\xd6\xf9\x27\xe7\x86\xd6\x9e\x0b\x16" "\xa2\x5f\xd5\xc4\xd3\xd2\xc2\x6b\x53\xc8\x3d\x1d\xcd\x18\xa0\x30\xea\x91" "\x09\xb8\x6a\x8f\x6f\xfa\x51\xb7\x04\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\xe8\x67\x18\x7f\x4e\x34\xea\x3e\x02\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x70\x7d" "\x7d\x1a\x00\x00\xff\xff\x8f\x8f\xd6\xd8", 1306); syz_mount_image(/*fs=*/0x2000000004c0, /*dir=*/0x200000000240, /*flags=MS_NOEXEC*/ 8, /*opts=*/0x200000000000, /*chdir=*/1, /*size=*/0x51a, /*img=*/0x200000001200); // sendfile arguments: [ // fdout: fd (resource) // fdin: fd (resource) // off: nil // count: intptr = 0x800000009 (8 bytes) // ] syscall(__NR_sendfile, /*fdout=*/(intptr_t)-1, /*fdin=*/(intptr_t)-1, /*off=*/0ul, /*count=*/0x800000009ul); // syz_open_dev$loop arguments: [ // dev: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 6c 6f 6f 70 23 00} (length 0xb) // } // id: intptr = 0x0 (8 bytes) // flags: open_flags = 0x0 (8 bytes) // ] // returns fd_loop memcpy((void*)0x200000000140, "/dev/loop#\000", 11); res = -1; res = syz_open_dev(/*dev=*/0x200000000140, /*id=*/0, /*flags=*/0); if (res != -1) r[0] = res; // ioctl$LOOP_SET_STATUS arguments: [ // fd: fd_loop (resource) // cmd: const = 0x4c02 (4 bytes) // arg: ptr[in, loop_info] { // loop_info { // lo_number: const = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // lo_device: alignptr[const[0, int16]] { // v: const = 0x0 (2 bytes) // pad = 0x0 (6 bytes) // } // lo_inode: const = 0x0 (8 bytes) // lo_rdevice: alignptr[const[0, int16]] { // v: const = 0x0 (2 bytes) // pad = 0x0 (6 bytes) // } // lo_offset: int32 = 0x20007 (4 bytes) // lo_enc_type: lo_encrypt_type = 0x0 (4 bytes) // lo_enc_key_size: int32 = 0x200000 (4 bytes) // lo_flags: lo_flags = 0xd (4 bytes) // lo_name: buffer: {22 53 6a f3 9b 7c 7c b7 43 5b 0a bd 07 2d bc 3a 9a // da 34 cc 97 af 10 fd 4f cc a1 57 48 32 8c 53 09 c3 9f b6 98 9b a7 43 // d3 0b 59 c4 91 a7 b3 e7 4d 93 89 81 06 13 83 37 4a 1d 79 47 1a 2d 2d // fe} (length 0x40) lo_enc_key: buffer: {04 10 b1 61 7b 62 17 91 7d 72 // 32 2c 0c 5a a9 26 36 26 c0 24 00 10 f9 db 74 16 1c cf f2 c5 cf 5e} // (length 0x20) lo_init: array[intptr] { // intptr = 0x3 (8 bytes) // intptr = 0x800 (8 bytes) // } // reserved: const = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // } // } // ] *(uint32_t*)0x200000000300 = 0; *(uint16_t*)0x200000000308 = 0; *(uint64_t*)0x200000000310 = 0; *(uint16_t*)0x200000000318 = 0; *(uint32_t*)0x200000000320 = 0x20007; *(uint32_t*)0x200000000324 = 0; *(uint32_t*)0x200000000328 = 0x200000; *(uint32_t*)0x20000000032c = 0xd; memcpy((void*)0x200000000330, "\x22\x53\x6a\xf3\x9b\x7c\x7c\xb7\x43\x5b\x0a\xbd\x07\x2d\xbc\x3a\x9a" "\xda\x34\xcc\x97\xaf\x10\xfd\x4f\xcc\xa1\x57\x48\x32\x8c\x53\x09\xc3" "\x9f\xb6\x98\x9b\xa7\x43\xd3\x0b\x59\xc4\x91\xa7\xb3\xe7\x4d\x93\x89" "\x81\x06\x13\x83\x37\x4a\x1d\x79\x47\x1a\x2d\x2d\xfe", 64); memcpy((void*)0x200000000370, "\x04\x10\xb1\x61\x7b\x62\x17\x91\x7d\x72\x32\x2c\x0c\x5a\xa9\x26\x36" "\x26\xc0\x24\x00\x10\xf9\xdb\x74\x16\x1c\xcf\xf2\xc5\xcf\x5e", 32); *(uint64_t*)0x200000000390 = 3; *(uint64_t*)0x200000000398 = 0x800; *(uint32_t*)0x2000000003a0 = 0; syscall(__NR_ioctl, /*fd=*/r[0], /*cmd=*/0x4c02, /*arg=*/0x200000000300ul); // openat arguments: [ // fd: fd_dir (resource) // file: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 31 00} (length 0x8) // } // flags: open_flags = 0x42 (4 bytes) // mode: open_mode = 0x0 (2 bytes) // ] // returns fd memcpy((void*)0x200000000040, "./file1\000", 8); syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x200000000040ul, /*flags=O_CREAT|O_RDWR*/ 0x42, /*mode=*/0); // creat arguments: [ // file: nil // mode: open_mode = 0x0 (8 bytes) // ] // returns fd syscall(__NR_creat, /*file=*/0ul, /*mode=*/0ul); // syz_open_dev$usbfs arguments: [ // dev: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 62 75 73 2f 75 73 62 2f 30 30 23 2f 30 30 23 // 00} (length 0x15) // } // id: intptr = 0x1ff (8 bytes) // flags: open_flags = 0xa401 (8 bytes) // ] // returns fd_usbfs memcpy((void*)0x200000003f00, "/dev/bus/usb/00#/00#\000", 21); syz_open_dev(/*dev=*/0x200000003f00, /*id=*/0x1ff, /*flags=O_LARGEFILE|FASYNC|O_APPEND|O_WRONLY*/ 0xa401); } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); const char* reason; (void)reason; if ((reason = setup_binfmt_misc())) printf("the reproducer may not work as expected: binfmt_misc setup failed: " "%s\n", reason); if ((reason = setup_swap())) printf("the reproducer may not work as expected: swap setup failed: %s\n", reason); do_sandbox_none(); return 0; }