// https://syzkaller.appspot.com/bug?id=20c4a7b5a6f4c32158f2b8ea3dd461bc1e9e9a4e // 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 #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 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; //% 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, destlen); } static int setup_loop_device(unsigned char* data, unsigned long size, const char* loopname, int* loopfd_p) { int err = 0, loopfd = -1; int memfd = syscall(__NR_memfd_create, "syzkaller", 0); if (memfd == -1) { err = errno; goto error; } if (puff_zlib_to_file(data, size, memfd)) { err = errno; goto error_close_memfd; } loopfd = open(loopname, O_RDWR); if (loopfd == -1) { err = errno; goto error_close_memfd; } if (ioctl(loopfd, LOOP_SET_FD, memfd)) { if (errno != EBUSY) { err = errno; goto error_close_loop; } ioctl(loopfd, LOOP_CLR_FD, 0); usleep(1000); if (ioctl(loopfd, LOOP_SET_FD, memfd)) { err = errno; goto error_close_loop; } } close(memfd); *loopfd_p = loopfd; return 0; error_close_loop: close(loopfd); error_close_memfd: close(memfd); error: errno = err; return -1; } static long syz_mount_image(volatile long fsarg, volatile long dir, volatile long flags, volatile long optsarg, volatile long change_dir, volatile unsigned long size, volatile long image) { unsigned char* data = (unsigned char*)image; int res = -1, err = 0, loopfd = -1, need_loop_device = !!size; char* mount_opts = (char*)optsarg; char* target = (char*)dir; char* fs = (char*)fsarg; char* source = NULL; char loopname[64]; if (need_loop_device) { memset(loopname, 0, sizeof(loopname)); snprintf(loopname, sizeof(loopname), "/dev/loop%llu", procid); if (setup_loop_device(data, size, loopname, &loopfd) == -1) return -1; source = loopname; } mkdir(target, 0777); char opts[256]; memset(opts, 0, sizeof(opts)); if (strlen(mount_opts) > (sizeof(opts) - 32)) { } strncpy(opts, mount_opts, sizeof(opts) - 32); if (strcmp(fs, "iso9660") == 0) { flags |= MS_RDONLY; } else if (strncmp(fs, "ext", 3) == 0) { 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) { ioctl(loopfd, LOOP_CLR_FD, 0); close(loopfd); } 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; retry: while (umount2(dir, MNT_DETACH | UMOUNT_NOFOLLOW) == 0) { } dp = opendir(dir); if (dp == NULL) { if (errno == EMFILE) { exit(1); } exit(1); } struct dirent* ep = 0; while ((ep = readdir(dp))) { if (strcmp(ep->d_name, ".") == 0 || strcmp(ep->d_name, "..") == 0) continue; char filename[FILENAME_MAX]; snprintf(filename, sizeof(filename), "%s/%s", dir, ep->d_name); while (umount2(filename, MNT_DETACH | UMOUNT_NOFOLLOW) == 0) { } struct stat st; if (lstat(filename, &st)) exit(1); if (S_ISDIR(st.st_mode)) { remove_dir(filename); continue; } int i; for (i = 0;; i++) { if (unlink(filename) == 0) break; if (errno == EPERM) { int fd = open(filename, O_RDONLY); if (fd != -1) { long flags = 0; if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) { } close(fd); continue; } } if (errno == EROFS) { break; } if (errno != EBUSY || i > 100) exit(1); if (umount2(filename, MNT_DETACH | UMOUNT_NOFOLLOW)) exit(1); } } closedir(dp); for (int i = 0;; i++) { if (rmdir(dir) == 0) break; if (i < 100) { if (errno == EPERM) { int fd = open(dir, O_RDONLY); if (fd != -1) { long flags = 0; if (ioctl(fd, FS_IOC_SETFLAGS, &flags) == 0) { } close(fd); continue; } } if (errno == EROFS) { break; } if (errno == EBUSY) { if (umount2(dir, MNT_DETACH | UMOUNT_NOFOLLOW)) exit(1); continue; } if (errno == ENOTEMPTY) { if (iter < 100) { iter++; goto retry; } } } exit(1); } } static void kill_and_wait(int pid, int* status) { kill(-pid, SIGKILL); kill(pid, SIGKILL); for (int i = 0; i < 100; i++) { if (waitpid(-1, status, WNOHANG | __WALL) == pid) return; usleep(1000); } DIR* dir = opendir("/sys/fs/fuse/connections"); if (dir) { for (;;) { struct dirent* ent = readdir(dir); if (!ent) break; if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) continue; char abort[300]; snprintf(abort, sizeof(abort), "/sys/fs/fuse/connections/%s/abort", ent->d_name); int fd = open(abort, O_WRONLY); if (fd == -1) { continue; } if (write(fd, abort, 1) < 0) { } close(fd); } closedir(dir); } else { } while (waitpid(-1, status, __WALL) != pid) { } } static void reset_loop() { char buf[64]; snprintf(buf, sizeof(buf), "/dev/loop%llu", procid); int loopfd = open(buf, O_RDWR); if (loopfd != -1) { ioctl(loopfd, LOOP_CLR_FD, 0); close(loopfd); } } static void setup_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); write_file("/proc/self/oom_score_adj", "1000"); if (symlink("/dev/binderfs", "./binderfs")) { } } #define NL802154_CMD_SET_SHORT_ADDR 11 #define NL802154_ATTR_IFINDEX 3 #define NL802154_ATTR_SHORT_ADDR 10 static void setup_802154() { int sock_route = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); if (sock_route == -1) exit(1); int sock_generic = socket(AF_NETLINK, SOCK_RAW, NETLINK_GENERIC); if (sock_generic < 0) exit(1); int nl802154_family_id = netlink_query_family_id(&nlmsg, sock_generic, "nl802154", true); 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)); int err = netlink_send(&nlmsg, sock_generic); if (err < 0) { } 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)); int err = netlink_send(&nlmsg, sock_route); if (err < 0) { } } } close(sock_route); close(sock_generic); } struct thread_t { int created, call; event_t ready, done; }; static struct thread_t threads[16]; static void execute_call(int call); static int running; static void* thr(void* arg) { struct thread_t* th = (struct thread_t*)arg; for (;;) { event_wait(&th->ready); event_reset(&th->ready); execute_call(th->call); __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED); event_set(&th->done); } return 0; } static void execute_one(void) { int i, call, thread; for (call = 0; call < 8; call++) { for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0])); thread++) { struct thread_t* th = &threads[thread]; if (!th->created) { th->created = 1; event_init(&th->ready); event_init(&th->done); event_set(&th->done); thread_start(thr, th); } if (!event_isset(&th->done)) continue; event_reset(&th->done); th->call = call; __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED); event_set(&th->ready); event_timedwait(&th->done, 50 + (call == 0 ? 4000 : 0)); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); reset_loop(); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); setup_test(); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; sleep_ms(1); if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x200000c0, "nilfs2\000", 7); memcpy((void*)0x200001c0, "./file2\000", 8); *(uint32_t*)0x20000240 = 0; memcpy( (void*)0x20000c40, "\x78\x9c\xec\xdd\x4d\x6c\x1c\x57\x01\x00\xe0\x37\x6b\xaf\x1d\x37\x2d" "\xd9\x94\x84\x98\x34\xb4\x09\x85\xb6\xfc\xd4\x6e\x1c\x13\x7e\x22\x68" "\xaa\xe6\x42\x68\x2a\x6e\x95\x2a\x2e\x51\x92\x96\x88\x34\x20\x52\xa9" "\xb4\xea\x21\xc9\x89\x1b\xad\xaa\x70\xe5\x47\x9c\x7a\xa9\x00\x21\xd1" "\x0b\x8a\x7a\xe2\x52\x89\x46\xe2\xd2\x53\xe1\xc0\x81\x28\x48\x95\x38" "\x40\x21\x59\xe4\xf5\x7b\xfb\xf3\xbc\xcb\xec\x3a\x59\xaf\xd7\xfb\x7d" "\xd2\xf3\xdb\x37\x6f\x76\xde\x9b\xf5\xcc\xec\xec\xcc\xbc\xf7\x02\x30" "\xb1\x2a\x8d\xbf\xcb\xcb\xf3\x45\x08\x57\xde\x7e\xe3\xd8\xdf\x1f\xfa" "\xdb\xdc\xca\x94\xc7\x9b\x73\xd4\x1a\x7f\xa7\xdb\x52\xd5\x10\x42\x11" "\xd3\xd3\xd9\xf2\x3e\x98\x5a\x8d\x6f\x7e\xf8\xea\xa9\x6e\x71\x11\x96" "\x1a\x7f\x53\x3a\x3c\x7d\xa3\xf9\xde\xed\x21\x84\x8b\x61\x7f\xb8\x1a" "\x6a\x61\xef\x95\x6b\xaf\xbf\xbb\xf4\xd4\x89\x4b\xc7\x2f\x1f\x78\xef" "\xcd\x23\xd7\x87\xb3\xf6\x00\x00\x30\x59\xbe\x7d\xf5\xc8\xf2\xee\xbf" "\xfc\xe9\xbe\x9d\x1f\xbd\x75\xff\xd1\x30\xdb\x9c\x9e\xce\xcf\x6b\x31" "\x7d\x77\x3c\xef\x3f\x1a\x4f\xfc\xd3\xf9\x7f\x25\x74\xa6\x8b\xb6\xd0" "\x6e\x26\x9b\x6f\x3a\x86\x4a\x36\xdf\x54\x97\xf9\xda\xcb\xa9\x66\xf3" "\x4d\xf7\x28\x7f\x26\x5b\x6e\xb5\xc7\x7c\xb3\x25\xe5\x4f\xb5\x4d\xeb" "\xb6\xde\x30\xce\xd2\x76\x5c\x0b\x45\x65\xa1\x23\x5d\xa9\x2c\x2c\xac" "\xfe\x26\x0f\x8d\xdf\xf5\x33\xc5\xc2\xf9\xb3\xe7\x9e\xbb\x30\xa2\x8a" "\x02\x77\xdc\x3f\x1f\x08\x21\xec\x17\x84\xc1\xc2\xd1\x30\xfa\x3a\x08" "\xb7\x1f\xea\x3b\x46\x7d\x04\x02\x58\x95\xdf\x2f\x5c\xe3\x62\x7e\x65" "\xe1\xf6\x34\x97\x36\xdd\x5f\xf9\x37\x9e\xa8\x74\x7f\x7f\xdf\xf2\x2b" "\x0e\xd0\x92\x6f\x7f\xf5\x7c\x73\xb9\xc3\xdb\x7f\x59\xf9\x6b\x28\x7f" "\xa4\xe5\xff\xea\xd2\x70\xcb\x67\xb2\x0c\xbc\x35\x7d\x69\x38\xf5\xb8" "\xd3\xd2\x7a\xa5\xfd\xe8\xee\x98\xce\xef\x23\xe4\xcf\x2f\x0d\xba\xff" "\xa7\xe5\xe5\xf7\x23\xaa\x7d\xd6\xb3\xd7\x7d\x84\x71\xb9\xbf\xd0\xab" "\x9e\x53\x1b\x5c\x8f\xf5\xea\x55\xff\x7c\xbb\xd8\xaa\xbe\x1e\xe3\x4a" "\xdc\x65\xbe\x91\xe5\xb7\xef\x3f\xf9\xff\x74\x5c\xfe\xc7\x40\x77\xff" "\x1a\xfb\xeb\xff\xdb\x36\x41\x1d\x04\x61\x13\x87\x4b\xbd\xf3\xea\xa3" "\x3e\x00\x01\x9b\x56\xfe\xdc\x5c\x3d\x4a\xf9\xf9\x73\x7d\x79\xfe\x6c" "\x49\xfe\xb6\x92\xfc\xb9\x92\xfc\xbb\x4a\xf2\xb7\x97\xe4\xc3\x24\xfb" "\xed\x8b\x3f\x09\xaf\x15\xad\xdf\xf9\xf9\x6f\xfa\x41\xaf\x87\xa5\xeb" "\x6c\xf7\xc4\xf8\x63\xe5\x55\x28\x7a\x26\xd6\x51\x7e\xfe\xdc\xef\xa0" "\x6e\xb7\x7c\x77\xf7\x18\x27\xbf\x3f\xf9\xcc\x99\xaf\x9c\x7e\xf6\xda" "\xea\xf3\xff\x45\x73\xfb\xbf\x15\xb7\xf7\xfd\x31\x5d\x8b\xfb\xd6\xd5" "\x38\x43\xba\x6e\x9a\x5f\x57\x6f\x3e\xfb\x5f\xeb\x2c\xa7\xd2\x63\xbe" "\x7b\xb3\xfa\xdc\xd3\x65\xfe\xc6\xeb\x5d\x9d\xf3\x15\xbb\x5a\xcb\x09" "\x6d\xc7\x99\x35\xf5\x98\xef\x7c\xdf\x8e\x5e\xf3\xed\xeb\x9c\x6f\xb5" "\xfa\xad\xab\xf8\x73\x31\x6c\xcb\xea\x9b\x9f\x9f\xdc\x95\x2d\x3f\x9d" "\x7f\xa4\xe3\x6a\xfa\xbc\xa6\xb3\xf5\xad\x66\xeb\x31\xd3\x51\x8f\xd6" "\x71\x65\x67\x8c\xf3\x7a\xc0\x7a\xa4\xed\xb1\xd7\xf3\xff\x69\xfb\x9c" "\x0f\xd5\xe2\xb9\xb3\xe7\xce\x3c\x16\xd3\x69\x3b\xfd\xe3\x54\x75\x76" "\x65\xfa\xc1\x0d\xae\x37\x70\xfb\xfa\x6d\xff\x33\x1f\x3a\xda\xff\x34" "\x4f\x73\xe7\x43\xb5\xd2\x7e\x5c\xd8\xd1\x9a\x5e\xb4\x1f\x17\x6a\xd9" "\xf4\xa5\x1e\xd3\x0f\xc5\x74\xfa\x9e\xfb\xee\xd4\x5c\x63\xfa\xc2\xa9" "\xef\x9f\x3b\x7d\xa7\x57\x1e\x26\xdc\x85\x97\x5f\xf9\xde\xc9\x73\xe7" "\xce\xfc\xd0\x8b\x1e\x2f\x56\xce\xdc\x37\x41\x35\xbc\xf0\x62\x43\x5f" "\x8c\xfa\xc8\x04\x0c\xdb\xe2\x8b\x2f\xfc\x60\xf1\xc2\xcb\xaf\x3c\x7a" "\xf6\x85\x93\xcf\x9f\x79\xfe\xcc\xf9\x43\x87\x0f\x1f\x5a\x5a\x3a\xfc" "\xd5\x43\xcb\x8b\x8d\xf3\xfa\xc5\xf6\xb3\x7b\x60\x2b\x69\x7d\xe9\x8f" "\xba\x26\x00\x00\x00\x00\x00\x00\x00\x00\x00\x40\xbf\x5e\x3a\x7e\xec" "\xda\x9f\xdf\xf9\xf2\xfb\xab\xed\xff\x5b\xed\xff\x52\xfb\xff\xf4\xe4" "\x6f\x6a\xff\xff\xe3\xac\xfd\x7f\x6a\xbf\x97\x8f\x03\x98\xda\x01\xee" "\x8c\x2d\xe4\xd7\xb4\xb7\xcf\x3a\x58\x9d\xc9\x96\x53\xed\xd1\xc2\x7d" "\x57\x56\xce\xee\xec\x7d\x9f\x88\x71\x73\x1c\xbf\xd8\xfe\x3f\x15\x97" "\xf7\xeb\x9a\xea\xb3\x27\x7b\x5f\xde\x7f\x6f\x9a\x2f\xeb\x4e\x60\x4d" "\x7f\x29\x33\x59\x1f\x24\xf9\x78\x81\x9f\x8e\xf1\xe5\x18\xff\xb2\xdb" "\x4a\xc2\x46\x29\xe6\xba\x4f\x8e\x71\x59\xff\xd6\x69\x5b\x4f\x0d\x82" "\xf5\x4b\x31\x9e\xd2\xff\x2d\x6d\x0d\xa9\x1f\x93\xd4\xfe\xbb\xac\x5f" "\xa7\x9d\x43\xae\x1f\xc3\xb1\x11\xcd\x09\x47\xbd\x8e\x40\x77\xff\xb8" "\x43\xfd\x7f\x37\xce\x13\x46\xdd\xcf\xb1\x30\xc2\x30\xb7\x09\xea\x20" "\x0c\x1a\xea\x75\xa3\x78\x00\x9b\xc3\xa8\xc7\xff\x4c\xd7\x3d\x53\x7c" "\xfe\x0f\xdf\xdc\xb6\x12\xd2\x6c\x37\x9e\xe8\x3c\x5e\xe6\xfd\x97\xc2" "\xed\xd8\xec\xe3\x4f\x2a\x7f\x6b\x8d\xff\xd9\x1c\xff\xae\xef\xe3\x5f" "\x36\x62\x5e\x6d\x7d\xe5\xfe\xfb\x67\xd7\xdf\x6f\x2b\x36\xec\xed\xb7" "\xfc\x7c\xfd\x53\x3f\xd0\xbb\x06\x2b\xff\xa3\x58\x7e\x5a\x9b\x87\x43" "\x7f\xe5\xd7\x7f\x91\x95\x9f\xdf\x10\xea\xd3\x7f\xb2\xf2\xef\xea\xb3" "\xfc\x35\xeb\xbf\x6f\x7d\xe5\xff\x37\x96\x9f\x3e\xb6\x47\x1e\xec\xb7" "\xfc\xd5\x1a\x17\x95\xce\x7a\x74\x5c\x37\x6e\x1b\x64\x23\xbf\x6e\x9c" "\xdc\xcc\xd6\xff\xf4\x7a\xd7\x7f\x9d\x03\x35\xde\x8a\xe5\xc3\x24\x1b" "\x97\x71\x66\x07\x52\x8c\xcf\xf8\xbf\xbd\xe4\xcf\x61\xa4\x61\x97\xd3" "\x81\x30\x3d\xe7\x90\x8f\x77\x32\x68\xfd\x3f\x1e\xe3\xf4\x3d\xb0\x3b" "\x5b\x7e\x51\xf2\xfd\x66\xfc\xdf\xf1\xf6\xb5\x18\x97\xed\x0f\x69\xfc" "\xdf\xb4\x3d\xd6\xba\xa4\x2b\x6d\xe9\x6a\x97\xcf\x76\x4b\x1e\x6b\x60" "\x8c\x7d\x30\xf6\xe3\xff\x8e\x7d\xb8\xb9\xa1\xe5\xd5\x67\x47\xbd\xbe" "\xc2\x26\x0a\xf5\x7a\x7d\xb8\x17\xb4\x4a\x8c\xb4\x70\x46\xfe\xf9\x8f" "\xfa\x77\xc2\xa8\xcb\x1f\xec\xf3\xdf\xf8\xda\xe6\xe3\xff\xe6\xe7\xf0" "\xf9\xf8\xbf\x79\x7e\x3e\xfe\x6f\x9e\x9f\x8f\xff\x9b\xe7\xe7\xe3\xeb" "\xe5\xf9\xf9\xf8\xbf\xf9\xe7\x99\x8f\xff\x9b\xe7\xef\xc9\x96\x9b\x8f" "\x0f\x3c\x5f\x92\xff\xc9\x92\xfc\xbd\x25\xf9\xf7\x95\xe4\xef\x2b\xc9" "\xff\x54\x49\xfe\x81\xd9\xff\x9f\x7f\x7f\xc9\xfb\x1f\x28\xc9\xbf\xb7" "\x24\xff\xc1\x6e\xf9\x2f\x7d\xab\x99\xff\x99\x92\xf7\x7f\xb6\x24\xff" "\xa1\x92\xfc\x47\x4a\xf2\x3f\x57\x92\xbf\xd5\xa5\xf6\x28\x93\xba\xfe" "\x30\xc9\x52\xbb\x0d\xfb\x3f\x4c\x9e\x74\xff\xa7\xd7\xfe\xbf\xab\x24" "\x1f\x18\x5f\x3f\x7d\xeb\xe0\x93\xcf\xfe\xe6\x3b\xb5\xd5\xf6\xff\x33" "\xcd\x2b\x0c\xe9\x3e\xde\xd1\x98\xae\xc6\xdf\xce\x3f\x8a\xe9\xfc\xbe" "\x77\x68\x4b\xaf\xe4\xbd\x13\xd3\x7f\xcd\xf2\x47\x7d\xbd\x09\x68\xc9" "\xfb\xcf\xc8\xbf\xdf\x1f\x2e\xc9\x07\xc6\x57\x7a\xce\xcb\xfe\x0d\x13" "\xa8\xe8\xde\x63\x4f\xbf\xfd\x56\xf5\x3a\xcf\x67\xbc\x7c\x3e\xc6\x5f" "\x88\xf1\x17\x63\xfc\x68\x8c\x17\x62\xbc\x18\xe3\x83\x31\x5e\xda\xa0" "\xfa\x31\x1c\x4f\xfe\xfa\x77\x47\x5e\x2b\x5a\xbf\xf7\x77\x64\xf9\xfd" "\x3e\x4f\x9e\xb7\x07\xca\xfb\x89\x3a\xd4\x67\x7d\xf2\xeb\x03\x83\x3e" "\xcf\xbe\xa7\xcf\x72\x86\x55\xfe\x3a\x9b\x83\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\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x8c\x4c\xa5\xf1\x77\x79\x79\xbe\x08\xe1\xca\xdb\x6f\x1c\x7b" "\xe6\xc4\xd9\xc5\x95\x29\x8f\x37\xe7\xa8\x35\xfe\x4e\xb7\xa5\xaa\xcd" "\xf7\x85\xf0\x58\x8c\xa7\x62\xfc\xf3\xf8\xe2\xe6\x87\xaf\x9e\x6a\x8f" "\x6f\xc5\xb8\x08\x4b\xa1\x08\x45\x73\x7a\x78\xfa\x46\xb3\xa4\xed\x21" "\x84\x8b\x61\x7f\xb8\x1a\x6a\x61\xef\x95\x6b\xaf\xbf\xbb\xf4\xd4\x89" "\x4b\xc7\x2f\x1f\x78\xef\xcd\x23\xd7\x87\xf7\x09\x00\x00\x00\xc0\xd6" "\xf7\xbf\x00\x00\x00\xff\xff\xd1\x3d\x16\x2b", 2646); syz_mount_image(/*fs=*/0x200000c0, /*dir=*/0x200001c0, /*flags=*/0x800000, /*opts=*/0x20000240, /*chdir=*/1, /*size=*/0xa56, /*img=*/0x20000c40); break; case 1: memcpy((void*)0x20000180, "./file2\000", 8); res = syscall(__NR_open, /*file=*/0x20000180ul, /*flags=*/0x14f942ul, /*mode=*/0ul); if (res != -1) r[0] = res; break; case 2: memcpy((void*)0x20000040, "./bus\000", 6); res = syscall(__NR_open, /*file=*/0x20000040ul, /*flags=*/0x147042ul, /*mode=*/0ul); if (res != -1) r[1] = res; break; case 3: syscall(__NR_ftruncate, /*fd=*/r[1], /*len=*/0x2007ffful); break; case 4: syscall(__NR_sendfile, /*fdout=*/r[0], /*fdin=*/r[1], /*off=*/0ul, /*count=*/0x1000000201004ul); break; case 5: memcpy((void*)0x20000100, "./file0\000", 8); res = syscall(__NR_open, /*file=*/0x20000100ul, /*flags=*/0x40c2ul, /*mode=*/0ul); if (res != -1) r[2] = res; break; case 6: memcpy( (void*)0x20000600, "\x34\xfd\x98\xaa\x1d\x0e\x7a\xde\xc9\x37\xa5\xf3\x31\xa7\x5f\x48\x79" "\x34\xf5\x02\x42\xa0\x75\x19\x44\x93\x69\x72\x89\x6c\x29\xa5\x06\x8c" "\x8e\xcb\xa1\xaa\x0a\x4e\x2a\x63\x1b\x51\x80\xe1\xfb\xde\x79\xf4\x50" "\x2d\xc4\xc4\xa1\xfb\xa9\xdc\xd9\xed\x83\xe6\x39\xae\xfa\x1b\x87\x63" "\x1c\x33\xd1\xa8\x2c\xb0\xc0\x03\x56\x76\xdd\xfe\xb0\xfe\x79\x84\xd7" "\x51\x9b\x0f\x83\x9d\x49\x7f\xc9\xd6\x4e\xf1\x4d\x1d\xe2\x22\x20\xff" "\x26\x23\xdf\x49\x50\x13\x4b\x9f\xb7\x34\xa5\x2a\xda\xd9\x5f\x13\x1c" "\xce\x36\x72\xa9\xd7\xd7\xb4\x00\xd2\xc6\x28\x10\xb5\xf2\x03\x51\x63" "\x93\x30\x94\x81\x07\xbf\x8d\x45\x34\xa0\x3a\xc3\x89\x45\x5c\x54\xd8" "\xeb\x4d\x60\x9b\x3e\x85\x8b\x72\x13\xb3\x8e\xb0\x1f\x0e\xea\xba\x37" "\x39\xae\x92\x79\x16\xe2\x8d\xa6\xa7\x9a\x3f\xd5\xe3\x2d\x30\xab\x30" "\xbf\x95\x9d\x45\x96\xe5\xff\xbf\xf6\x78\x9a\x65\x0b\x9e\x7d\x24\x8d" "\x1b\xa8\x68\x01\x23\x36\xa4\xf3\xef\x8f\xab\x07\xa8\xf5\xb8\x1b\xb0" "\xbc\x45\xb2\x17\x45\x38\x31\x5c\xa1\x2b\x7c\x72\x3b\x21\x57\x56\x25" "\x64\xa8\xa1\xf1\x9d\x28\x17\x9f\x8c\x56\x54\x48\xe0\xe9\x21\xb8\xc3" "\xe6\xfc\x4a\xda\xaf\xa8\xb9\x29\xad\x07\x7f\x63\x33\x25\xb6\xa6\xf7" "\x1a\x58\x6c\xab\xc4\x88\x3e\x03\xe1\x93\x15\xf9\x46\xb2\x77\x85\x85" "\x93\xa7\x36\x7e\x23\x22\x02\xfe\x9a\xd6\x56\xc6\x76\x8a\x15\x17\xda" "\x7f\x04\x98\xb4\x8c\xb0\x78\xe9\x29\xfb\x11\xdb\x0c\xc5\x51\xf7\x54" "\xbf\xfc\x48\x59\xdd\x89\xa3\x96\x91\x5c\xc8\x09\xb0\x7d\x44\x85\x73" "\x09\x84\x09\xea\x21\x37\x10\x56\xf6\x7e\xf4\x11\x4e\xc1\x05\x47\xf4" "\x98\xd2\x45\x13\xfe\x59\x43\x08\xbf\x02\x28\x68\xad\x21\xe8\x5b\xba" "\x81\x19\x42\xfd\xc4\x51\x61\xa1\xa8\xa7\xfe\x00\xd5\xc6\xb0\x5e\xd7" "\x95\x4f\x63\x1b\xbd\x12\xa5\xc9\xa5\xcf\xa5\x96\x5e\x05\x95\xde\x60" "\x8b\x04\xeb\xe0\x2b\x3f\xcb\xf3\xb9\xf5\x78\x07\xa1\xa7\xad\x85\x28" "\x99\x2e\x2e\xc6\x59\x49\xda\x2f\x4a\x04\x78\xdf\xd3\xae\x52\x63\x9c" "\x15\xd8\xae\xaa\x35\x1d\xa6\xd3\x93\xb5\x8c\x77\x21\x68\xfa\xe6\x04" "\xd0\x97\xfe\xf4\xd6\xb9\x36\x0e\xb1\x69\xa0\xb0\xee\x70\xcd\xc2\x24" "\x35\xa0\x03\xe6\x86\x98\xf6\x1b\x3b\x63\xb1\xf5\x10\x11\xbc\x8f\x4e" "\xf9\x44\xc1\xde\x82\x17\x85\xf6\x70\x12\x4a\x1c\x6e\xd1\x83\x35\xd6" "\x34\x12", 512); syscall(__NR_write, /*fd=*/r[2], /*buf=*/0x20000600ul, /*count=*/0x200ul); break; case 7: *(uint32_t*)0x20000380 = 0x16; *(uint16_t*)0x20000384 = 0x98; *(uint16_t*)0x20000386 = 0xfa00; *(uint64_t*)0x20000388 = 0; *(uint64_t*)0x20000390 = 0; *(uint32_t*)0x20000398 = -1; *(uint16_t*)0x2000039c = 0x30; *(uint16_t*)0x2000039e = 0; *(uint16_t*)0x200003a0 = 0x1b; *(uint16_t*)0x200003a2 = htobe16(0x7fff); *(uint32_t*)0x200003a4 = htobe32(0x6000); memcpy((void*)0x200003a8, "\x95\xa0\x91\xf4\x74\xa7\xff\x3e\x35\x65\x73\x26\x68\x1e\x04\xee", 16); *(uint64_t*)0x200003b8 = htobe64(4); *(uint64_t*)0x200003c0 = htobe64(0x3f); *(uint64_t*)0x200003c8 = 0x401; syscall(__NR_write, /*fd=*/r[2], /*data=*/0x20000380ul, /*len=*/0xa0ul); break; } } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=*/0x32ul, /*fd=*/-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000ul, /*prot=*/7ul, /*flags=*/0x32ul, /*fd=*/-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x21000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=*/0x32ul, /*fd=*/-1, /*offset=*/0ul); setup_802154(); use_temporary_dir(); loop(); return 0; }