// https://syzkaller.appspot.com/bug?id=0c81dbee1b873defa8f716f216e7a11653e96c0a // 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 #ifndef __NR_memfd_create #define __NR_memfd_create 279 #endif #ifndef __NR_mmap #define __NR_mmap 222 #endif #ifndef __NR_openat #define __NR_openat 56 #endif #ifndef __NR_write #define __NR_write 64 #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 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; } #define MAX_FDS 30 //% This code is derived from puff.{c,h}, found in the zlib development. The //% original files come with the following copyright notice: //% Copyright (C) 2002-2013 Mark Adler, all rights reserved //% version 2.3, 21 Jan 2013 //% This software is provided 'as-is', without any express or implied //% warranty. In no event will the author be held liable for any damages //% arising from the use of this software. //% Permission is granted to anyone to use this software for any purpose, //% including commercial applications, and to alter it and redistribute it //% freely, subject to the following restrictions: //% 1. The origin of this software must not be misrepresented; you must not //% claim that you wrote the original software. If you use this software //% in a product, an acknowledgment in the product documentation would be //% appreciated but is not required. //% 2. Altered source versions must be plainly marked as such, and must not be //% misrepresented as being the original software. //% 3. This notice may not be removed or altered from any source distribution. //% Mark Adler madler@alumni.caltech.edu //% BEGIN CODE DERIVED FROM puff.{c,h} #define MAXBITS 15 #define MAXLCODES 286 #define MAXDCODES 30 #define MAXCODES (MAXLCODES + MAXDCODES) #define FIXLCODES 288 struct puff_state { unsigned char* out; unsigned long outlen; unsigned long outcnt; const unsigned char* in; unsigned long inlen; unsigned long incnt; int bitbuf; int bitcnt; jmp_buf env; }; static int puff_bits(struct puff_state* s, int need) { long val = s->bitbuf; while (s->bitcnt < need) { if (s->incnt == s->inlen) longjmp(s->env, 1); val |= (long)(s->in[s->incnt++]) << s->bitcnt; s->bitcnt += 8; } s->bitbuf = (int)(val >> need); s->bitcnt -= need; return (int)(val & ((1L << need) - 1)); } static int puff_stored(struct puff_state* s) { s->bitbuf = 0; s->bitcnt = 0; if (s->incnt + 4 > s->inlen) return 2; unsigned len = s->in[s->incnt++]; len |= s->in[s->incnt++] << 8; if (s->in[s->incnt++] != (~len & 0xff) || s->in[s->incnt++] != ((~len >> 8) & 0xff)) return -2; if (s->incnt + len > s->inlen) return 2; if (s->outcnt + len > s->outlen) return 1; for (; len--; s->outcnt++, s->incnt++) { if (s->in[s->incnt]) s->out[s->outcnt] = s->in[s->incnt]; } return 0; } struct puff_huffman { short* count; short* symbol; }; static int puff_decode(struct puff_state* s, const struct puff_huffman* h) { int first = 0; int index = 0; int bitbuf = s->bitbuf; int left = s->bitcnt; int code = first = index = 0; int len = 1; short* next = h->count + 1; while (1) { while (left--) { code |= bitbuf & 1; bitbuf >>= 1; int count = *next++; if (code - count < first) { s->bitbuf = bitbuf; s->bitcnt = (s->bitcnt - len) & 7; return h->symbol[index + (code - first)]; } index += count; first += count; first <<= 1; code <<= 1; len++; } left = (MAXBITS + 1) - len; if (left == 0) break; if (s->incnt == s->inlen) longjmp(s->env, 1); bitbuf = s->in[s->incnt++]; if (left > 8) left = 8; } return -10; } static int puff_construct(struct puff_huffman* h, const short* length, int n) { int len; for (len = 0; len <= MAXBITS; len++) h->count[len] = 0; int symbol; for (symbol = 0; symbol < n; symbol++) (h->count[length[symbol]])++; if (h->count[0] == n) return 0; int left = 1; for (len = 1; len <= MAXBITS; len++) { left <<= 1; left -= h->count[len]; if (left < 0) return left; } short offs[MAXBITS + 1]; offs[1] = 0; for (len = 1; len < MAXBITS; len++) offs[len + 1] = offs[len] + h->count[len]; for (symbol = 0; symbol < n; symbol++) if (length[symbol] != 0) h->symbol[offs[length[symbol]]++] = symbol; return left; } static int puff_codes(struct puff_state* s, const struct puff_huffman* lencode, const struct puff_huffman* distcode) { static const short lens[29] = {3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258}; static const short lext[29] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0}; static const short dists[30] = { 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577}; static const short dext[30] = {0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13}; int symbol; do { symbol = puff_decode(s, lencode); if (symbol < 0) return symbol; if (symbol < 256) { if (s->outcnt == s->outlen) return 1; if (symbol) s->out[s->outcnt] = symbol; s->outcnt++; } else if (symbol > 256) { symbol -= 257; if (symbol >= 29) return -10; int len = lens[symbol] + puff_bits(s, lext[symbol]); symbol = puff_decode(s, distcode); if (symbol < 0) return symbol; unsigned dist = dists[symbol] + puff_bits(s, dext[symbol]); if (dist > s->outcnt) return -11; if (s->outcnt + len > s->outlen) return 1; while (len--) { if (dist <= s->outcnt && s->out[s->outcnt - dist]) s->out[s->outcnt] = s->out[s->outcnt - dist]; s->outcnt++; } } } while (symbol != 256); return 0; } static int puff_fixed(struct puff_state* s) { static int virgin = 1; static short lencnt[MAXBITS + 1], lensym[FIXLCODES]; static short distcnt[MAXBITS + 1], distsym[MAXDCODES]; static struct puff_huffman lencode, distcode; if (virgin) { lencode.count = lencnt; lencode.symbol = lensym; distcode.count = distcnt; distcode.symbol = distsym; short lengths[FIXLCODES]; int symbol; for (symbol = 0; symbol < 144; symbol++) lengths[symbol] = 8; for (; symbol < 256; symbol++) lengths[symbol] = 9; for (; symbol < 280; symbol++) lengths[symbol] = 7; for (; symbol < FIXLCODES; symbol++) lengths[symbol] = 8; puff_construct(&lencode, lengths, FIXLCODES); for (symbol = 0; symbol < MAXDCODES; symbol++) lengths[symbol] = 5; puff_construct(&distcode, lengths, MAXDCODES); virgin = 0; } return puff_codes(s, &lencode, &distcode); } static int puff_dynamic(struct puff_state* s) { static const short order[19] = {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; int nlen = puff_bits(s, 5) + 257; int ndist = puff_bits(s, 5) + 1; int ncode = puff_bits(s, 4) + 4; if (nlen > MAXLCODES || ndist > MAXDCODES) return -3; short lengths[MAXCODES]; int index; for (index = 0; index < ncode; index++) lengths[order[index]] = puff_bits(s, 3); for (; index < 19; index++) lengths[order[index]] = 0; short lencnt[MAXBITS + 1], lensym[MAXLCODES]; struct puff_huffman lencode = {lencnt, lensym}; int err = puff_construct(&lencode, lengths, 19); if (err != 0) return -4; index = 0; while (index < nlen + ndist) { int symbol; int len; symbol = puff_decode(s, &lencode); if (symbol < 0) return symbol; if (symbol < 16) lengths[index++] = symbol; else { len = 0; if (symbol == 16) { if (index == 0) return -5; len = lengths[index - 1]; symbol = 3 + puff_bits(s, 2); } else if (symbol == 17) symbol = 3 + puff_bits(s, 3); else symbol = 11 + puff_bits(s, 7); if (index + symbol > nlen + ndist) return -6; while (symbol--) lengths[index++] = len; } } if (lengths[256] == 0) return -9; err = puff_construct(&lencode, lengths, nlen); if (err && (err < 0 || nlen != lencode.count[0] + lencode.count[1])) return -7; short distcnt[MAXBITS + 1], distsym[MAXDCODES]; struct puff_huffman distcode = {distcnt, distsym}; err = puff_construct(&distcode, lengths + nlen, ndist); if (err && (err < 0 || ndist != distcode.count[0] + distcode.count[1])) return -8; return puff_codes(s, &lencode, &distcode); } static int puff(unsigned char* dest, unsigned long* destlen, const unsigned char* source, unsigned long sourcelen) { struct puff_state s = { .out = dest, .outlen = *destlen, .outcnt = 0, .in = source, .inlen = sourcelen, .incnt = 0, .bitbuf = 0, .bitcnt = 0, }; int err; if (setjmp(s.env) != 0) err = 2; else { int last; do { last = puff_bits(&s, 1); int type = puff_bits(&s, 2); err = type == 0 ? puff_stored(&s) : (type == 1 ? puff_fixed(&s) : (type == 2 ? puff_dynamic(&s) : -1)); if (err != 0) break; } while (!last); } *destlen = s.outcnt; return err; } //% END CODE DERIVED FROM puff.{c,h} #define ZLIB_HEADER_WIDTH 2 static int puff_zlib_to_file(const unsigned char* source, unsigned long sourcelen, int dest_fd) { if (sourcelen < ZLIB_HEADER_WIDTH) return 0; source += ZLIB_HEADER_WIDTH; sourcelen -= ZLIB_HEADER_WIDTH; const unsigned long max_destlen = 132 << 20; void* ret = mmap(0, max_destlen, PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANON, -1, 0); if (ret == MAP_FAILED) return -1; unsigned char* dest = (unsigned char*)ret; unsigned long destlen = max_destlen; int err = puff(dest, &destlen, source, sourcelen); if (err) { munmap(dest, max_destlen); errno = -err; return -1; } if (write(dest_fd, dest, destlen) != (ssize_t)destlen) { munmap(dest, max_destlen); return -1; } return munmap(dest, max_destlen); } static int setup_loop_device(unsigned char* data, unsigned long size, const char* loopname, int* loopfd_p) { int err = 0, loopfd = -1; int memfd = syscall(__NR_memfd_create, "syzkaller", 0); if (memfd == -1) { err = errno; goto error; } if (puff_zlib_to_file(data, size, memfd)) { err = errno; goto error_close_memfd; } loopfd = open(loopname, O_RDWR); if (loopfd == -1) { err = errno; goto error_close_memfd; } if (ioctl(loopfd, LOOP_SET_FD, memfd)) { if (errno != EBUSY) { err = errno; goto error_close_loop; } ioctl(loopfd, LOOP_CLR_FD, 0); usleep(1000); if (ioctl(loopfd, LOOP_SET_FD, memfd)) { err = errno; goto error_close_loop; } } close(memfd); *loopfd_p = loopfd; return 0; error_close_loop: close(loopfd); error_close_memfd: close(memfd); error: errno = err; return -1; } static void reset_loop_device(const char* loopname) { int loopfd = open(loopname, O_RDWR); if (loopfd == -1) { return; } if (ioctl(loopfd, LOOP_CLR_FD, 0)) { } close(loopfd); } static long syz_mount_image(volatile long fsarg, volatile long dir, volatile long flags, volatile long optsarg, volatile long change_dir, volatile unsigned long size, volatile long image) { unsigned char* data = (unsigned char*)image; int res = -1, err = 0, need_loop_device = !!size; char* mount_opts = (char*)optsarg; char* target = (char*)dir; char* fs = (char*)fsarg; char* source = NULL; char loopname[64]; if (need_loop_device) { int loopfd; memset(loopname, 0, sizeof(loopname)); snprintf(loopname, sizeof(loopname), "/dev/loop%llu", procid); if (setup_loop_device(data, size, loopname, &loopfd) == -1) return -1; close(loopfd); source = loopname; } mkdir(target, 0777); char opts[256]; memset(opts, 0, sizeof(opts)); if (strlen(mount_opts) > (sizeof(opts) - 32)) { } strncpy(opts, mount_opts, sizeof(opts) - 32); if (strcmp(fs, "iso9660") == 0) { flags |= MS_RDONLY; } else if (strncmp(fs, "ext", 3) == 0) { bool has_remount_ro = false; char* remount_ro_start = strstr(opts, "errors=remount-ro"); if (remount_ro_start != NULL) { char after = *(remount_ro_start + strlen("errors=remount-ro")); char before = remount_ro_start == opts ? '\0' : *(remount_ro_start - 1); has_remount_ro = ((before == '\0' || before == ',') && (after == '\0' || after == ',')); } if (strstr(opts, "errors=panic") || !has_remount_ro) strcat(opts, ",errors=continue"); } else if (strcmp(fs, "xfs") == 0) { strcat(opts, ",nouuid"); } else if (strncmp(fs, "gfs2", 4) == 0 && (strstr(opts, "errors=panic") || strstr(opts, "debug"))) { strcat(opts, ",errors=withdraw"); } res = mount(source, target, fs, flags, opts); if (res == -1) { err = errno; goto error_clear_loop; } res = open(target, O_RDONLY | O_DIRECTORY); if (res == -1) { err = errno; goto error_clear_loop; } if (change_dir) { res = chdir(target); if (res == -1) { err = errno; } } error_clear_loop: if (need_loop_device) reset_loop_device(loopname); errno = err; return res; } static void setup_gadgetfs(); static void setup_binderfs(); static void setup_fusectl(); static void sandbox_common_mount_tmpfs(void) { write_file("/proc/sys/fs/mount-max", "100000"); if (mkdir("./syz-tmp", 0777)) exit(1); if (mount("", "./syz-tmp", "tmpfs", 0, NULL)) exit(1); if (mkdir("./syz-tmp/newroot", 0777)) exit(1); if (mkdir("./syz-tmp/newroot/dev", 0700)) exit(1); unsigned bind_mount_flags = MS_BIND | MS_REC | MS_PRIVATE; if (mount("/dev", "./syz-tmp/newroot/dev", NULL, bind_mount_flags, NULL)) exit(1); if (mkdir("./syz-tmp/newroot/proc", 0700)) exit(1); if (mount("syz-proc", "./syz-tmp/newroot/proc", "proc", 0, NULL)) exit(1); if (mkdir("./syz-tmp/newroot/selinux", 0700)) exit(1); const char* selinux_path = "./syz-tmp/newroot/selinux"; if (mount("/selinux", selinux_path, NULL, bind_mount_flags, NULL)) { if (errno != ENOENT) exit(1); if (mount("/sys/fs/selinux", selinux_path, NULL, bind_mount_flags, NULL) && errno != ENOENT) exit(1); } if (mkdir("./syz-tmp/newroot/sys", 0700)) exit(1); if (mount("/sys", "./syz-tmp/newroot/sys", 0, bind_mount_flags, NULL)) exit(1); if (mount("/sys/kernel/debug", "./syz-tmp/newroot/sys/kernel/debug", NULL, bind_mount_flags, NULL) && errno != ENOENT) exit(1); if (mount("/sys/fs/smackfs", "./syz-tmp/newroot/sys/fs/smackfs", NULL, bind_mount_flags, NULL) && errno != ENOENT) exit(1); if (mount("/proc/sys/fs/binfmt_misc", "./syz-tmp/newroot/proc/sys/fs/binfmt_misc", NULL, bind_mount_flags, NULL) && errno != ENOENT) exit(1); if (mkdir("./syz-tmp/newroot/syz-inputs", 0700)) exit(1); if (mount("/syz-inputs", "./syz-tmp/newroot/syz-inputs", NULL, bind_mount_flags | MS_RDONLY, NULL) && errno != ENOENT) exit(1); if (mkdir("./syz-tmp/pivot", 0777)) exit(1); if (syscall(SYS_pivot_root, "./syz-tmp", "./syz-tmp/pivot")) { if (chdir("./syz-tmp")) exit(1); } else { if (chdir("/")) exit(1); if (umount2("./pivot", MNT_DETACH)) exit(1); } if (chroot("./newroot")) exit(1); if (chdir("/")) exit(1); setup_gadgetfs(); setup_binderfs(); setup_fusectl(); } static void setup_gadgetfs() { if (mkdir("/dev/gadgetfs", 0777)) { } if (mount("gadgetfs", "/dev/gadgetfs", "gadgetfs", 0, NULL)) { } } static void setup_fusectl() { if (mount(0, "/sys/fs/fuse/connections", "fusectl", 0, 0)) { } } static void setup_binderfs() { if (mkdir("/dev/binderfs", 0777)) { } if (mount("binder", "/dev/binderfs", "binder", 0, NULL)) { } } static void loop(); static void sandbox_common() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); if (getppid() == 1) exit(1); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = (200 << 20); setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 32 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 136 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); if (unshare(CLONE_NEWNS)) { } if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL)) { } if (unshare(CLONE_NEWIPC)) { } if (unshare(0x02000000)) { } if (unshare(CLONE_NEWUTS)) { } if (unshare(CLONE_SYSVSEM)) { } typedef struct { const char* name; const char* value; } sysctl_t; static const sysctl_t sysctls[] = { {"/proc/sys/kernel/shmmax", "16777216"}, {"/proc/sys/kernel/shmall", "536870912"}, {"/proc/sys/kernel/shmmni", "1024"}, {"/proc/sys/kernel/msgmax", "8192"}, {"/proc/sys/kernel/msgmni", "1024"}, {"/proc/sys/kernel/msgmnb", "1024"}, {"/proc/sys/kernel/sem", "1024 1048576 500 1024"}, }; unsigned i; for (i = 0; i < sizeof(sysctls) / sizeof(sysctls[0]); i++) write_file(sysctls[i].name, sysctls[i].value); } static int wait_for_loop(int pid) { if (pid < 0) exit(1); int status = 0; while (waitpid(-1, &status, __WALL) != pid) { } return WEXITSTATUS(status); } static void drop_caps(void) { struct __user_cap_header_struct cap_hdr = {}; struct __user_cap_data_struct cap_data[2] = {}; cap_hdr.version = _LINUX_CAPABILITY_VERSION_3; cap_hdr.pid = getpid(); if (syscall(SYS_capget, &cap_hdr, &cap_data)) exit(1); const int drop = (1 << CAP_SYS_PTRACE) | (1 << CAP_SYS_NICE); cap_data[0].effective &= ~drop; cap_data[0].permitted &= ~drop; cap_data[0].inheritable &= ~drop; if (syscall(SYS_capset, &cap_hdr, &cap_data)) exit(1); } static int do_sandbox_none(void) { if (unshare(CLONE_NEWPID)) { } int pid = fork(); if (pid != 0) return wait_for_loop(pid); sandbox_common(); drop_caps(); if (unshare(CLONE_NEWNET)) { } write_file("/proc/sys/net/ipv4/ping_group_range", "0 65535"); sandbox_common_mount_tmpfs(); loop(); exit(1); } #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 close_fds() { for (int fd = 3; fd < MAX_FDS; fd++) close(fd); } static const char* setup_usb() { if (chmod("/dev/raw-gadget", 0666)) return "failed to chmod /dev/raw-gadget"; return NULL; } 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(); close_fds(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } 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$nilfs2 arguments: [ // fs: ptr[in, buffer] { // buffer: {6e 69 6c 66 73 32 00} (length 0x7) // } // dir: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 30 00} (length 0x8) // } // flags: mount_flags = 0x3200400 (8 bytes) // opts: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYRES8: ANYRES8 (resource) // } // } // } // chdir: int8 = 0x3 (1 bytes) // size: len = 0xa73 (8 bytes) // img: ptr[in, buffer] { // buffer: (compressed buffer with length 0xa73) // } // ] // returns fd_dir memcpy((void*)0x20000000, "nilfs2\000", 7); memcpy((void*)0x20000040, "./file0\000", 8); *(uint8_t*)0x20000140 = 0; memcpy( (void*)0x20003cc0, "\x78\x9c\xec\xdd\x4d\x8c\x1b\x57\x01\x00\xe0\x37\xde\xf5\x26\x9b\xa4\xc4" "\x29\x09\x5d\x92\xd0\x26\xfc\xb4\xe5\xa7\xbb\xcd\x66\x09\x3f\x11\x34\x55" "\x73\x21\x6a\x2a\x6e\x95\x2a\x2e\x51\x9a\x96\x88\x34\x20\x52\x09\x5a\x55" "\x22\xc9\x89\x1b\xad\xaa\x70\x85\x22\x4e\xe5\x50\x01\x42\x6a\x2f\x28\xea" "\x89\x4b\x25\x1a\x89\x4b\x4f\x85\x03\x07\xa2\x20\x55\xe2\x00\x85\xc4\x68" "\xbd\xef\x79\xc7\x2f\x76\xc7\xfb\x93\xb5\xbd\xfe\x3e\xe9\xed\xf3\x9b\x37" "\xf6\x7b\x33\x3b\x33\x1e\xcf\xcc\x7b\x2f\x00\x63\xab\xd6\xfa\xbb\xb0\x30" "\x53\x84\x70\xe5\xad\x57\x8f\xff\xe3\xfe\xbf\x4f\x2f\x4e\x79\xa4\x3d\x47" "\xa3\xf5\x77\xb2\x94\xaa\x87\x10\x8a\x98\x9e\xcc\x3e\xef\xfd\x89\xa5\xf8" "\xe6\x07\x2f\x9d\xee\x16\x17\x61\xbe\xf5\x37\xa5\xc3\x13\x37\xda\xef\xdd" "\x1e\x42\xb8\x18\x0e\x84\xab\xa1\x11\xf6\x5e\xb9\xf6\xca\x3b\xf3\x8f\x9f" "\xbc\x74\xe2\xf2\xc1\x77\x5f\x3f\x7a\xfd\xce\x2c\x3d\x00\x00\x8c\x97\x6f" "\x5f\x3d\xba\xb0\xe7\xaf\x7f\xde\xb7\xeb\xc3\x37\xee\x3d\x16\xb6\xb4\xa7" "\xa7\xf3\xf3\x46\x4c\xef\x88\xe7\xfd\xc7\xe2\x89\x7f\x3a\xff\xaf\x85\xce" "\x74\x51\x0a\x65\x53\xd9\x7c\x93\x31\xd4\xb2\xf9\x26\xba\xcc\x57\x2e\xa7" "\x9e\xcd\x37\xd9\xa3\xfc\xa9\xec\x73\xeb\xed\xfc\x7d\x1d\xf3\x6d\xa9\x28" "\x7f\xa2\x34\xad\xdb\x72\xc3\x28\x4b\xdb\x71\x23\x14\xb5\xd9\x8e\x74\xad" "\x36\x3b\xbb\xf4\x9b\x3c\xb4\x7e\xd7\x4f\x15\xb3\xe7\xcf\x9e\x7b\xe6\xc2" "\x80\x2a\x0a\xac\xbb\x7f\xdd\x17\x42\x38\x20\xac\x34\x34\x9b\xcd\x9f\xb4" "\x56\xe0\x10\xd4\x45\x10\x56\x1b\x9a\x3b\x07\x7d\x04\x02\x58\x92\xdf\x2f" "\xbc\xcd\xc5\xfc\xca\xc2\xda\xb4\x3f\x6d\xb2\xbf\xf2\x6f\x3c\x5a\xeb\xfe" "\x7e\x58\x07\x1b\xbd\xfd\x2b\x7f\xb4\xca\xff\xf5\x25\x47\x1c\xd6\xcf\x66" "\xdd\x9a\xd2\x72\xa5\xfd\x68\x47\x4c\xe7\xf7\x11\xf2\xe7\x97\x56\xba\xff" "\xa7\xcf\xcb\xef\x47\xd4\xfb\xac\x67\xaf\xfb\x08\xa3\x72\x7f\xa1\x57\x3d" "\x27\x36\xb8\x1e\xab\xd5\xab\xfe\xf9\x76\xb1\x59\x7d\x23\xc6\x69\x3d\x7c" "\x33\xcb\x2f\xef\x3f\xf9\xff\x74\x54\xfe\xc7\x40\x77\xff\xde\xa8\xeb\xff" "\xaf\x4d\x0f\xfc\x5a\xe7\x62\x38\x30\x04\x75\xd8\xd4\xa1\x3e\x04\x75\x10" "\xfa\x0e\xcd\x41\x1f\x80\x80\xa1\xb5\xfc\xdc\xdc\x92\x66\x94\xf2\xf3\xe7" "\xfa\xf2\xfc\x2d\x15\xf9\x5b\x2b\xf2\xa7\x2b\xf2\xb7\x55\xe4\x6f\xaf\xc8" "\x87\x71\xf6\xfb\xe7\x7f\x16\x5e\x2e\x96\x7f\xe7\xe7\xbf\xe9\x57\x7a\x3d" "\x2c\x5d\x67\xbb\x2b\xc6\x1f\x5b\x61\x7d\xf2\xeb\x91\x2b\x2d\x3f\x7f\xee" "\x77\xa5\xd6\x5a\x7e\xfe\x3c\x31\x0c\xb3\x37\x4f\x3d\x79\xe6\xab\x4f\x3f" "\x75\x6d\xe9\xf9\xff\xa2\xbd\xfd\xdf\x8a\xdb\xfb\x81\x98\x6e\xc4\x7d\xeb" "\x6a\x9c\x21\x5d\x2f\xcc\xaf\xab\xb7\x9f\xfd\x6f\x74\x96\x53\xeb\x31\xdf" "\xdd\x59\x7d\xee\xba\x6d\xfe\xe6\x52\x89\xbb\x3b\xe7\x2b\x76\x2f\x7f\x4e" "\x28\x1d\x67\x6e\xab\xc7\x4c\xe7\xfb\x76\xf6\x9a\x6f\x7f\xe7\x7c\x8d\x6c" "\xbe\xe9\x18\xb6\x66\xf5\xcd\xcf\x4f\xb6\x65\xef\x4b\xe7\x1f\xe9\xb8\x9a" "\xd6\xd7\x64\xb6\xbc\xf5\x6c\x39\xa6\xb2\x7a\xa4\xe3\xca\xae\x18\xe7\xf5" "\x80\xd5\x48\xdb\x63\xaf\xe7\xff\xd3\xf6\x39\x13\xea\xc5\x33\x67\xcf\x9d" "\x79\x38\xa6\xd3\x76\xfa\xa7\x89\xfa\x96\xc5\xe9\x87\xca\x1f\xfa\x9b\x8d" "\xa9\x3b\xb0\x36\xfd\xb6\xff\x99\x09\x9d\xed\x7f\x76\xb4\xa7\xd7\x6b\xe5" "\xe3\xc2\xce\xe5\xe9\x45\xf9\xb8\xd0\xc8\xa6\xcf\x2f\x25\xdb\xb7\xc9\xd3" "\xf4\xc3\x31\x9d\xbe\xe7\xbe\x3b\x31\xdd\x9a\x3e\x7b\xfa\xfb\xe7\x9e\x5e" "\xef\x85\x87\x31\x77\xe1\x85\x17\xbf\x77\xea\xdc\xb9\x33\x3f\xf4\x22\xbd" "\x98\xb6\x5a\xbc\xf0\xa2\xea\xc8\xb1\x59\x9f\x1c\x84\xf1\x31\xf7\xfc\x73" "\x3f\x98\xbb\xf0\xc2\x8b\x0f\x9d\x7d\xee\xd4\xb3\x67\x9e\x3d\x73\xfe\xf0" "\x91\x23\x87\xe7\xe7\x8f\x7c\xed\xf0\xc2\x5c\xeb\xbc\x7e\xae\x7c\x76\x0f" "\x6c\x26\xcb\x5f\xfa\x83\xae\x09\x00\x00\x00\x00\x00\x00\x00\x00\x00\xd0" "\xaf\x1f\x9d\x38\x7e\xed\x2f\x6f\x7f\xe5\xbd\xa5\xf6\xff\xcb\xed\xff\x52" "\xfb\xff\xf4\xe4\x6f\x6a\xff\xff\xd3\xac\xfd\x7f\xde\x4e\x3e\xb5\x0a\x48" "\xed\x00\x77\x75\xc9\x6f\x8d\xbb\xf7\x66\x67\x3d\xa6\xb2\xf9\xea\x31\x7c" "\x3c\xab\xef\xee\xac\x9c\x3d\xd9\xfb\x3e\x11\xe3\xf6\x38\x7e\xb1\xfd\x7f" "\x6a\x6f\x9f\xf7\xeb\x9a\xea\x73\x4f\x36\x3d\xef\xbf\x37\xcd\x97\x75\x27" "\x70\x5b\x7f\x29\x53\x59\x1f\x24\xed\xf1\x02\x63\x83\xfd\x4f\xc7\xf4\xe5" "\x18\xff\x2a\xc0\x00\x15\xd3\xdd\x27\xc7\xb8\xaa\x7f\xeb\xb4\xad\xa7\xfe" "\x29\xf4\x4b\x31\x9a\xd2\xff\x2d\x6d\x0d\xa9\x1f\x93\xd4\xfe\xbb\x57\xbf" "\x4e\xe9\xf8\xbf\x6b\x03\xea\xc8\xfa\xdb\x88\xe6\x84\x83\x5e\x46\xa0\xbb" "\x7f\x0e\xfd\xf8\x9f\xa5\x33\xf1\x81\xd7\xe5\x23\x43\xb3\x39\xf8\x3a\xac" "\x3d\x0c\xff\x7a\x16\xd6\x31\x34\x9b\x46\xf1\x00\x86\xc3\xa0\xc7\xff\x4c" "\xd7\x3d\x53\x7c\xfe\x8f\xdf\xda\xba\x18\xd2\x6c\x37\x1e\xed\x3c\x5e\xe6" "\xfd\x97\xc2\x5a\x0c\xfb\xf8\x93\xca\xdf\x5c\xe3\x7f\xb6\xc7\xbf\xeb\xeb" "\xf8\xd7\xa5\x77\xf5\x8e\x7e\x9e\xfb\x1f\x5d\xe1\x3f\xbf\xb8\xfe\x5e\xa9" "\xd8\xb0\xb7\xdf\xe3\x6f\xbe\xfc\xa9\x1f\xe8\xdd\xd5\x65\x96\x7d\x18\xcb" "\x4f\xcb\xff\x40\xe8\xaf\xfc\xe6\x6b\x59\xf9\xf9\x0d\xa1\x3e\xfd\x37\x2b" "\x7f\x5b\x9f\xe5\xdf\xb6\xfc\xfb\x57\x57\xfe\xff\x62\xf9\x69\xb5\x3d\xf8" "\x99\x7e\xcb\x5f\xaa\x71\x51\xeb\xac\x47\x7e\xdd\x38\xdd\xff\xcb\xaf\x1b" "\x27\x37\xb3\xe5\x4f\x7d\x7b\xae\x78\xf9\x57\x39\x50\xe3\xad\x58\x3e\x8c" "\xb3\xde\xe3\xcc\xf6\x3b\x82\xed\x70\x1a\x95\xf1\x7f\x7b\xc9\x9f\xc3\xf8" "\x72\x4c\xa7\x03\x61\x7a\xce\x21\xff\x46\x5e\x69\xfd\xd3\xf3\x15\xe9\x7b" "\x60\x4f\xf6\xf9\x45\xc5\xf7\xdb\xa8\x8c\x53\xdc\xcb\xb8\x8f\xff\xfb\xf5" "\x18\x57\xed\x0f\x69\xfc\xdf\xb4\x3d\x36\xba\xa4\x6b\xa5\x74\xbd\xcb\xba" "\x1d\xf5\x6d\x05\x36\x9b\xf7\x87\xfe\xfe\xdf\x88\x85\x8b\x43\x50\x07\x61" "\x48\xc3\x70\x8c\x81\x5d\x0e\xcd\x66\x73\xa0\x1d\x79\xeb\x45\x7c\xb0\x06" "\xbd\xfe\x07\x7d\xf7\x79\xd0\xe5\x0f\x7a\xfd\x57\xc9\xc7\xff\xcd\xcf\xe1" "\xf3\xf1\x7f\x6b\xd9\x0f\x88\x7c\xfc\xdf\xfc\xfd\xf9\xf8\xbf\x79\x7e\x3e" "\xbe\x5e\x9e\x9f\x8f\xff\x9b\xaf\xcf\x7c\xfc\xdf\x3c\xff\x9e\xec\x73\xf3" "\x2b\xd8\x33\x15\xf9\x9f\xac\xc8\xdf\x5b\x91\xbf\x6f\x39\x7f\xba\x5b\xfe" "\xfe\x8a\xf7\x7f\xaa\x22\xff\x60\x45\xfe\xbd\x15\xf9\xf7\x55\xe4\xdf\x5d" "\x91\x3f\x51\x91\xff\xd9\x8a\xfc\xcf\x55\xe4\xdf\x5f\x91\xff\x60\x45\xfe" "\xe7\x2b\xf2\x37\xbb\x56\x7b\x94\xd2\x4e\x35\x6e\xcb\x0f\xe3\x2c\x6f\x9f" "\x67\xff\x87\xf1\x91\xee\xff\xf4\xda\xff\x77\x57\xe4\x03\xa3\xeb\xe7\x6f" "\x1c\x7a\xec\xa9\xdf\x7d\xa7\xb1\xd4\xfe\x7f\xaa\xfd\x7b\x2d\xdd\xc7\x3b" "\x16\xd3\xf5\xf8\xdb\xf9\xc7\x31\x9d\xdf\xf7\x0e\xa5\xf4\x62\xde\xdb\x31" "\xfd\xb7\x2c\x7f\xd8\xaf\x77\xc0\x38\xc9\xfb\xcf\xc8\xbf\xdf\x1f\xa8\xc8" "\x07\x46\x57\x7a\xce\xcb\xfe\x0d\x63\xa8\xe8\xde\x63\x4f\x7e\xbf\xad\x57" "\xbf\x55\xbd\xce\xf3\x19\x2d\x5f\x88\xf1\x17\x63\xfc\xa5\x18\x3f\x14\xe3" "\xd9\x18\xcf\xc5\xf8\x50\x8c\xe7\x37\xa8\x7e\xdc\x19\x8f\xfd\xf6\x0f\x47" "\x5f\x2e\x96\x7f\xef\xef\xcc\xf2\xfb\x7d\x9e\x3c\x6f\x0f\x94\xf7\x13\x75" "\xb8\xcf\xfa\xe4\xd7\x07\x56\xfa\x3c\x7b\xde\x8f\xdf\x4a\xad\xb5\xfc\x55" "\x36\x07\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x18\x98\x5a\xeb\xef\xc2\xc2\x4c\x11\xc2" "\x95\xb7\x5e\x3d\xfe\xe4\xc9\xb3\x73\x8b\x53\x1e\x69\xcf\xd1\x68\xfd\x9d" "\x2c\xa5\xea\xed\xf7\x85\xf0\x70\x8c\x27\x62\xfc\xcb\xf8\xe2\xe6\x07\x2f" "\x9d\x2e\xc7\xb7\x62\x5c\x84\xf9\x50\x84\xa2\x3d\x3d\x3c\x71\xa3\x5d\xd2" "\xf6\x10\xc2\xc5\x70\x20\x5c\x0d\x8d\xb0\xf7\xca\xb5\x57\xde\x99\x7f\xfc" "\xe4\xa5\x13\x97\x0f\xbe\xfb\xfa\xd1\xeb\x77\x6e\x0d\x00\x00\x00\xc0\xe6" "\xf7\xff\x00\x00\x00\xff\xff\xa6\x52\x1b\x08", 2675); syz_mount_image( /*fs=*/0x20000000, /*dir=*/0x20000040, /*flags=MS_LAZYTIME|MS_STRICTATIME|MS_RELATIME|MS_NOATIME*/ 0x3200400, /*opts=*/0x20000140, /*chdir=*/3, /*size=*/0xa73, /*img=*/0x20003cc0); // openat arguments: [ // fd: fd_dir (resource) // file: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 32 00} (length 0x8) // } // flags: open_flags = 0x193042 (4 bytes) // mode: open_mode = 0x0 (2 bytes) // ] // returns fd memcpy((void*)0x20000100, "./file2\000", 8); res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x20000100ul, /*flags=O_SYNC|O_DIRECT|O_CREAT|O_CLOEXEC|FASYNC|0x2*/ 0x193042, /*mode=*/0); if (res != -1) r[0] = res; // write$FUSE_INIT arguments: [ // fd: fd_fuse (resource) // arg: ptr[in, fuse_out_t[fuse_unique, fuse_init_out]] { // fuse_out_t[fuse_unique, fuse_init_out] { // len: len = 0x50 (4 bytes) // err: fuse_errors = 0x0 (4 bytes) // unique: fuse_unique (resource) // payload: fuse_init_out { // major: const = 0x7 (4 bytes) // minor: const = 0x2b (4 bytes) // max_readahead: int32 = 0xffffffea (4 bytes) // flags: fuse_init_flags = 0x0 (4 bytes) // max_background: int16 = 0x0 (2 bytes) // congestion_threshold: int16 = 0x0 (2 bytes) // max_write: int32 = 0x0 (4 bytes) // time_gran: int32 = 0x0 (4 bytes) // max_pages: const = 0x0 (2 bytes) // map_alignment: const = 0x0 (2 bytes) // flags2: fuse_init_flags2 = 0x0 (4 bytes) // max_stack_depth: int32 = 0x0 (4 bytes) // unused: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00} (length 0x18) // } // } // } // len: bytesize = 0x2000 (8 bytes) // ] *(uint32_t*)0x20000000 = 0x50; *(uint32_t*)0x20000004 = 0; *(uint64_t*)0x20000008 = 0; *(uint32_t*)0x20000010 = 7; *(uint32_t*)0x20000014 = 0x2b; *(uint32_t*)0x20000018 = 0xffffffea; *(uint32_t*)0x2000001c = 0; *(uint16_t*)0x20000020 = 0; *(uint16_t*)0x20000022 = 0; *(uint32_t*)0x20000024 = 0; *(uint32_t*)0x20000028 = 0; *(uint16_t*)0x2000002c = 0; *(uint16_t*)0x2000002e = 0; *(uint32_t*)0x20000030 = 0; *(uint32_t*)0x20000034 = 0; memset((void*)0x20000038, 0, 24); syscall(__NR_write, /*fd=*/r[0], /*arg=*/0x20000000ul, /*len=*/0x2000ul); } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-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=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x21000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); const char* reason; (void)reason; if ((reason = setup_usb())) printf("the reproducer may not work as expected: USB injection setup " "failed: %s\n", reason); for (procid = 0; procid < 5; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; }