// https://syzkaller.appspot.com/bug?id=c5fa40d992b334ea85a59ec78b859306e921a3d0 // 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 #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 bool write_file(const char* file, const char* what, ...) { char buf[1024]; va_list args; va_start(args, what); vsnprintf(buf, sizeof(buf), what, args); va_end(args); buf[sizeof(buf) - 1] = 0; int len = strlen(buf); int fd = open(file, O_WRONLY | O_CLOEXEC); if (fd == -1) return false; if (write(fd, buf, len) != len) { int err = errno; close(fd); errno = err; return false; } close(fd); return true; } struct nlmsg { char* pos; int nesting; struct nlattr* nested[8]; char buf[4096]; }; static void netlink_init(struct nlmsg* nlmsg, int typ, int flags, const void* data, int size) { memset(nlmsg, 0, sizeof(*nlmsg)); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf; hdr->nlmsg_type = typ; hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | flags; memcpy(hdr + 1, data, size); nlmsg->pos = (char*)(hdr + 1) + NLMSG_ALIGN(size); } static void netlink_attr(struct nlmsg* nlmsg, int typ, const void* data, int size) { struct nlattr* attr = (struct nlattr*)nlmsg->pos; attr->nla_len = sizeof(*attr) + size; attr->nla_type = typ; if (size > 0) memcpy(attr + 1, data, size); nlmsg->pos += NLMSG_ALIGN(attr->nla_len); } static void netlink_nest(struct nlmsg* nlmsg, int typ) { struct nlattr* attr = (struct nlattr*)nlmsg->pos; attr->nla_type = typ; nlmsg->pos += sizeof(*attr); nlmsg->nested[nlmsg->nesting++] = attr; } static void netlink_done(struct nlmsg* nlmsg) { struct nlattr* attr = nlmsg->nested[--nlmsg->nesting]; attr->nla_len = nlmsg->pos - (char*)attr; } static int netlink_send_ext(struct nlmsg* nlmsg, int sock, uint16_t reply_type, int* reply_len, bool dofail) { if (nlmsg->pos > nlmsg->buf + sizeof(nlmsg->buf) || nlmsg->nesting) exit(1); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf; hdr->nlmsg_len = nlmsg->pos - nlmsg->buf; struct sockaddr_nl addr; memset(&addr, 0, sizeof(addr)); addr.nl_family = AF_NETLINK; ssize_t n = sendto(sock, nlmsg->buf, hdr->nlmsg_len, 0, (struct sockaddr*)&addr, sizeof(addr)); if (n != (ssize_t)hdr->nlmsg_len) { if (dofail) exit(1); return -1; } n = recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0); if (reply_len) *reply_len = 0; if (n < 0) { if (dofail) exit(1); return -1; } if (n < (ssize_t)sizeof(struct nlmsghdr)) { errno = EINVAL; if (dofail) exit(1); return -1; } if (hdr->nlmsg_type == NLMSG_DONE) return 0; if (reply_len && hdr->nlmsg_type == reply_type) { *reply_len = n; return 0; } if (n < (ssize_t)(sizeof(struct nlmsghdr) + sizeof(struct nlmsgerr))) { errno = EINVAL; if (dofail) exit(1); return -1; } if (hdr->nlmsg_type != NLMSG_ERROR) { errno = EINVAL; if (dofail) exit(1); return -1; } errno = -((struct nlmsgerr*)(hdr + 1))->error; return -errno; } static int netlink_send(struct nlmsg* nlmsg, int sock) { return netlink_send_ext(nlmsg, sock, 0, NULL, true); } static int netlink_query_family_id(struct nlmsg* nlmsg, int sock, const char* family_name, bool dofail) { struct genlmsghdr genlhdr; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = CTRL_CMD_GETFAMILY; netlink_init(nlmsg, GENL_ID_CTRL, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(nlmsg, CTRL_ATTR_FAMILY_NAME, family_name, strnlen(family_name, GENL_NAMSIZ - 1) + 1); int n = 0; int err = netlink_send_ext(nlmsg, sock, GENL_ID_CTRL, &n, dofail); if (err < 0) { return -1; } uint16_t id = 0; struct nlattr* attr = (struct nlattr*)(nlmsg->buf + NLMSG_HDRLEN + NLMSG_ALIGN(sizeof(genlhdr))); for (; (char*)attr < nlmsg->buf + n; attr = (struct nlattr*)((char*)attr + NLMSG_ALIGN(attr->nla_len))) { if (attr->nla_type == CTRL_ATTR_FAMILY_ID) { id = *(uint16_t*)(attr + 1); break; } } if (!id) { errno = EINVAL; return -1; } recv(sock, nlmsg->buf, sizeof(nlmsg->buf), 0); return id; } static unsigned int queue_count = 2; static void netlink_add_device_impl(struct nlmsg* nlmsg, const char* type, const char* name, bool up) { struct ifinfomsg hdr; memset(&hdr, 0, sizeof(hdr)); if (up) hdr.ifi_flags = hdr.ifi_change = IFF_UP; netlink_init(nlmsg, RTM_NEWLINK, NLM_F_EXCL | NLM_F_CREATE, &hdr, sizeof(hdr)); if (name) netlink_attr(nlmsg, IFLA_IFNAME, name, strlen(name)); netlink_attr(nlmsg, IFLA_NUM_TX_QUEUES, &queue_count, sizeof(queue_count)); netlink_attr(nlmsg, IFLA_NUM_RX_QUEUES, &queue_count, sizeof(queue_count)); netlink_nest(nlmsg, IFLA_LINKINFO); netlink_attr(nlmsg, IFLA_INFO_KIND, type, strlen(type)); } 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 struct nlmsg nlmsg; //% 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; } #define FS_IOC_SETFLAGS _IOW('f', 2, long) static void remove_dir(const char* dir) { int iter = 0; DIR* dp = 0; const int umount_flags = MNT_FORCE | UMOUNT_NOFOLLOW; retry: while (umount2(dir, umount_flags) == 0) { } dp = opendir(dir); if (dp == NULL) { if (errno == EMFILE) { exit(1); } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); while (umount2(filename, umount_flags) == 0) { } struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } int i; for (i = 0;; i++) { if (unlink(filename) == 0) break; if (errno == EPERM) { int fd = open(filename, O_RDONLY); if (fd != -1) { long flags = 0; if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) { } close(fd); continue; } } if (errno == EROFS) { break; } if (errno != EBUSY || i > 100) exit(1); if (umount2(filename, umount_flags)) exit(1); } } closedir(dp); for (int i = 0;; i++) { if (rmdir(dir) == 0) break; if (i < 100) { if (errno == EPERM) { int fd = open(dir, O_RDONLY); if (fd != -1) { long flags = 0; if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) { } close(fd); continue; } } if (errno == EROFS) { break; } if (errno == EBUSY) { if (umount2(dir, umount_flags)) exit(1); continue; } if (errno == ENOTEMPTY) { if (iter < 100) { iter++; goto retry; } } } exit(1); } } static void kill_and_wait(int pid, int* status) { kill(-pid, SIGKILL); kill(pid, SIGKILL); for (int i = 0; i < 100; i++) { if (waitpid(-1, status, WNOHANG | __WALL) == pid) return; usleep(1000); } DIR* dir = opendir("/sys/fs/fuse/connections"); if (dir) { for (;;) { struct dirent* ent = readdir(dir); if (!ent) break; if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) continue; char abort[300]; snprintf(abort, sizeof(abort), "/sys/fs/fuse/connections/%s/abort", ent->d_name); int fd = open(abort, O_WRONLY); if (fd == -1) { continue; } if (write(fd, abort, 1) < 0) { } close(fd); } closedir(dir); } else { } while (waitpid(-1, status, __WALL) != pid) { } } static void 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 setup_sysctl() { int cad_pid = fork(); if (cad_pid < 0) exit(1); if (cad_pid == 0) { for (;;) sleep(100); } char tmppid[32]; snprintf(tmppid, sizeof(tmppid), "%d", cad_pid); struct { const char* name; const char* data; } files[] = { {"/sys/kernel/debug/x86/nmi_longest_ns", "10000000000"}, {"/proc/sys/kernel/hung_task_check_interval_secs", "20"}, {"/proc/sys/net/core/bpf_jit_kallsyms", "1"}, {"/proc/sys/net/core/bpf_jit_harden", "0"}, {"/proc/sys/kernel/kptr_restrict", "0"}, {"/proc/sys/kernel/softlockup_all_cpu_backtrace", "1"}, {"/proc/sys/fs/mount-max", "100"}, {"/proc/sys/vm/oom_dump_tasks", "0"}, {"/proc/sys/debug/exception-trace", "0"}, {"/proc/sys/kernel/printk", "7 4 1 3"}, {"/proc/sys/kernel/keys/gc_delay", "1"}, {"/proc/sys/vm/oom_kill_allocating_task", "1"}, {"/proc/sys/kernel/ctrl-alt-del", "0"}, {"/proc/sys/kernel/cad_pid", tmppid}, }; for (size_t i = 0; i < sizeof(files) / sizeof(files[0]); i++) { if (!write_file(files[i].name, files[i].data)) { } } kill(cad_pid, SIGKILL); while (waitpid(cad_pid, NULL, 0) != cad_pid) ; } #define NL802154_CMD_SET_SHORT_ADDR 11 #define NL802154_ATTR_IFINDEX 3 #define NL802154_ATTR_SHORT_ADDR 10 static const char* setup_802154() { const char* error = NULL; int sock_generic = -1; int sock_route = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock_route == -1) { error = "socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE) failed"; goto fail; } sock_generic = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC); if (sock_generic == -1) { error = "socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC) failed"; goto fail; } { int nl802154_family_id = netlink_query_family_id(&nlmsg, sock_generic, "nl802154", true); if (nl802154_family_id < 0) { error = "netlink_query_family_id failed"; goto fail; } for (int i = 0; i < 2; i++) { char devname[] = "wpan0"; devname[strlen(devname) - 1] += i; uint64_t hwaddr = 0xaaaaaaaaaaaa0002 + (i << 8); uint16_t shortaddr = 0xaaa0 + i; int ifindex = if_nametoindex(devname); struct genlmsghdr genlhdr; memset(&genlhdr, 0, sizeof(genlhdr)); genlhdr.cmd = NL802154_CMD_SET_SHORT_ADDR; netlink_init(&nlmsg, nl802154_family_id, 0, &genlhdr, sizeof(genlhdr)); netlink_attr(&nlmsg, NL802154_ATTR_IFINDEX, &ifindex, sizeof(ifindex)); netlink_attr(&nlmsg, NL802154_ATTR_SHORT_ADDR, &shortaddr, sizeof(shortaddr)); if (netlink_send(&nlmsg, sock_generic) < 0) { error = "NL802154_CMD_SET_SHORT_ADDR failed"; goto fail; } netlink_device_change(&nlmsg, sock_route, devname, true, 0, &hwaddr, sizeof(hwaddr), 0); if (i == 0) { netlink_add_device_impl(&nlmsg, "lowpan", "lowpan0", false); netlink_done(&nlmsg); netlink_attr(&nlmsg, IFLA_LINK, &ifindex, sizeof(ifindex)); if (netlink_send(&nlmsg, sock_route) < 0) { error = "netlink: adding device lowpan0 type lowpan link wpan0"; goto fail; } } } } fail: close(sock_route); close(sock_generic); return error; } 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 (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[1] = {0xffffffffffffffff}; void execute_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 00} (length 0x8) // } // flags: mount_flags = 0x800700 (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 { // data_err_ignore: buffer: {64 61 74 61 5f 65 72 72 3d 69 67 6e // 6f 72 65} (length 0xf) // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[ext4_options] { // elem: union ext4_options { // dioread_nolock: buffer: {64 69 6f 72 65 61 64 5f 6e 6f 6c 6f // 63 6b} (length 0xe) // } // 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 = 0x5a (18 bytes) // } // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[ext4_options] { // elem: union ext4_options { // errors_remount: buffer: {65 72 72 6f 72 73 3d 72 65 6d 6f 75 // 6e 74 2d 72 6f} (length 0x11) // } // 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 = // 0x10000005 (18 bytes) // } // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[ext4_options] { // elem: union ext4_options { // nolazytime: buffer: {6e 6f 6c 61 7a 79 74 69 6d 65} (length // 0xa) // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[ext4_options] { // elem: union ext4_options { // nobh: buffer: {6e 6f 62 68} (length 0x4) // } // comma: const = 0x2c (1 bytes) // } // } // common: array[fs_opt_elem[fs_options_common]] { // } // null: const = 0x0 (1 bytes) // } // } // chdir: int8 = 0x1 (1 bytes) // size: len = 0x46f (8 bytes) // img: ptr[in, buffer] { // buffer: (compressed buffer with length 0x46f) // } // ] // returns fd_dir NONFAILING(memcpy((void*)0x200000000180, "ext4\000", 5)); NONFAILING(memcpy((void*)0x200000000000, "./file0\000", 8)); NONFAILING(memcpy((void*)0x200000000040, "data_err=ignore", 15)); NONFAILING(*(uint8_t*)0x20000000004f = 0x2c); NONFAILING(memcpy((void*)0x200000000050, "dioread_nolock", 14)); NONFAILING(*(uint8_t*)0x20000000005e = 0x2c); NONFAILING(memcpy((void*)0x20000000005f, "debug_want_extra_isize", 22)); NONFAILING(*(uint8_t*)0x200000000075 = 0x3d); NONFAILING(sprintf((char*)0x200000000076, "0x%016llx", (long long)0x5a)); NONFAILING(*(uint8_t*)0x200000000088 = 0x2c); NONFAILING(memcpy((void*)0x200000000089, "errors=remount-ro", 17)); NONFAILING(*(uint8_t*)0x20000000009a = 0x2c); NONFAILING(memcpy((void*)0x20000000009b, "max_dir_size_kb", 15)); NONFAILING(*(uint8_t*)0x2000000000aa = 0x3d); NONFAILING( sprintf((char*)0x2000000000ab, "0x%016llx", (long long)0x10000005)); NONFAILING(*(uint8_t*)0x2000000000bd = 0x2c); NONFAILING(memcpy((void*)0x2000000000be, "nolazytime", 10)); NONFAILING(*(uint8_t*)0x2000000000c8 = 0x2c); NONFAILING(memcpy((void*)0x2000000000c9, "nobh", 4)); NONFAILING(*(uint8_t*)0x2000000000cd = 0x2c); NONFAILING(*(uint8_t*)0x2000000000ce = 0); NONFAILING(memcpy( (void*)0x200000000bc0, "\x78\x9c\xec\xdb\xcd\x6b\x1c\xe5\x1f\x00\xf0\xef\x4c\x5e\xda\xfe\xfa\x92" "\xfc\x6a\x7d\x69\xad\x1a\x2d\x42\x50\x4c\x9a\xb4\x6a\x0f\x5e\x14\x05\x91" "\x8a\x82\x1e\xea\x31\x26\xdb\x12\xba\x6d\xa4\x89\x62\x6b\xb1\xa9\x88\x27" "\x41\x0a\x7a\x16\x8f\xa2\x7f\x81\x37\x11\x44\x3d\x09\x5e\x3d\x79\x92\x42" "\xd1\x5e\xda\x7a\x8a\xcc\xec\x4c\xbb\xd9\x66\x13\x63\x36\x9d\x98\xfd\x7c" "\x60\x76\x9f\x67\xe6\xd9\x9d\xe7\xbb\xcf\xbc\x3c\xfb\x3c\xbb\x01\x74\xad" "\xa1\xec\x21\x89\xd8\x11\x11\xbf\x46\xc4\x40\x23\xbb\xb8\xc0\x50\xe3\xe9" "\xfa\xd5\xf3\x93\x37\xae\x9e\x9f\x4c\x62\x61\xe1\xb5\x3f\x92\xbc\xdc\xb5" "\xab\xe7\x27\xcb\xa2\xe5\xeb\xb6\x17\x99\xe1\x34\x22\xfd\x30\x29\x76\xb2" "\xd8\xec\xd9\x73\x27\x27\xea\xf5\xda\x99\x22\x3f\x3a\x77\xea\xad\xd1\xd9" "\xb3\xe7\x9e\x78\xe7\xd4\xc4\x89\xda\x89\xda\xe9\xf1\x23\x47\x0e\x1f\x1a" "\x7b\xfa\xa9\xf1\x27\x3b\x12\x67\x16\xd7\xb5\x7d\xef\xcf\xec\xdf\xfb\xe2" "\x1b\x97\x5e\x9e\x3c\x76\xe9\xcd\x1f\xbf\xce\xea\xbb\xa3\xd8\xde\x1c\x47" "\xa7\x0c\x65\x81\xff\xb9\x90\x6b\xdd\xf6\x68\xa7\x77\x56\xb1\x9d\x4d\xe9" "\xa4\xb7\xc2\x8a\xb0\x2a\x3d\x11\x91\x35\x57\x5f\x7e\xfe\x0f\x44\x4f\xdc" "\x6a\xbc\x81\x78\xe1\x83\x4a\x2b\x07\xac\xab\xec\xde\xb4\xa5\xfd\xe6\xf9" "\x05\x60\x13\x4b\xa2\xea\x1a\x00\xd5\x28\x6f\xf4\xd9\xf7\xdf\x72\xb9\x43" "\x5d\x8f\x0d\xe1\xca\xb3\x8d\x2f\x40\x59\xdc\xd7\x8b\xa5\xb1\xa5\x37\xd2" "\xa2\x4c\x5f\xcb\xf7\xdb\x4e\x1a\x8a\x88\x63\xf3\x7f\x7d\x9e\x2d\xb1\x4e" "\xe3\x10\x00\x00\xcd\x3e\x9e\xfc\xec\x68\x7f\x44\xbc\x77\xe3\xab\x97\xb2" "\xbe\xc7\x40\x44\x94\xe3\x41\xf7\xe4\x8f\xbf\xe5\x8f\xbb\x8a\x39\x94\xc1" "\x88\xf8\x7f\x44\xec\x8e\x88\xbb\x22\x62\x4f\x44\xdc\x5d\x94\xbd\x37\x22" "\xee\x5b\x63\x7d\x6e\xef\xff\xa4\x97\xd7\xf8\x96\xcb\xca\xfa\x7f\xcf\x14" "\x73\x5b\x8b\xfb\x7f\x65\xef\x2f\x06\x7b\x8a\xdc\xce\x3c\xfe\xbe\xe4\xf8" "\x74\xbd\x76\xb0\xf8\x4c\x86\xa3\x6f\x4b\x96\x1f\x5b\x66\x1f\xdf\x3e\xff" "\xcb\x27\xed\xb6\x35\xf7\xff\xb2\x25\xdb\x7f\xd9\x17\x2c\xea\x71\xb9\xb7" "\x65\x80\x6e\x6a\x62\x6e\x22\xef\x94\x76\xc0\x95\x8b\x11\xfb\x7a\x97\x8a" "\x3f\xb9\x39\x13\x90\x44\xc4\xde\x88\xd8\xb7\xba\xb7\xde\x55\x26\xa6\x1f" "\xfb\x72\x7f\xbb\x42\x2b\xc7\xbf\x8c\x0e\xcc\x33\x2d\x7c\x91\x85\x37\x9f" "\xc5\x3f\x1f\x2d\xf1\x97\x92\xe6\xf9\xc9\xe9\xdb\xe6\x27\x47\xb7\x46\xbd" "\x76\x70\xb4\x3c\x2a\x6e\xf7\xd3\xcf\x1f\xbd\xda\x6e\xff\x6b\x8a\xbf\x03" "\xae\xd4\x1a\xcf\x4d\xed\xdf\x5a\x64\x30\x69\x9e\xaf\x9d\xed\xec\xfe\xff" "\xe5\xf1\x9f\xf6\x27\xaf\xe7\xf3\xcc\xfd\xc5\xba\x77\x27\xe6\xe6\xce\x8c" "\x45\xf4\x27\x47\xf3\xfc\xa2\xf5\xe3\xb7\x5e\x5b\xe6\xcb\xf2\xd9\xf1\x3f" "\x7c\x60\xe9\xf3\x7f\x77\xf1\x9a\x2c\xfe\xfb\x23\x22\x3b\x88\x1f\x88\x88" "\x07\x23\xe2\xa1\xa2\xee\x0f\x47\xc4\x23\x11\x71\x60\x99\x18\x7f\x78\x6e" "\xe5\xf8\x23\xad\xa8\xfd\x2f\x46\x4c\x2d\x79\xfd\xbb\x79\xfc\xb7\xb4\xff" "\xea\x13\x3d\x27\xbf\xff\xa6\xdd\xfe\xff\x59\xfb\x1f\xce\x53\xc3\xc5\x9a" "\xfc\xfa\xb7\x82\xa5\xaa\x93\x5d\x2e\x5a\x2b\xb8\x96\xcf\x0e\x00\x00\x00" "\xfe\x2b\xd2\xfc\x37\xf0\x49\x3a\x72\x33\x9d\xa6\x23\x23\x8d\xdf\xf0\xef" "\x89\xff\xa5\xf5\x99\xd9\xb9\xc7\x8f\xcf\xbc\x7d\x7a\xaa\xf1\x5b\xf9\xc1" "\xe8\x4b\xcb\x91\xae\x81\x62\x3c\xb4\x3e\x5d\xaf\x8d\x25\xf3\xc5\x3b\x36" "\xc6\x47\xc7\x8b\xb1\xe2\x72\xbc\xf4\x50\x31\x6e\xfc\x69\xcf\xb6\x3c\x3f" "\x32\x39\x53\x9f\xaa\x38\x76\xe8\x76\xdb\xdb\x9c\xff\x99\xdf\x7b\xaa\xae" "\x1d\xb0\xce\xb6\x2d\xb9\x76\xbc\xff\x8e\x57\x04\xa8\x40\xeb\x3c\x7a\xba" "\x38\x7b\xe1\x95\x70\x31\x80\xcd\xca\xff\xb5\xa1\x7b\xad\x70\xfe\x37\xff" "\x0f\x06\xd8\x64\xdc\xff\xa1\x7b\x2d\x75\xfe\x5f\x68\xc9\x9b\x0b\x80\xcd" "\xc9\xfd\x1f\xba\x97\xf3\x1f\xba\x54\xfa\x5d\xd5\x35\x00\x2a\xe4\xfe\x0f" "\x5d\x69\x2d\xff\xeb\x5f\xc7\xc4\xd6\x8d\x51\x8d\x6a\x12\x1b\xb5\x51\xf2" "\x44\x44\x99\x48\x37\x44\x7d\x24\xd6\x29\x51\xf5\x95\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\xa0\x33\xfe\x0e\x00\x00\xff\xff\x2b\x62\xe6" "\x8b", 1135)); NONFAILING(syz_mount_image(/*fs=*/0x200000000180, /*dir=*/0x200000000000, /*flags=MS_I_VERSION|MS_NOATIME|0x300*/ 0x800700, /*opts=*/0x200000000040, /*chdir=*/1, /*size=*/0x46f, /*img=*/0x200000000bc0)); // 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 31 00} (length 0x8) // } // flags: mount_flags = 0x2000000 (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 = 0x11 (1 bytes) // size: len = 0x56b (8 bytes) // img: ptr[in, buffer] { // buffer: (compressed buffer with length 0x56b) // } // ] // returns fd_dir NONFAILING(memcpy((void*)0x200000000140, "ext4\000", 5)); NONFAILING(memcpy((void*)0x2000000001c0, "./file1\000", 8)); NONFAILING(*(uint8_t*)0x2000000009c0 = 0); NONFAILING(memcpy( (void*)0x200000000440, "\x78\x9c\xec\xdd\xcd\x6b\x1c\xe5\x1f\x00\xf0\xef\x6c\x36\xe9\xeb\xef\xd7" "\x14\x4a\x51\x11\x09\xf4\x60\xa5\x76\xd3\x24\xbe\x54\xf0\x50\x8f\xa2\xc5" "\x82\xde\xeb\x92\x4c\x43\xc9\xa6\x5b\xb2\x9b\xd2\xc4\x82\xed\xc1\x5e\xbc" "\x48\x11\x44\x2c\x88\x07\x6f\x7a\xf7\x58\xfc\x07\xbc\xf8\x2f\x14\xb4\x50" "\xa4\x04\x3d\x78\x89\xcc\x66\x36\xcd\xcb\x6e\xb2\x6d\x36\x2f\xed\x7e\x3e" "\x30\xe1\x79\x76\x66\xf7\x99\xef\xcc\x7c\x9f\x3c\xb3\xcf\x2e\x1b\x40\xcf" "\x1a\xca\xfe\x14\x22\x5e\x8c\x88\xaf\x92\x88\x23\x11\x91\xe4\xeb\x8a\x91" "\xaf\x1c\x5a\xda\x6e\xe1\xd1\x8d\xf1\x6c\x49\x62\x71\xf1\xe3\xbf\x92\xc6" "\x76\x59\xbd\xf9\x5a\xcd\xe7\x1d\xca\x2b\x2f\x44\xc4\xaf\x5f\x44\x9c\x2a" "\xac\x6f\xb7\x36\x37\x3f\x55\xae\x54\xd2\x99\xbc\x3e\x5c\x9f\xbe\x3a\x5c" "\x9b\x9b\x3f\x7d\x79\xba\x3c\x99\x4e\xa6\x57\x46\xc7\xc6\xce\xbe\x39\x36" "\xfa\xce\xdb\x6f\x75\x2d\xd6\xd7\x2e\xfc\xf3\xed\x47\xf7\xde\x3f\xfb\xe5" "\x89\x85\x6f\x7e\x7e\x70\xf4\x4e\x12\xe7\xe2\x70\xbe\x6e\x65\x1c\x5b\x70" "\x73\x65\x65\x28\x86\xf2\x63\xd2\x1f\xe7\xd6\x6c\x38\xd2\x85\xc6\xf6\x92" "\x64\xb7\x77\x80\xa7\xd2\x97\xe7\x79\x7f\x64\x7d\xc0\x91\xe8\xcb\xb3\xbe" "\x95\x1f\x0f\xec\xe8\xae\x01\xdb\xec\xf3\x88\x58\x04\x7a\x54\x22\xff\xa1" "\x47\x35\xc7\x01\xcd\x7b\xfb\x2e\xdd\x07\x3f\x33\x1e\xbe\xb7\x74\x03\xb4" "\x3e\xfe\xe2\xd2\x7b\x23\xb1\xbf\x71\x6f\x74\x70\x21\x59\x75\x67\x94\xdd" "\xef\x0e\x76\xa1\xfd\xac\x8d\x5f\xfe\xbc\x7b\x27\x5b\xa2\x7b\xef\x43\x00" "\x6c\xea\xe6\xad\x88\x38\x53\x2c\xae\xef\xff\x92\xbc\xff\x7b\x7a\x67\x3a" "\xd8\x66\x6d\x1b\xfa\x3f\xd8\x39\xf7\xb2\xf1\xcf\xeb\xeb\xc6\x3f\x03\xb1" "\x9c\x9b\xfb\x1b\x7f\xd7\x8e\x7f\x0e\xb5\xc8\xdd\xa7\xb1\x79\xfe\x17\x1e" "\x74\xa1\x99\xb6\xb2\xf1\xdf\xbb\x2d\xc7\xbf\xcb\x93\x56\x83\x7d\x79\xed" "\x7f\x8d\x31\x5f\x7f\x72\xe9\x72\x25\xcd\xfa\xb6\xff\x47\xc4\xc9\xe8\xdf" "\x97\xd5\x37\x9a\xcf\x39\xbb\x70\x7f\xb1\xdd\xba\x95\xe3\xbf\x6c\xc9\xda" "\x6f\x8e\x05\xf3\xfd\x78\x50\xdc\xb7\xfa\x39\x13\xe5\x7a\x79\x2b\x31\xaf" "\xf4\xf0\x56\xc4\x4b\x2d\xc7\xbf\xc9\xf2\xf9\x4f\x5a\x9c\xff\xec\x78\x5c" "\xe8\xb0\x8d\xe3\xe9\xdd\x57\xda\xad\xdb\x3c\xfe\xed\xb5\xf8\x43\xc4\xab" "\x2d\xcf\xff\xe3\x19\xad\x64\xe3\xf9\xc9\xe1\xc6\xf5\x30\xdc\xbc\x2a\xd6" "\xfb\xfb\xf6\xf1\xdf\xda\xb5\xbf\xdb\xf1\x67\xe7\xff\xe0\xc6\xf1\x0f\x26" "\x2b\xe7\x6b\x6b\x4f\xde\xc6\xf7\xfb\xff\x4d\xdb\xad\x5b\x15\x7f\x74\x7e" "\xfd\x0f\x24\x9f\x34\xca\x03\xf9\x63\xd7\xcb\xf5\xfa\xcc\x48\xc4\x40\xf2" "\xe1\xfa\xc7\x47\x1f\x3f\xb7\x59\x6f\x6e\x9f\xc5\x7f\xf2\x44\xeb\xfc\xdf" "\xe8\xfa\x3f\x10\x11\x9f\x76\x18\xff\xed\x63\x3f\xbd\xdc\x51\xfc\xbb\x74" "\xfe\x27\x9e\xe8\xfc\x3f\x79\xe1\xfe\x07\x9f\x7d\xd7\xae\xfd\xce\xfa\xbf" "\x37\x1a\xa5\x93\xf9\x23\x9d\xf4\x7f\x9d\xee\xe0\x56\x8e\x1d\x00\x00\x00" "\x00\x00\x00\xec\x35\x85\x88\x38\x1c\x49\xa1\xb4\x5c\x2e\x14\x4a\xa5\xa5" "\xcf\x77\x1c\x8b\x83\x85\x4a\xb5\x56\x3f\x75\xa9\x3a\x7b\x65\x22\x1a\xdf" "\x95\x1d\x8c\xfe\x42\x73\xa6\xfb\xc8\x8a\xcf\x43\x8c\xe4\x9f\x87\x6d\xd6" "\x47\xd7\xd4\xc7\x22\xe2\x68\x44\x7c\xdd\x77\xa0\x51\x2f\x8d\x57\x2b\x13" "\xbb\x1d\x3c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\xec\x11\x87\xda\x7c\xff\x3f\xf3\x47\xdf\x6e\xef\x1d\xb0\xed\xda\xff\xe4" "\x37\xf0\xbc\xdb\x34\xff\xbb\xf1\x4b\x4f\xc0\x9e\xe4\xff\x3f\xf4\x2e\xf9" "\x0f\xbd\x4b\xfe\x43\xef\x92\xff\xd0\xbb\xe4\x3f\xf4\x2e\xf9\x0f\xbd\x4b" "\xfe\x43\xef\x92\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\xd0\x55\x17\xce\x9f\xcf\x96\xc5\x85\x47" "\x37\xc6\xb3\xfa\xc4\xb5\xb9\xd9\xa9\xea\xb5\xd3\x13\x69\x6d\xaa\x34\x3d" "\x3b\x5e\x1a\xaf\xce\x5c\x2d\x4d\x56\xab\x93\x95\xb4\x34\x5e\x9d\xde\xec" "\xf5\x2a\xd5\xea\xd5\x91\xd1\x98\xbd\x3e\x5c\x4f\x6b\xf5\xe1\xda\xdc\xfc" "\xc5\xe9\xea\xec\x95\xfa\xc5\xcb\xd3\xe5\xc9\xf4\x62\xda\xbf\x23\x51\x01" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xb3\xa5\x36" "\x37\x3f\x55\xae\x54\xd2\x19\x85\xe7\xb3\xf0\xfb\x76\x37\x51\xdc\xea\xeb" "\x14\x23\x62\x0f\x1c\x28\x85\xd5\x85\xdd\xee\x99\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\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\xb1\xff\x02\x00\x00\xff\xff\xb0\x87\x37" "\x3c", 1387)); NONFAILING(syz_mount_image(/*fs=*/0x200000000140, /*dir=*/0x2000000001c0, /*flags=MS_LAZYTIME*/ 0x2000000, /*opts=*/0x2000000009c0, /*chdir=*/0x11, /*size=*/0x56b, /*img=*/0x200000000440)); // openat arguments: [ // fd: fd_dir (resource) // file: nil // flags: open_flags = 0x181242 (4 bytes) // mode: open_mode = 0x148 (2 bytes) // ] // returns fd res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0ul, /*flags=O_TRUNC|O_SYNC|O_CREAT|O_CLOEXEC|O_RDWR*/ 0x181242, /*mode=S_IXGRP|S_IXUSR|S_IRUSR*/ 0x148); if (res != -1) r[0] = res; // pwrite64 arguments: [ // fd: fd (resource) // buf: ptr[in, buffer] { // buffer: {a6} (length 0x1) // } // count: len = 0x1 (8 bytes) // pos: intptr = 0xfecc (8 bytes) // ] NONFAILING(memset((void*)0x200000000100, 166, 1)); syscall(__NR_pwrite64, /*fd=*/r[0], /*buf=*/0x200000000100ul, /*count=*/1ul, /*pos=*/0xfeccul); } 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); setup_sysctl(); const char* reason; (void)reason; if ((reason = setup_802154())) printf("the reproducer may not work as expected: 802154 injection setup " "failed: %s\n", reason); install_segv_handler(); for (procid = 0; procid < 5; procid++) { if (fork() == 0) { use_temporary_dir(); loop(); } } sleep(1000000); return 0; }