// https://syzkaller.appspot.com/bug?id=630b9997291d3cc623b7a582d2a7f249f6e8b3c2 // 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 #ifndef __NR_bpf #define __NR_bpf 321 #endif #ifndef __NR_memfd_create #define __NR_memfd_create 319 #endif static unsigned long long procid; static __thread int clone_ongoing; static __thread int skip_segv; static __thread jmp_buf segv_env; static void segv_handler(int sig, siginfo_t* info, void* ctx) { if (__atomic_load_n(&clone_ongoing, __ATOMIC_RELAXED) != 0) { exit(sig); } uintptr_t addr = (uintptr_t)info->si_addr; const uintptr_t prog_start = 1 << 20; const uintptr_t prog_end = 100 << 20; int skip = __atomic_load_n(&skip_segv, __ATOMIC_RELAXED) != 0; int valid = addr < prog_start || addr > prog_end; if (skip && valid) { _longjmp(segv_env, 1); } exit(sig); } static void install_segv_handler(void) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = SIG_IGN; syscall(SYS_rt_sigaction, 0x20, &sa, NULL, 8); syscall(SYS_rt_sigaction, 0x21, &sa, NULL, 8); memset(&sa, 0, sizeof(sa)); sa.sa_sigaction = segv_handler; sa.sa_flags = SA_NODEFER | SA_SIGINFO; sigaction(SIGSEGV, &sa, NULL); sigaction(SIGBUS, &sa, NULL); } #define NONFAILING(...) \ ({ \ int ok = 1; \ __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); \ if (_setjmp(segv_env) == 0) { \ __VA_ARGS__; \ } else \ ok = 0; \ __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); \ ok; \ }) static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { int state; } event_t; static void event_init(event_t* ev) { ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { if (ev->state) exit(1); __atomic_store_n(&ev->state, 1, __ATOMIC_RELEASE); syscall(SYS_futex, &ev->state, FUTEX_WAKE | FUTEX_PRIVATE_FLAG, 1000000); } static void event_wait(event_t* ev) { while (!__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, 0); } static int event_isset(event_t* ev) { return __atomic_load_n(&ev->state, __ATOMIC_ACQUIRE); } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; for (;;) { uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, &ts); if (__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) return 1; now = current_time_ms(); if (now - start > timeout) return 0; } } static bool write_file(const char* file, const char* what, ...) { char buf[1024]; va_list args; va_start(args, what); vsnprintf(buf, sizeof(buf), what, args); va_end(args); buf[sizeof(buf) - 1] = 0; int len = strlen(buf); int fd = open(file, O_WRONLY | O_CLOEXEC); if (fd == -1) return false; if (write(fd, buf, len) != len) { int err = errno; close(fd); errno = err; return false; } close(fd); return true; } struct nlmsg { char* pos; int nesting; struct nlattr* nested[8]; char buf[4096]; }; static void netlink_init(struct nlmsg* nlmsg, int typ, int flags, const void* data, int size) { memset(nlmsg, 0, sizeof(*nlmsg)); struct nlmsghdr* hdr = (struct nlmsghdr*)nlmsg->buf; hdr->nlmsg_type = typ; hdr->nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK | flags; memcpy(hdr + 1, data, size); nlmsg->pos = (char*)(hdr + 1) + NLMSG_ALIGN(size); } static void netlink_attr(struct nlmsg* nlmsg, int typ, const void* data, int size) { struct nlattr* attr = (struct nlattr*)nlmsg->pos; attr->nla_len = sizeof(*attr) + size; attr->nla_type = typ; if (size > 0) memcpy(attr + 1, data, size); nlmsg->pos += NLMSG_ALIGN(attr->nla_len); } static 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 void netlink_add_device_impl(struct nlmsg* nlmsg, const char* type, const char* name, bool up) { struct ifinfomsg hdr; memset(&hdr, 0, sizeof(hdr)); if (up) hdr.ifi_flags = hdr.ifi_change = IFF_UP; netlink_init(nlmsg, RTM_NEWLINK, NLM_F_EXCL | NLM_F_CREATE, &hdr, sizeof(hdr)); if (name) netlink_attr(nlmsg, IFLA_IFNAME, name, strlen(name)); netlink_nest(nlmsg, IFLA_LINKINFO); netlink_attr(nlmsg, IFLA_INFO_KIND, type, strlen(type)); } static void netlink_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; static long syz_genetlink_get_family_id(volatile long name, volatile long sock_arg) { int fd = sock_arg; if (fd < 0) { fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC); if (fd == -1) { return -1; } } struct nlmsg nlmsg_tmp; int ret = netlink_query_family_id(&nlmsg_tmp, fd, (char*)name, false); if ((int)sock_arg < 0) close(fd); if (ret < 0) { return -1; } return ret; } //% This code is derived from puff.{c,h}, found in the zlib development. The //% original files come with the following copyright notice: //% Copyright (C) 2002-2013 Mark Adler, all rights reserved //% version 2.3, 21 Jan 2013 //% This software is provided 'as-is', without any express or implied //% warranty. In no event will the author be held liable for any damages //% arising from the use of this software. //% Permission is granted to anyone to use this software for any purpose, //% including commercial applications, and to alter it and redistribute it //% freely, subject to the following restrictions: //% 1. The origin of this software must not be misrepresented; you must not //% claim that you wrote the original software. If you use this software //% in a product, an acknowledgment in the product documentation would be //% appreciated but is not required. //% 2. Altered source versions must be plainly marked as such, and must not be //% misrepresented as being the original software. //% 3. This notice may not be removed or altered from any source distribution. //% Mark Adler madler@alumni.caltech.edu //% BEGIN CODE DERIVED FROM puff.{c,h} #define MAXBITS 15 #define MAXLCODES 286 #define MAXDCODES 30 #define MAXCODES (MAXLCODES + MAXDCODES) #define FIXLCODES 288 struct puff_state { unsigned char* out; unsigned long outlen; unsigned long outcnt; const unsigned char* in; unsigned long inlen; unsigned long incnt; int bitbuf; int bitcnt; jmp_buf env; }; static int puff_bits(struct puff_state* s, int need) { long val = s->bitbuf; while (s->bitcnt < need) { if (s->incnt == s->inlen) longjmp(s->env, 1); val |= (long)(s->in[s->incnt++]) << s->bitcnt; s->bitcnt += 8; } s->bitbuf = (int)(val >> need); s->bitcnt -= need; return (int)(val & ((1L << need) - 1)); } static int puff_stored(struct puff_state* s) { s->bitbuf = 0; s->bitcnt = 0; if (s->incnt + 4 > s->inlen) return 2; unsigned len = s->in[s->incnt++]; len |= s->in[s->incnt++] << 8; if (s->in[s->incnt++] != (~len & 0xff) || s->in[s->incnt++] != ((~len >> 8) & 0xff)) return -2; if (s->incnt + len > s->inlen) return 2; if (s->outcnt + len > s->outlen) return 1; for (; len--; s->outcnt++, s->incnt++) { if (s->in[s->incnt]) s->out[s->outcnt] = s->in[s->incnt]; } return 0; } struct puff_huffman { short* count; short* symbol; }; static int puff_decode(struct puff_state* s, const struct puff_huffman* h) { int first = 0; int index = 0; int bitbuf = s->bitbuf; int left = s->bitcnt; int code = first = index = 0; int len = 1; short* next = h->count + 1; while (1) { while (left--) { code |= bitbuf & 1; bitbuf >>= 1; int count = *next++; if (code - count < first) { s->bitbuf = bitbuf; s->bitcnt = (s->bitcnt - len) & 7; return h->symbol[index + (code - first)]; } index += count; first += count; first <<= 1; code <<= 1; len++; } left = (MAXBITS + 1) - len; if (left == 0) break; if (s->incnt == s->inlen) longjmp(s->env, 1); bitbuf = s->in[s->incnt++]; if (left > 8) left = 8; } return -10; } static int puff_construct(struct puff_huffman* h, const short* length, int n) { int len; for (len = 0; len <= MAXBITS; len++) h->count[len] = 0; int symbol; for (symbol = 0; symbol < n; symbol++) (h->count[length[symbol]])++; if (h->count[0] == n) return 0; int left = 1; for (len = 1; len <= MAXBITS; len++) { left <<= 1; left -= h->count[len]; if (left < 0) return left; } short offs[MAXBITS + 1]; offs[1] = 0; for (len = 1; len < MAXBITS; len++) offs[len + 1] = offs[len] + h->count[len]; for (symbol = 0; symbol < n; symbol++) if (length[symbol] != 0) h->symbol[offs[length[symbol]]++] = symbol; return left; } static int puff_codes(struct puff_state* s, const struct puff_huffman* lencode, const struct puff_huffman* distcode) { static const short lens[29] = {3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258}; static const short lext[29] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0}; static const short dists[30] = { 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577}; static const short dext[30] = {0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13}; int symbol; do { symbol = puff_decode(s, lencode); if (symbol < 0) return symbol; if (symbol < 256) { if (s->outcnt == s->outlen) return 1; if (symbol) s->out[s->outcnt] = symbol; s->outcnt++; } else if (symbol > 256) { symbol -= 257; if (symbol >= 29) return -10; int len = lens[symbol] + puff_bits(s, lext[symbol]); symbol = puff_decode(s, distcode); if (symbol < 0) return symbol; unsigned dist = dists[symbol] + puff_bits(s, dext[symbol]); if (dist > s->outcnt) return -11; if (s->outcnt + len > s->outlen) return 1; while (len--) { if (dist <= s->outcnt && s->out[s->outcnt - dist]) s->out[s->outcnt] = s->out[s->outcnt - dist]; s->outcnt++; } } } while (symbol != 256); return 0; } static int puff_fixed(struct puff_state* s) { static int virgin = 1; static short lencnt[MAXBITS + 1], lensym[FIXLCODES]; static short distcnt[MAXBITS + 1], distsym[MAXDCODES]; static struct puff_huffman lencode, distcode; if (virgin) { lencode.count = lencnt; lencode.symbol = lensym; distcode.count = distcnt; distcode.symbol = distsym; short lengths[FIXLCODES]; int symbol; for (symbol = 0; symbol < 144; symbol++) lengths[symbol] = 8; for (; symbol < 256; symbol++) lengths[symbol] = 9; for (; symbol < 280; symbol++) lengths[symbol] = 7; for (; symbol < FIXLCODES; symbol++) lengths[symbol] = 8; puff_construct(&lencode, lengths, FIXLCODES); for (symbol = 0; symbol < MAXDCODES; symbol++) lengths[symbol] = 5; puff_construct(&distcode, lengths, MAXDCODES); virgin = 0; } return puff_codes(s, &lencode, &distcode); } static int puff_dynamic(struct puff_state* s) { static const short order[19] = {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; int nlen = puff_bits(s, 5) + 257; int ndist = puff_bits(s, 5) + 1; int ncode = puff_bits(s, 4) + 4; if (nlen > MAXLCODES || ndist > MAXDCODES) return -3; short lengths[MAXCODES]; int index; for (index = 0; index < ncode; index++) lengths[order[index]] = puff_bits(s, 3); for (; index < 19; index++) lengths[order[index]] = 0; short lencnt[MAXBITS + 1], lensym[MAXLCODES]; struct puff_huffman lencode = {lencnt, lensym}; int err = puff_construct(&lencode, lengths, 19); if (err != 0) return -4; index = 0; while (index < nlen + ndist) { int symbol; int len; symbol = puff_decode(s, &lencode); if (symbol < 0) return symbol; if (symbol < 16) lengths[index++] = symbol; else { len = 0; if (symbol == 16) { if (index == 0) return -5; len = lengths[index - 1]; symbol = 3 + puff_bits(s, 2); } else if (symbol == 17) symbol = 3 + puff_bits(s, 3); else symbol = 11 + puff_bits(s, 7); if (index + symbol > nlen + ndist) return -6; while (symbol--) lengths[index++] = len; } } if (lengths[256] == 0) return -9; err = puff_construct(&lencode, lengths, nlen); if (err && (err < 0 || nlen != lencode.count[0] + lencode.count[1])) return -7; short distcnt[MAXBITS + 1], distsym[MAXDCODES]; struct puff_huffman distcode = {distcnt, distsym}; err = puff_construct(&distcode, lengths + nlen, ndist); if (err && (err < 0 || ndist != distcode.count[0] + distcode.count[1])) return -8; return puff_codes(s, &lencode, &distcode); } static int puff(unsigned char* dest, unsigned long* destlen, const unsigned char* source, unsigned long sourcelen) { struct puff_state s = { .out = dest, .outlen = *destlen, .outcnt = 0, .in = source, .inlen = sourcelen, .incnt = 0, .bitbuf = 0, .bitcnt = 0, }; int err; if (setjmp(s.env) != 0) err = 2; else { int last; do { last = puff_bits(&s, 1); int type = puff_bits(&s, 2); err = type == 0 ? puff_stored(&s) : (type == 1 ? puff_fixed(&s) : (type == 2 ? puff_dynamic(&s) : -1)); if (err != 0) break; } while (!last); } *destlen = s.outcnt; return err; } //% END CODE DERIVED FROM puff.{c,h} #define ZLIB_HEADER_WIDTH 2 static int puff_zlib_to_file(const unsigned char* source, unsigned long sourcelen, int dest_fd) { if (sourcelen < ZLIB_HEADER_WIDTH) return 0; source += ZLIB_HEADER_WIDTH; sourcelen -= ZLIB_HEADER_WIDTH; const unsigned long max_destlen = 132 << 20; void* ret = mmap(0, max_destlen, PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANON, -1, 0); if (ret == MAP_FAILED) return -1; unsigned char* dest = (unsigned char*)ret; unsigned long destlen = max_destlen; int err = puff(dest, &destlen, source, sourcelen); if (err) { munmap(dest, max_destlen); errno = -err; return -1; } if (write(dest_fd, dest, destlen) != (ssize_t)destlen) { munmap(dest, max_destlen); return -1; } return munmap(dest, max_destlen); } static int setup_loop_device(unsigned char* data, unsigned long size, const char* loopname, int* loopfd_p) { int err = 0, loopfd = -1; int memfd = syscall(__NR_memfd_create, "syzkaller", 0); if (memfd == -1) { err = errno; goto error; } if (puff_zlib_to_file(data, size, memfd)) { err = errno; goto error_close_memfd; } loopfd = open(loopname, O_RDWR); if (loopfd == -1) { err = errno; goto error_close_memfd; } if (ioctl(loopfd, LOOP_SET_FD, memfd)) { if (errno != EBUSY) { err = errno; goto error_close_loop; } ioctl(loopfd, LOOP_CLR_FD, 0); usleep(1000); if (ioctl(loopfd, LOOP_SET_FD, memfd)) { err = errno; goto error_close_loop; } } close(memfd); *loopfd_p = loopfd; return 0; error_close_loop: close(loopfd); error_close_memfd: close(memfd); error: errno = err; return -1; } static void reset_loop_device(const char* loopname) { int loopfd = open(loopname, O_RDWR); if (loopfd == -1) { return; } if (ioctl(loopfd, LOOP_CLR_FD, 0)) { } close(loopfd); } static long syz_mount_image(volatile long fsarg, volatile long dir, volatile long flags, volatile long optsarg, volatile long change_dir, volatile unsigned long size, volatile long image) { unsigned char* data = (unsigned char*)image; int res = -1, err = 0, need_loop_device = !!size; char* mount_opts = (char*)optsarg; char* target = (char*)dir; char* fs = (char*)fsarg; char* source = NULL; char loopname[64]; if (need_loop_device) { int loopfd; memset(loopname, 0, sizeof(loopname)); snprintf(loopname, sizeof(loopname), "/dev/loop%llu", procid); if (setup_loop_device(data, size, loopname, &loopfd) == -1) return -1; close(loopfd); source = loopname; } mkdir(target, 0777); char opts[256]; memset(opts, 0, sizeof(opts)); if (strlen(mount_opts) > (sizeof(opts) - 32)) { } strncpy(opts, mount_opts, sizeof(opts) - 32); if (strcmp(fs, "iso9660") == 0) { flags |= MS_RDONLY; } else if (strncmp(fs, "ext", 3) == 0) { bool has_remount_ro = false; char* remount_ro_start = strstr(opts, "errors=remount-ro"); if (remount_ro_start != NULL) { char after = *(remount_ro_start + strlen("errors=remount-ro")); char before = remount_ro_start == opts ? '\0' : *(remount_ro_start - 1); has_remount_ro = ((before == '\0' || before == ',') && (after == '\0' || after == ',')); } if (strstr(opts, "errors=panic") || !has_remount_ro) strcat(opts, ",errors=continue"); } else if (strcmp(fs, "xfs") == 0) { strcat(opts, ",nouuid"); } res = mount(source, target, fs, flags, opts); if (res == -1) { err = errno; goto error_clear_loop; } res = open(target, O_RDONLY | O_DIRECTORY); if (res == -1) { err = errno; goto error_clear_loop; } if (change_dir) { res = chdir(target); if (res == -1) { err = errno; } } error_clear_loop: if (need_loop_device) reset_loop_device(loopname); errno = err; return res; } #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; } #define USLEEP_FORKED_CHILD (3 * 50 * 1000) static long handle_clone_ret(long ret) { if (ret != 0) { __atomic_store_n(&clone_ongoing, 0, __ATOMIC_RELAXED); return ret; } usleep(USLEEP_FORKED_CHILD); syscall(__NR_exit, 0); while (1) { } } static long syz_clone(volatile long flags, volatile long stack, volatile long stack_len, volatile long ptid, volatile long ctid, volatile long tls) { long sp = (stack + stack_len) & ~15; __atomic_store_n(&clone_ongoing, 1, __ATOMIC_RELAXED); long ret = (long)syscall(__NR_clone, flags & ~CLONE_VM, sp, ptid, ctid, tls); return handle_clone_ret(ret); } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } int i, call, thread; for (call = 0; call < 22; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 50 + (call == 3 ? 4000 : 0) + (call == 19 ? 4000 : 0)); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } 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[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: NONFAILING(memcpy((void*)0x20000140, "/dev/net/tun\000", 13)); res = syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0x20000140ul, /*flags=*/0ul, /*mode=*/0ul); if (res != -1) r[0] = res; break; case 1: NONFAILING(memcpy((void*)0x20000680, "veth1_to_bridge\000", 16)); NONFAILING(*(uint16_t*)0x20000690 = 0xc0f4); syscall(__NR_ioctl, /*fd=*/r[0], /*cmd=*/0x400454ca, /*arg=*/0x20000680ul); break; case 2: NONFAILING(*(uint16_t*)0x20000040 = 2); NONFAILING(*(uint64_t*)0x20000048 = 0x20000000); NONFAILING(*(uint16_t*)0x20000000 = 3); NONFAILING(*(uint8_t*)0x20000002 = 0); NONFAILING(*(uint8_t*)0x20000003 = 3); NONFAILING(*(uint32_t*)0x20000004 = 0); NONFAILING(*(uint16_t*)0x20000008 = 6); NONFAILING(*(uint8_t*)0x2000000a = 0); NONFAILING(*(uint8_t*)0x2000000b = 0x7c); NONFAILING(*(uint32_t*)0x2000000c = 0); syscall(__NR_ioctl, /*fd=*/r[0], /*cmd=*/0x401054d5, /*arg=*/0x20000040ul); break; case 3: NONFAILING(memcpy((void*)0x20000140, "vfat\000", 5)); NONFAILING(memcpy((void*)0x20000040, "./file0\000", 8)); NONFAILING(memcpy( (void*)0x20000180, "\x78\x9c\xec\xdd\xcf\x6b\x23\x65\x18\xc0\xf1\x27\x69\x36\xbf\x96\x6d" "\x72\x10\x45\x41\xfa\xa0\x17\xbd\x0c\x6d\xf4\xac\x06\xd9\x05\x31\xe0" "\xd2\xdd\x88\xbb\x82\x30\xbb\x9d\x68\xc8\x98\x94\x99\x50\x89\x88\xad" "\x27\xaf\xe2\xcd\x7f\x40\x70\xd9\x63\x6f\x05\xf5\x1f\xe8\xc5\x5b\xbd" "\x78\xf1\xd6\x4b\x41\xd0\x22\xe2\xc8\x4c\x66\xda\xfc\x98\x24\x4d\x9a" "\x92\xd6\x7e\x3f\x50\xf2\x4c\xde\xf7\x99\x99\x37\x33\x84\xe7\x0d\xcc" "\xdb\xc3\x0f\xbe\xf9\xb4\x51\x73\x8d\x9a\xd9\x96\x64\x56\x25\x21\x22" "\x72\x2c\x52\x94\xa4\x44\x12\xe1\x6b\x32\x88\xd3\xd2\x6b\x47\x5e\xbd" "\xf9\xc7\xc1\x8b\xf7\x1e\x3c\x7c\xb7\x5c\xa9\xdc\x5e\x57\xbd\x53\xbe" "\xff\x5a\x49\x55\x97\x57\x7e\xfc\xec\x8b\x5c\xd8\x6d\x2f\x23\xfb\xc5" "\x8f\x0e\x8f\x4a\xbf\xef\x3f\xbb\xff\xfc\xe1\xbf\xf7\x3f\xa9\xbb\x5a" "\x77\xb5\xd9\x6a\xab\xa9\x8f\x5a\xbf\xb5\xcd\x47\xb6\xa5\x1b\x75\xb7" "\x61\xa8\xde\xb5\x2d\xd3\xb5\xb4\xde\x74\x2d\xa7\xdb\xde\xea\xb6\xd7" "\xec\xd6\xe6\x66\x47\xcd\xe6\xc6\xad\xfc\xa6\x63\xb9\xae\x9a\xcd\x8e" "\x36\xac\x8e\xb6\x5b\xda\x76\x3a\x6a\x7e\x6c\xd6\x9b\x6a\x18\x86\xde" "\xca\xcb\xf5\x92\x1d\xd8\xf6\x12\x93\x73\xaa\x4f\xd6\xd7\xcd\xf2\x8c" "\x07\x7c\x3c\x63\x1e\xe6\xed\x6f\xcf\xf3\xc6\x34\x3b\x4e\xd9\x5c\x12" "\x31\x72\x43\x2d\xd5\x27\x17\x7a\x5e\x00\x00\xe0\x52\x1a\xa8\xff\xbf" "\x8b\x6a\x84\xa2\x24\x4f\x0a\xca\x44\xdf\x5c\x60\xb8\xfe\x8f\xe2\xa0" "\xfe\xf7\xab\xce\xd3\xfa\xff\xe9\x4b\x3f\xb7\x6f\xbe\xbf\xbb\x1c\xd6" "\xff\x7b\xe9\xb8\xfa\xff\xf5\x5f\xbb\xf9\x7d\xf5\xbf\x7f\xf4\xb9\xd7" "\xff\x3f\x0c\x6c\x0f\x57\x44\x57\xde\xf6\x34\x9d\xcf\x55\xff\xe3\x72" "\x58\x49\x0f\xbd\xd5\x3f\xf5\xf3\xeb\xff\x7c\x38\x7f\x0f\x7c\xf5\xe1" "\xd3\xd5\x20\xa0\xfe\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\xe0\x2a\x38\xf6\xbc\x82\xe7\x79\x85\xe8\x35\xfa" "\x3b\x7d\x84\x20\xdc\x8e\xb6\xc6\x3d\x68\x8c\x2b\x67\xd4\xf5\xcf\x84" "\x2b\x0a\x9c\xdc\x0f\xf8\x5f\xba\xf7\xe0\xa1\x64\x83\x07\xf7\x52\xcb" "\x22\xf6\xd7\x5b\xd5\xad\x6a\xf7\x35\x6c\x8f\x3a\xae\x4a\x41\xfe\x09" "\xee\x87\x50\x77\xc1\x89\x9d\xa0\x51\x7d\x45\xf9\xc9\xde\x0e\xf3\xb7" "\xb7\xaa\x4b\x41\x4b\x59\x44\xc5\x16\x4b\xd6\xa4\x20\xc5\xbe\xfc\x20" "\xbe\xf3\x4e\xe5\xf6\x9a\x76\xf5\xe7\x27\x52\x79\x3f\xbf\x26\xf5\x20" "\xbf\x24\x05\x79\x26\x3e\xbf\x14\x9b\x9f\x96\x57\x5e\xee\xc9\x37\xa4" "\x20\xbf\x3c\x96\x96\xd8\xb2\x11\x7e\x8f\x45\xf9\x5f\xae\xa9\xbe\xfd" "\x5e\x65\x20\x3f\x17\xf4\x8b\xf3\xe6\xc5\x5f\x16\x00\x00\x00\x00\x00" "\xe6\xca\x50\xcd\x86\xd3\xe7\xd8\xf9\xbb\x61\xa8\xc6\xb5\xfb\x73\x79" "\xe9\x9d\x9f\x0f\xff\x3e\x70\x32\xbf\x5e\x8d\x9d\x9f\xa7\x0a\x2f\xa4" "\x16\x3b\x76\x00\x00\x00\x00\x00\xae\x0b\x37\xfd\x79\xc3\xb4\x6d\xcb" "\x71\x3b\x23\x83\x9c\x4c\xea\x93\x09\xf7\x36\x7e\x3f\xf1\x41\x6a\x9a" "\xce\x7e\x70\x10\x04\x37\xc6\xf5\x59\xea\x19\xe1\x59\xf7\x9c\x0e\xff" "\x83\xc6\x14\x27\x2f\xd3\x8d\xd4\xb4\xed\x3f\x33\x12\xfb\x61\x46\x4b" "\xb8\xf6\x35\x65\xcf\xf1\xa9\x9a\x76\x34\xfe\x33\x74\xce\x4e\x7b\x09" "\x1c\x37\x39\xfd\xd8\x2d\xc7\x5d\xf1\xcf\x47\x67\x1a\x4e\x4f\x10\xfd" "\x6c\x34\xaa\x8f\xdc\x9d\x75\xcf\xa3\x82\x68\xe5\xdc\x49\x9d\x9f\xfb" "\xf6\xfb\xbf\x66\x3b\x44\x22\x5c\xb5\xb7\xb7\xe9\x8d\xdd\xec\x84\x91" "\x06\x41\x62\xe0\x9d\x9d\x09\x37\xed\x91\xe7\x4d\x3c\x9f\x1b\x17\xf9" "\x9d\x03\x00\x00\x00\x60\x31\xa2\xa2\x3f\xe7\x46\xef\xbc\xb5\xd8\x13" "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\xe0\x1a\x9a\xeb\x32\x69\x23\x82\x45\x8f\x11" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xb8\x2c\xfe\x0b\x00\x00\xff" "\xff\xbd\x9b\xf9\x62", 855)); NONFAILING(syz_mount_image(/*fs=*/0x20000140, /*dir=*/0x20000040, /*flags=*/0, /*opts=*/0x20000000, /*chdir=*/1, /*size=*/0x357, /*img=*/0x20000180)); break; case 4: syscall(__NR_ioctl, /*fd=*/-1, /*cmd=*/0xc0502100, /*arg=*/0ul); break; case 5: NONFAILING(*(uint64_t*)0x20000140 = 8); NONFAILING(*(uint64_t*)0x20000148 = 0x8b); syscall(__NR_prlimit64, /*pid=*/0, /*res=RLIMIT_RTPRIO*/ 0xeul, /*new=*/0x20000140ul, /*old=*/0ul); break; case 6: NONFAILING(*(uint32_t*)0x20000080 = 7); syscall(__NR_sched_setscheduler, /*pid=*/0, /*policy=SCHED_FIFO*/ 1ul, /*prio=*/0x20000080ul); break; case 7: syscall(__NR_prctl, /*option=*/0x3eul, /*cmd=*/1ul, /*pid=*/0, /*type=PIDTYPE_PGID*/ 2ul, /*uaddr=*/0ul); break; case 8: NONFAILING(*(uint64_t*)0x20000040 = 0x10001); syscall(__NR_sched_setaffinity, /*pid=*/0, /*cpusetsize=*/8ul, /*mask=*/0x20000040ul); break; case 9: NONFAILING(memcpy((void*)0x200002c0, "/dev/hwrng\000", 11)); res = syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0x200002c0ul, /*flags=*/0ul, /*mode=*/0ul); if (res != -1) r[1] = res; break; case 10: NONFAILING(*(uint64_t*)0x20000240 = 0x20033a80); NONFAILING(*(uint64_t*)0x20000248 = 0xfffffd6e); syscall(__NR_preadv, /*fd=*/r[1], /*vec=*/0x20000240ul, /*vlen=*/1ul, /*off_low=*/0, /*off_high=*/0); break; case 11: syscall(__NR_socket, /*domain=*/2ul, /*type=*/1ul, /*proto=*/0); break; case 12: NONFAILING(*(uint64_t*)0x200001c0 = 0); NONFAILING(*(uint64_t*)0x200001c8 = 0); NONFAILING(*(uint64_t*)0x200001d0 = 1); NONFAILING(*(uint64_t*)0x200001d8 = 0); NONFAILING(*(uint64_t*)0x200001e0 = 0); NONFAILING(*(uint64_t*)0x200001e8 = 0); NONFAILING(*(uint64_t*)0x200001f0 = 0); NONFAILING(*(uint64_t*)0x200001f8 = 0); NONFAILING(*(uint64_t*)0x20000200 = 0); NONFAILING(*(uint64_t*)0x20000208 = 0); NONFAILING(*(uint64_t*)0x20000210 = 0); NONFAILING(*(uint64_t*)0x20000218 = 0); NONFAILING(*(uint64_t*)0x20000220 = 0); NONFAILING(*(uint64_t*)0x20000228 = 0); NONFAILING(*(uint64_t*)0x20000230 = 0); NONFAILING(*(uint64_t*)0x20000238 = 0x8000000000000001); NONFAILING(*(uint64_t*)0x20000240 = 0); NONFAILING(*(uint64_t*)0x20000248 = 0); NONFAILING(*(uint64_t*)0x20000250 = 0); NONFAILING(*(uint64_t*)0x20000258 = 0); NONFAILING(*(uint64_t*)0x20000260 = 0); NONFAILING(*(uint64_t*)0x20000268 = 0); NONFAILING(*(uint64_t*)0x20000270 = 0); NONFAILING(*(uint64_t*)0x20000278 = 0); NONFAILING(*(uint64_t*)0x20000280 = 0); NONFAILING(*(uint64_t*)0x20000288 = 3); syscall(__NR_clock_adjtime, /*id=CLOCK_THREAD_CPUTIME_ID|0xffffffd0*/ 0xffffffd3ul, /*tx=*/0x200001c0ul); break; case 13: NONFAILING(syz_clone(/*flags=*/0, /*stack=*/0, /*stack_len=*/0, /*parentid=*/0, /*childtid=*/0, /*tls=*/0)); break; case 14: NONFAILING( memcpy((void*)0x200001c0, "blkio.bfq.io_wait_time_recursive\000", 33)); res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x200001c0ul, /*flags=*/0x275aul, /*mode=*/0ul); if (res != -1) r[2] = res; break; case 15: NONFAILING(memcpy((void*)0x20000500, "#! ", 3)); NONFAILING(memcpy((void*)0x20000503, "./file2", 7)); NONFAILING(*(uint8_t*)0x2000050a = 0xa); syscall(__NR_write, /*fd=*/r[2], /*data=*/0x20000500ul, /*len=*/0xfffffffffffffda3ul); break; case 16: NONFAILING(syz_genetlink_get_family_id(/*name=*/0, /*fd=*/r[2])); break; case 17: NONFAILING(memcpy((void*)0x200002c0, "batadv_slave_1\000\000", 16)); syscall(__NR_ioctl, /*fd=*/r[2], /*cmd=*/0x8933, /*arg=*/0x200002c0ul); break; case 18: syscall(__NR_bpf, /*cmd=*/0ul, /*arg=*/0ul, /*size=*/0ul); break; case 19: NONFAILING(memcpy((void*)0x20000100, "hfsplus\000", 8)); NONFAILING( memcpy((void*)0x20002900, "./" "file0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\000", 250)); NONFAILING(memcpy( (void*)0x20001340, "\x78\x9c\xec\xdd\xc1\x6f\x1c\x57\x1d\x07\xf0\xef\xac\xd7\x8e\xb7\x54" "\xc1\x69\x13\x1a\xa1\x22\xac\x44\x2a\x48\x11\x89\x13\x2b\x85\x70\xc1" "\x20\x84\x72\xa8\x50\x55\x0e\x3d\x5b\x89\xd3\x58\xdd\x24\x55\xe2\xa2" "\xb4\x42\x90\x02\x82\x13\x12\x87\xfe\x01\x05\xc9\x37\x0e\x08\x89\x7b" "\x50\xb8\x70\x29\xb7\x5e\x7d\xac\x84\xc4\x25\xe2\x10\xf5\xb2\x68\x66" "\x67\xd7\xbb\xf6\x3a\x5e\x27\xf6\x3a\x81\xcf\x27\x1a\xcf\x7b\xf3\x66" "\xde\xfc\xe6\x37\x6f\x66\xbc\xeb\xac\x36\xc0\xff\xad\xcb\x67\xd2\xbc" "\x9f\x22\x97\xcf\xbc\x71\xb7\xac\x6f\xac\x2f\xb6\x37\xd6\x17\x8f\xd4" "\xcd\xed\x24\x65\xb9\x91\x34\xbb\xb3\x14\x37\x93\xe2\x41\xb2\x54\xb6" "\x17\x03\x53\x06\xe6\xdb\x7c\xbc\x7a\xe9\xad\xcf\x1e\x6e\x7c\xde\xad" "\x35\xeb\xa9\x5a\x7f\xaa\xbf\xdd\xec\x58\x21\x8f\xd8\xc7\xbd\x7a\xca" "\x7c\xdd\xdf\xfc\xc8\x2d\xa7\xc7\xea\xbf\xdb\x57\x15\x5e\x5e\x4c\x72" "\xa5\x9e\x0f\x9b\x19\xb7\xaf\xa1\x15\xcb\xa4\x9d\xae\xe7\x70\xe8\x3a" "\xdb\xdc\xdb\xcb\xe6\x3b\x5e\xef\xc0\xb3\xaf\xf7\x74\x2a\xba\xcf\xcd" "\x6d\xe6\x92\x17\xea\x27\x73\xf5\x3b\x41\x7d\x77\x68\x4c\x2e\xc2\x83" "\xb1\xa7\xbb\x1c\x00\x00\x00\x3c\xa7\x3e\xbd\x75\xd8\x11\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\xc0\xf3\xa7\xfe\xfe\xff\xa2\x9e\x1a\xf5" "\x3c\xf3\x29\x7a\xdf\xff\x3f\xd3\x5b\x56\x97\x9f\x41\x4b\x63\xaf\x79" "\xff\x40\xe3\x00\x00\x00\x00\x00\x00\x00\x80\xc9\xf8\xfa\xa3\x3c\xca" "\xdd\x1c\xed\xd5\x3b\x45\xf5\x37\xff\x53\x55\xe5\x78\xbe\xe8\x24\x5f" "\xca\xfb\xb9\x93\x95\xdc\xce\xd9\xdc\xcd\x72\xd6\xb2\x96\xdb\x39\x9f" "\x64\x6e\xa0\xa3\x99\xbb\xcb\x6b\x6b\xb7\xcf\xf7\xb7\x2c\x8d\xde\xf2" "\xc2\xc8\x2d\x2f\x4c\xea\x88\x01\x00\x00\x00\x00\x00\x00\xe0\x7f\xd2" "\x2f\xd3\xda\xfc\xfb\x3f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x3c\x0b\x8a\x64\xaa\x3b\xab\xa6\xe3\xf5\x3c\x73\x69\x34\xb3" "\xd9\x96\x7b\xc9\x3f\x93\xcc\x1c\x76\xbc\x7b\x50\x8c\x5a\x78\x7f\xf2" "\x71\x00\x00\x00\xc0\x53\x99\x7d\x82\x6d\xbe\xfc\x28\x8f\x72\x37\x47" "\x7b\xf5\x4e\x51\xbd\xe6\xff\x4a\xf5\x7a\x79\x36\xef\xe7\x66\xd6\xb2" "\x9a\xb5\xb4\xb3\x92\xab\xf5\x6b\xe8\xf2\x55\x7f\x63\x63\x7d\xb1\xbd" "\xb1\xbe\x78\xa3\x9c\xca\xfa\x70\xbf\xdf\xff\xf7\x9e\xc2\x98\xa9\x7b" "\x98\xaa\x6a\xa3\xf6\x7c\xb2\x5a\xa3\x95\x6b\x59\xad\x96\x9c\xcd\x95" "\x2a\x98\xab\x69\x74\xf7\x7d\x3a\x39\xd9\x8b\x67\x20\xae\x01\x1f\x95" "\x31\x15\xdf\xab\x8d\x19\x59\xb3\x4e\x6b\xb9\xb3\xdf\xef\xf4\x2e\xc2" "\xbe\x18\x7e\x2b\xa2\xf1\x98\x35\x5b\x9b\xc1\x25\xfd\x8c\x2c\xd4\xb1" "\x95\x5b\x1e\xeb\x66\xa0\xa8\xde\xa8\x49\xb6\x66\x62\xd7\xb3\xd3\x1c" "\xaa\xcd\x55\xbd\x4e\xf7\xf7\x74\x3e\x8d\xfe\x3b\x3f\xc7\x0f\x20\xe7" "\x2f\xd4\xf3\xf2\x78\x7e\x73\xa0\x39\xdf\xab\x7e\x26\x1a\xa9\x32\x71" "\xa1\x37\xfa\xca\x6b\xe6\xf1\x99\x48\xbe\xf1\xd7\x3f\xbd\x7d\xbd\x7d" "\xf3\xdd\xeb\xd7\xee\x9c\x79\x76\x0e\x69\x17\x53\x3b\x2c\xdf\x3a\x26" "\x16\x07\x32\xf1\xca\x73\x9d\x89\xe6\x1e\xd7\x5f\xa8\x32\x71\xa2\x5f" "\xbf\x9c\x1f\xe5\x27\x39\x93\xf9\xbc\x99\xdb\x59\xcd\x4f\xb3\x9c\xb5" "\xac\xa4\x53\xb7\x2f\xd7\xe3\xb9\xfc\x39\xf7\xf8\x4c\x2d\x0d\xd5\xde" "\xdc\x2d\x92\x99\xfa\xbc\x74\xcf\xd9\x38\x31\xcd\xe7\x87\x55\x69\x39" "\xa7\xaa\x6d\x8f\x66\x35\x45\x6e\xe5\x6a\x56\xf2\x7a\xf5\xef\x42\xce" "\xe7\xdb\xb9\x98\x8b\xb9\x34\x70\x86\x4f\xec\x18\x77\x75\x6c\xd5\x55" "\xdf\xd8\x7a\xd5\xf7\xce\xf4\xdf\x46\x06\x7f\xfa\x9b\x75\xa1\xbc\xbb" "\xfd\x76\xf3\x2e\xb7\xf4\xb8\x23\xde\x69\x74\xee\x97\xee\xbd\xbf\xcc" "\xeb\xb1\x81\xbc\x76\x47\xfd\xc3\xfe\x5a\xc7\x06\xae\x83\x85\x81\x2c" "\xbd\xd4\xcb\xce\xf4\xc8\xce\x9f\xe4\xde\xd8\xfc\x6a\x5d\x28\xf7\xf1" "\xab\x5d\x9e\x13\x93\x35\x57\x67\xa2\xbc\x80\x7a\x4f\x89\x5e\x74\x2f" "\x77\x33\xd1\xac\x9e\x45\xdb\xc7\xf9\x1f\x3a\xe5\x76\x69\xdf\xec\x74" "\xae\x2f\xbf\xb7\x43\xff\xf7\xb6\xd4\x5f\xab\xe7\xe5\xb0\x5a\xff\xda" "\x6e\x6b\xf7\x8c\x3e\x15\xfb\xab\x1c\x2f\x2f\x65\xb6\xbe\x93\x0c\x8f" "\x8e\xb2\xed\xe5\xfe\x5d\x66\xa0\xad\xb3\x39\x96\xbb\x6d\xc3\x4f\xdc" "\x72\xbb\x13\x55\x5b\x51\xf4\xae\xd4\x1f\xe7\x56\x35\x00\xb6\x5f\xa9" "\x33\xf5\xef\x70\xdb\x7b\xba\x50\xb5\xbd\x32\xb2\x6d\xb1\x6a\x3b\x39" "\xd0\x36\xf4\xfb\x56\x6e\xa5\x9d\xab\x13\xc8\x1f\x00\x4f\xe2\x1f\x6f" "\xf7\x8b\x73\x79\x61\xa6\xf5\xaf\xd6\xa7\xad\x4f\x5a\xbf\x6e\x5d\x6f" "\xbd\x31\xfb\x83\x23\xdf\x39\xf2\xea\x4c\xa6\xff\x3e\xfd\xdd\xe6\xc2" "\xd4\x6b\x8d\x57\x8b\xbf\xe4\x93\xfc\x7c\xf3\xf5\x3f\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\xf0\xe4\xee\x7c\xf0\xe1\xbb\xcb\xed\xf6\xca\xed\xd1\x85\xc6" "\xce\x4d\x43\x85\x56\xb6\x2e\xd9\xa9\xe7\x23\xa3\xfb\x29\xea\x2f\xf4" "\x19\x63\x5f\xcf\x45\x61\x36\xc9\xd0\x92\xea\x7b\x8e\x26\x1e\x46\x6b" "\x6b\x18\xdb\x0a\x9d\x5f\x24\x13\xcf\x4f\xef\x4b\x04\x47\xaf\xf3\xbb" "\xb2\xd0\xdc\x36\xa2\x46\x15\x96\x86\x96\xfc\x79\x7b\x87\x1f\xed\x31" "\xc2\x62\xbc\xeb\xe2\x00\x0b\x8d\x4c\x76\xa7\x53\x19\x3d\x00\x0e\xf1" "\xa6\x04\x4c\xc4\xb9\xb5\x1b\xef\x9d\xbb\xf3\xc1\x87\xdf\x5a\xbd\xb1" "\xfc\xce\xca\x3b\x2b\x37\xa7\x2f\x5e\xbc\xb4\x70\xe9\xe2\xeb\x8b\xe7" "\xae\xad\xb6\x57\x16\xba\x3f\x0f\x3b\x4a\xe0\x20\x6c\x3e\xf4\x0f\x3b" "\x12\x00\x00\x00\x00\x00\x00\x00\x00\x00\x60\x5c\xa3\x3e\x18\x70\xea" "\xc5\xdd\x3e\x34\x32\xd6\x67\x3c\xfc\xcf\x42\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x60\x5f\x5c\x3e\x93\xe6\xfd\x14\x39\xbf\x70\x76\xa1\xac\x6f\xac\x2f" "\xb6\xcb\xa9\x57\xde\x5c\xb3\x99\xa4\xd1\x48\x8a\x9f\x25\xc5\x83\x64" "\x29\xdd\x29\x73\x03\xdd\x15\xf9\xe3\x83\x74\x46\xec\xe7\xe3\xd5\x4b" "\x6f\x7d\xf6\x70\xe3\xf3\xcd\xbe\x9a\xdd\xf5\x93\x46\x3d\xdf\xd9\xe3" "\x5b\x93\xdc\xab\xa7\xcc\x27\x99\xaa\xe7\x4f\x61\xa8\xbf\x2b\x4f\xdd" "\x5f\xf1\x9f\xde\x31\x94\x09\xfb\xa2\xd3\xe9\x2c\x3d\x5d\x7c\xb0\x3f" "\xfe\x1b\x00\x00\xff\xff\x3f\x7b\xf4\xb4", 1744)); NONFAILING(syz_mount_image(/*fs=*/0x20000100, /*dir=*/0x20002900, /*flags=MS_LAZYTIME|MS_SYNCHRONOUS*/ 0x2000010, /*opts=*/0x200022c0, /*chdir=*/1, /*size=*/0x6d0, /*img=*/0x20001340)); break; case 20: NONFAILING(memcpy((void*)0x200001c0, "./file2\000", 8)); syscall(__NR_mkdir, /*path=*/0x200001c0ul, /*mode=*/0ul); break; case 21: NONFAILING(memcpy((void*)0x200005c0, "./file0\000", 8)); syscall(__NR_mkdirat, /*fd=*/0xffffff9c, /*path=*/0x200005c0ul, /*mode=*/0ul); break; } } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x21000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1, /*offset=*/0ul); setup_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 < 6; procid++) { if (fork() == 0) { use_temporary_dir(); loop(); } } sleep(1000000); return 0; }