// https://syzkaller.appspot.com/bug?id=127fa0ac195cfd85a8c02f1f2485d6d48772bf7b // 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 #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; } #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); } 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 < 7; 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); close_fds(); } 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[2] = {0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: // syz_mount_image$udf arguments: [ // fs: ptr[in, buffer] { // buffer: {75 64 66 00} (length 0x4) // } // dir: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 31 00} (length 0x8) // } // flags: mount_flags = 0x2014000 (8 bytes) // opts: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {6c 61 73 74 62 6c 6f 63 6b 3d 30 30 30 30 30 // 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 2c 75 6d 61 73 6b // 3d 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 // 31 30 32 2c 64 6d 6f 64 65 3d 30 30 30 30 30 30 30 30 30 30 30 // 30 30 30 30 30 30 30 37 37 37 37 37 2c 6e 6f 76 72 73 2c 73 68 // 6f 72 74 61 64 2c 73 68 6f 72 74 61 64 2c 75 6e 64 65 6c 65 74 // 65 2c 69 6f 63 68 61 72 73 65 74 3d 63 70 34 33 37 2c 73 68 6f // 72 74 61 64 2c 75 6d 61 73 6b 3d 30 30 30 30 30 30 30 30 30 30 // 30 30 30 30 30 30 30 30 30 30 30 30 36 2c 64 6d 6f 64 65 3d 30 // 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 31 // 31 2c 66 69 6c 65 73 65 74 3d 30 30 30 30 30 30 30 30 30 30 30 // 30 30 30 30 30 30 30 31 31 2c 75 69 64 3d} (length 0xef) // } // union ANYUNION { // ANYBLOB: buffer: {d6 d8 4c 0d f9 37 ed 4a 0c d3 00 00 f2 e9 ea // 95 68 ea b7 4a 46 c5 25 dc 38 69 83 ea de 0b 0c e5 f1 dd 91 17 // 06 cf 7d 32 d7 d5 08 d1 82 3b 88 71 e0 01 00 00 00 eb 4c e0 a0 // 08 f5 cd ea 62 2f c6 67 5e 54 86 86 0a 75 2e d0 29 8a 94 8e fa // 72 b2 c8 d8 52 51 81 64 4a 31 24 f3 54 4a 50 f1 92 b9 8f 05 5a // d1 25 fd 46 74 53 44 13 c6 04 41 36 ea 5a ef ac 52 67 e4 37 39 // 62 6e a9 39 1d 8f 34 6c 46 94 f7 04 00 00 00 00 00 00 00 ce e1 // f6 28 d1 ce c3 46 28 30 60 6b b6 12 bf ed 91 18 1c dc 10 7b b9 // 1a 2e 86 de 2a d5} (length 0xa8) // } // union ANYUNION { // ANYBLOB: buffer: {2c 00 01 00 00 00 00 00 00 30 30 30 30 00 30 // 30 30 30 30 30 30 30 30 30 30 30 30 30 35 2c 00 d7 45 dc ab 34 // ff 63 40 99 d4 02 40 61 84 d6 88 f8 1f 99 d0 1c e1 16 4b fd 68 // 77 7e 4b df e2 e9 fa e1 8a 6c 91 c7 0b c3 4f 97 4b 26 5a 58 d1 // 88 9c 9c 38 e7 e3 28 95 b1 92 1f 8e 4b 4b 41 f3 ef 0d eb ac 34 // b1 9a a6 87 22 1a 6b 94 2e b3 96 15 9e f6 de 96 45 e4 b3 38 65 // d6 b6 2e 56 42 77 ed 35 92 35 44 b6 37 98 22 86 1e c7 9f 42 3c // 1b 03 72 e2 b2 6b db a8 1f ce a8 c4 d1 eb 65 78 69 c8 7c 4d 7c // f2 b1 87 c3 87 d6 32 e5 8f 44 95 6d 2d 7b 16 ba 93 15 35 14 08 // 7b 38 67 6f 72 ca b9 f6 2f 53 f3 31 bb 7f 95 2e f5 ab 05 e9 40 // 3a fa 22 e6 57 43 c5 83 ba 30 68 3a c5 e3 01 73 cd b5 c2 16 d8 // 79 ea d8 b3 ee 56 d6 02 a3 9e 33 c6 3b a2 75 4c cf e2 31 c2 e1 // b6 60 f2 a6 8c c1 4a 91 86 ee 2e 83 4b e5 f1 0b 09} (length // 0x107) // } // } // } // chdir: int8 = 0x12 (1 bytes) // size: len = 0xc49 (8 bytes) // img: ptr[in, buffer] { // buffer: (compressed buffer with length 0xc49) // } // ] // returns fd_dir memcpy((void*)0x200000000080, "udf\000", 4); memcpy((void*)0x200000000100, "./file1\000", 8); memcpy((void*)0x200000000580, "lastblock=00000000000000000000,umask=00000000000000000000102,dmode=" "00000000000000000077777,novrs,shortad,shortad,undelete,iocharset=" "cp437,shortad,umask=00000000000000000000006,dmode=" "00000000000000000000011,fileset=00000000000000000011,uid=", 239); memcpy( (void*)0x20000000066f, "\xd6\xd8\x4c\x0d\xf9\x37\xed\x4a\x0c\xd3\x00\x00\xf2\xe9\xea\x95\x68" "\xea\xb7\x4a\x46\xc5\x25\xdc\x38\x69\x83\xea\xde\x0b\x0c\xe5\xf1\xdd" "\x91\x17\x06\xcf\x7d\x32\xd7\xd5\x08\xd1\x82\x3b\x88\x71\xe0\x01\x00" "\x00\x00\xeb\x4c\xe0\xa0\x08\xf5\xcd\xea\x62\x2f\xc6\x67\x5e\x54\x86" "\x86\x0a\x75\x2e\xd0\x29\x8a\x94\x8e\xfa\x72\xb2\xc8\xd8\x52\x51\x81" "\x64\x4a\x31\x24\xf3\x54\x4a\x50\xf1\x92\xb9\x8f\x05\x5a\xd1\x25\xfd" "\x46\x74\x53\x44\x13\xc6\x04\x41\x36\xea\x5a\xef\xac\x52\x67\xe4\x37" "\x39\x62\x6e\xa9\x39\x1d\x8f\x34\x6c\x46\x94\xf7\x04\x00\x00\x00\x00" "\x00\x00\x00\xce\xe1\xf6\x28\xd1\xce\xc3\x46\x28\x30\x60\x6b\xb6\x12" "\xbf\xed\x91\x18\x1c\xdc\x10\x7b\xb9\x1a\x2e\x86\xde\x2a\xd5", 168); memcpy( (void*)0x200000000717, "\x2c\x00\x01\x00\x00\x00\x00\x00\x00\x30\x30\x30\x30\x00\x30\x30\x30" "\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x35\x2c\x00\xd7\x45\xdc" "\xab\x34\xff\x63\x40\x99\xd4\x02\x40\x61\x84\xd6\x88\xf8\x1f\x99\xd0" "\x1c\xe1\x16\x4b\xfd\x68\x77\x7e\x4b\xdf\xe2\xe9\xfa\xe1\x8a\x6c\x91" "\xc7\x0b\xc3\x4f\x97\x4b\x26\x5a\x58\xd1\x88\x9c\x9c\x38\xe7\xe3\x28" "\x95\xb1\x92\x1f\x8e\x4b\x4b\x41\xf3\xef\x0d\xeb\xac\x34\xb1\x9a\xa6" "\x87\x22\x1a\x6b\x94\x2e\xb3\x96\x15\x9e\xf6\xde\x96\x45\xe4\xb3\x38" "\x65\xd6\xb6\x2e\x56\x42\x77\xed\x35\x92\x35\x44\xb6\x37\x98\x22\x86" "\x1e\xc7\x9f\x42\x3c\x1b\x03\x72\xe2\xb2\x6b\xdb\xa8\x1f\xce\xa8\xc4" "\xd1\xeb\x65\x78\x69\xc8\x7c\x4d\x7c\xf2\xb1\x87\xc3\x87\xd6\x32\xe5" "\x8f\x44\x95\x6d\x2d\x7b\x16\xba\x93\x15\x35\x14\x08\x7b\x38\x67\x6f" "\x72\xca\xb9\xf6\x2f\x53\xf3\x31\xbb\x7f\x95\x2e\xf5\xab\x05\xe9\x40" "\x3a\xfa\x22\xe6\x57\x43\xc5\x83\xba\x30\x68\x3a\xc5\xe3\x01\x73\xcd" "\xb5\xc2\x16\xd8\x79\xea\xd8\xb3\xee\x56\xd6\x02\xa3\x9e\x33\xc6\x3b" "\xa2\x75\x4c\xcf\xe2\x31\xc2\xe1\xb6\x60\xf2\xa6\x8c\xc1\x4a\x91\x86" "\xee\x2e\x83\x4b\xe5\xf1\x0b\x09", 263); memcpy( (void*)0x200000001cc0, "\x78\x9c\xec\xdd\x4f\x6c\x1c\xd7\x7d\x07\xf0\xdf\x1b\x2d\xc5\x95\xdc" "\x56\x4c\xec\x28\x4e\x1a\xb7\x9b\xa6\x48\x65\xc5\x72\xf5\x2f\xa6\x62" "\x15\xee\xaa\xa6\xd9\x06\x90\x65\x21\x14\x73\x0b\xc0\x95\xb8\x52\x17" "\xa6\x48\x82\xa4\x1a\xd9\x48\x0b\xa6\x97\x1e\x7a\x08\x50\x14\x3d\xe4" "\x44\xa0\x35\x0a\xa4\x68\x60\x34\x45\x90\x23\xd3\xba\x40\x72\xf1\xa1" "\xc8\xa9\x27\xa2\x85\x8d\xa0\xe8\x81\x6d\x03\xf8\x14\x30\x98\xd9\xb7" "\xe2\x92\xa2\x22\x5a\x14\x25\x4a\xfe\x7c\x6c\xea\xbb\x3b\xfb\xde\xec" "\x7b\x33\xab\x37\x14\xc1\x37\x2f\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x80\x88\x3f\x78\xe5\xdc\xf1\x13\x69\xbb\xa5\x3f" "\x58\xdb\xdd\xd6\x00\x00\x0f\xc2\x85\xb1\xaf\x1c\x3f\xb9\xed\xeb\x3f" "\x00\xf0\x38\xb8\xf4\xa1\xfe\xfd\x0f\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x3c\x04\x29\x8a\x78\x32\x52\xcc\x5e\x58\x4d\x13\xd5\xf3" "\xae\xfa\xf9\xce\xc0\x8d\x9b\xe3\x23\xa3\x5b\x57\x3b\x90\xaa\x9a\xfb" "\xaa\xf2\xe5\x57\xfd\xc4\xc9\x53\xa7\xbf\xf8\xc2\xf0\x99\x5e\x9e\xef" "\x4c\xaf\xd7\x1f\xdc\xed\x6e\x7c\x3a\x5e\x1b\xbb\x74\xae\xf1\xf2\xcc" "\xf5\xd9\xb9\xf6\xfc\x7c\x7b\xb2\x31\x3e\xdd\xb9\x32\x33\xd9\xde\xf6" "\x1e\x76\x5a\x7f\xb3\xa3\xd5\x01\x68\x5c\x7f\xfd\xc6\xe4\xd5\xab\xf3" "\x8d\x93\xcf\x9f\xda\xf0\xf2\xcd\xa1\xf7\x07\x9f\x38\x3c\x74\x76\xf8" "\xd9\x63\xcf\xf4\xca\x8e\x8f\x8c\x8e\x8e\xad\x17\xa9\xf7\x97\xaf\xdd" "\x73\x43\xba\xee\x34\xc3\x63\x7f\x14\x71\x2c\x52\x3c\xf7\xdd\x9f\xa6" "\x56\x44\x14\xb1\xf3\x63\x51\xdf\x70\xee\x1f\xb8\x03\x55\x27\x8e\x56" "\x9d\x18\x1f\x19\xad\x3a\x32\xd5\x69\x4d\x2f\x94\x2f\x5e\xec\x1d\x88" "\x22\xa2\xd1\x57\xa9\xd9\x3b\x46\x5b\x9f\x8b\xa8\x0d\x3c\xd0\x3e\xdc" "\x59\x33\x62\xb1\x6c\x7e\xd9\xe0\xa3\x65\xf7\xc6\x66\x5b\x73\xad\xcb" "\x53\xed\xc6\xc5\xd6\xdc\x42\x67\xa1\x33\x33\x7d\x31\x75\x5b\x5b\xf6" "\xa7\x11\x45\x9c\x49\x11\x4b\x11\xb1\xb2\xc5\x5f\xc3\x81\x28\xa2\x16" "\x29\xbe\x7d\x68\x35\x5d\x8e\x88\x7d\xbd\xe3\xf0\x85\x6a\x62\xf0\x9d" "\xdb\x51\xec\x62\x1f\xb7\xa1\x6c\x67\x63\x20\x62\xa9\x78\x04\xce\xd9" "\x1e\x36\x18\x45\xbc\x1a\x29\x7e\xf6\xce\x91\xb8\x92\xc7\x99\x6a\xac" "\xf9\x7c\xc4\xab\x65\x7e\x3f\xe2\xad\x32\x5f\x8a\x48\xe5\x07\xe3\x74" "\xc4\x7b\xbb\x3e\x9c\xf3\xa0\xd4\xa2\x88\xbf\x2c\xcf\xff\xd9\xd5\x34" "\x59\x8d\x07\xbd\x71\xe5\xfc\x57\x1b\x5f\x9e\xbe\x3a\xd3\x57\xb6\x37" "\xae\x7c\xc8\xeb\xc3\x6d\x23\xc5\x43\xba\x3e\x1c\xd8\x94\x0f\xc6\x1e" "\x1f\x9b\xea\x51\x44\xab\x1a\xf1\x57\xd3\xbd\x7f\xb3\x03\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xfd\x76\x20\x8a\xf8\x54\xa4" "\x78\xe5\xdf\xff\xa4\x9a\x57\x1c\xd5\xbc\xf4\x43\x67\x87\xff\x70\xe8" "\x57\xfb\xe7\x8c\x3f\x7d\x97\xfd\x94\x65\x9f\x8f\x88\xc5\x62\x7b\x73" "\x72\xf7\xe7\x89\x81\x17\xd3\xc5\x94\x1e\xf2\x5c\xe2\x8f\xb2\x7a\x14" "\xf1\xa7\x79\xfe\xdf\x37\x1f\x76\x63\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x3e\xd2\x8a\xf8\x49\xa4\x78\xf1\xdd\x23" "\x69\x29\xfa\xd7\x14\xef\x4c\x5f\x6b\x5c\x6a\x5d\x9e\xea\xae\x0a\xdb" "\x5b\xfb\xb7\xb7\x66\xfa\xda\xda\xda\x5a\x23\x75\xb3\x99\x73\x22\xe7" "\x62\xce\xa5\x9c\xcb\x39\x57\x72\x46\x91\xeb\xe7\x6c\xe6\x9c\xc8\xb9" "\x98\x73\x29\xe7\x72\xce\x95\x9c\xb1\x2f\xd7\xcf\xd9\xcc\x39\x91\x73" "\x31\xe7\x52\xce\xe5\x9c\x2b\x39\xa3\x96\xeb\xe7\x6c\xe6\x9c\xc8\xb9" "\x98\x73\x29\x2f\xba\xbf\x9c\x9f\xaf\xe4\x8c\x3d\xb2\x76\x2f\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\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\xe3\xa4\x88\x22\x7e\x1e" "\x29\xbe\xf5\xf5\xd5\x14\x29\x22\x9a\x11\x13\xd1\xcd\xe5\xc1\x87\xdd" "\x3a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xa0\x34\x98" "\x8a\xf8\x5e\xa4\x68\xfc\x51\xf3\xd6\xb6\x5a\x44\xa4\xea\xff\xae\x23" "\xe5\x1f\xa7\xa3\xb9\xbf\xcc\x8f\x47\x73\xb8\xcc\x97\xa2\x79\x2e\x67" "\xab\xca\x5a\xf3\x9b\x0f\xa1\xfd\xec\xcc\x40\x2a\xe2\xc7\x91\x62\xb0" "\xfe\xf6\xad\x13\x9e\xcf\xff\x40\xf7\xd9\xad\x8f\x41\xbc\xf5\x8d\xf5" "\x67\x9f\xae\x75\x73\x5f\xef\xc5\xa1\xf7\x07\x9f\x38\x7c\xe8\xec\xf0" "\xe8\x6f\x3c\x7d\xa7\xc7\x69\xab\x06\x1c\x3d\xdf\x99\xbe\x71\xb3\x31" "\x3e\x32\x3a\x3a\xd6\xb7\xb9\x96\xdf\xfd\xe3\x7d\xdb\x86\xf2\xfb\x16" "\xf7\xa7\xeb\x44\xc4\xfc\x1b\x6f\xbe\xde\x9a\x9a\x6a\xcf\xdd\xfb\x83" "\xf2\x23\xb0\x83\xea\x8f\xd0\x83\x54\xfb\xa8\xf4\xf4\xd1\x7e\xf0\x9b" "\xf7\x6b\x87\x51\xdb\x0b\xdd\x79\x38\x0f\xee\x3e\x76\xfc\xff\x83\x18" "\xa0\xd8\x55\xe5\xf5\xff\xbd\x48\xf1\xbb\xef\xfe\x47\xef\x82\xdf\xbd" "\xfe\xd7\xe3\x57\xba\xcf\x6e\x5d\xe1\xe3\x83\x3f\x5b\xbf\xfe\xbf\xb8" "\x79\x47\xdb\xbc\xfe\xd7\x36\xd7\xcb\xd7\xff\xf2\x9a\xbe\xd5\xf5\xff" "\xc9\xbe\x6d\x2f\xe6\xef\x46\x06\x6a\x11\xf5\x85\xeb\xb3\x03\x87\x23" "\xea\xf3\x6f\xbc\x79\xac\x73\xbd\x75\xad\x7d\xad\x3d\x7d\xfa\xf8\xf1" "\x2f\x0d\x0f\x7f\xe9\xd4\xf1\x81\xfd\x11\xf5\xab\x9d\xa9\x76\xf7\x51" "\x8a\xa9\xf6\xf1\xfb\x72\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x1e\x9c\x54\xc4\xef\x47\x8a\xd6\x8f\x57\x53\x23\x22\x6e" "\x56\xf3\xb5\x86\xce\x0e\x3f\x7b\xec\x99\x7d\xb1\xaf\x9a\x6f\xb5\x61" "\xde\xf6\x6b\x63\x97\xce\x35\x5e\x9e\xb9\x3e\x3b\xd7\x9e\x9f\x6f\x4f" "\x36\xc6\xa7\x3b\x57\x66\x26\xdb\xdb\x7d\xbb\x7a\x35\xdd\x6b\x7c\x64" "\x74\x57\x3a\x73\x57\x07\x76\xb9\xfd\x07\xea\x2f\xcf\xcc\xbe\x31\xd7" "\xb9\xf6\xc7\x0b\x5b\xbe\x7e\xb0\x7e\xee\xf2\xfc\xc2\x5c\xeb\xca\xd6" "\x2f\xc7\x81\x28\x22\x9a\xfd\x5b\x8e\x56\x0d\x1e\x1f\x19\xad\x1a\x3d" "\xd5\x69\x4d\x57\x55\x2f\x6e\x39\x99\xfe\xc3\x1b\x48\x45\xfc\x67\xa4" "\xb8\x72\xba\x91\x3e\x9b\xb7\xe5\xf9\xff\x9b\x67\xf8\x6f\x98\xff\xbf" "\xb8\x79\x47\xbb\x34\xff\xff\x63\x7d\xdb\xca\xf7\x4c\xa9\x88\x0f\x22" "\xc5\xef\xfc\xd5\xd3\xf1\xd9\xaa\x9d\x07\xe3\xb6\x63\x96\xcb\xfd\x5d" "\xa4\x38\x7a\xe6\x33\xb9\x5c\xec\x2f\xcb\xf5\xda\xd0\xbd\xaf\x40\x77" "\x8e\x60\x59\xf6\x7f\x23\xc5\x3f\xfd\x7c\x63\xd9\xde\x7c\xc8\x27\xd7" "\xcb\x9e\xd8\xf6\x81\x7d\x44\x94\xe7\xff\x50\xa4\xf8\xde\x5f\x7c\x27" "\x7e\x2b\x6f\xdb\x78\xff\x87\xad\xcf\xff\xc1\xcd\x3b\xda\xa5\xf3\xff" "\x54\xdf\xb6\x83\x1b\xee\x57\xb0\xe3\xae\x93\xcf\xff\xb1\x48\xf1\xd2" "\x93\x6f\xc7\xe7\xf2\xb6\x5f\x76\xff\x8f\xde\xbd\x37\x8e\xe4\xc2\xb7" "\xee\xcf\xb1\x4b\xe7\xff\x13\x7d\xdb\x86\xf2\xfb\xfe\xf6\xfd\xe9\x3a" "\x00\x00\x00\x00\x00\x00\x00\x00\xc0\x23\x6d\x20\x15\xf1\xf7\x91\xe2" "\x87\xa3\xb5\xf4\x42\xde\xb6\x9d\xdf\xff\x9b\xdc\xbc\xa3\x5d\xfa\xfd" "\xaf\x4f\xf6\x6d\x9b\xbc\x3f\xeb\x15\xdd\xf5\xc1\x8e\x0f\x2a\x00\x00" "\x00\x00\xec\x11\x03\xa9\x88\x9f\x44\x8a\x6b\x0b\x6f\xdf\x9a\x43\xbd" "\x71\xfe\x77\xdf\xfc\xcf\xdf\x5b\x9f\xff\x39\x92\x36\xbd\x5a\xfd\x9c" "\xef\xd7\xaa\xfb\x06\xdc\xcf\x9f\xff\xf5\x1b\xca\xef\x3b\xb1\xf3\x6e" "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\x9e" "\x92\x52\x11\x2f\xe4\xf5\xd4\x27\xaa\xf9\xfc\x93\x77\x5c\x4f\x7d\x39" "\x52\xbc\xf2\xdf\xcf\xe5\x72\xe9\x70\x59\xae\xb7\x0e\xfc\x50\xf5\x67" "\xfd\xc2\xcc\xf4\xb1\x73\x53\x53\x33\x57\x5a\x0b\xad\xcb\x53\xed\xc6" "\xd8\x6c\xeb\x4a\xbb\xac\xfb\x54\xa4\x58\xfd\xdb\xcf\xe4\xba\x45\xb5" "\xbe\x7a\x6f\xbd\xf9\xee\x1a\xef\xeb\x6b\xb1\xcf\x45\x8a\xd1\x7f\xe8" "\x95\xed\xae\xc5\xde\x5b\x9b\xfc\xa9\xf5\xb2\x27\xca\xb2\x1f\x8b\x14" "\xff\xf5\x8f\x1b\xcb\x7e\x2e\x97\xfb\xc4\x7a\xd9\x93\x65\xd9\xbf\x89" "\x14\x5f\xfb\xc1\xed\x65\x4b\x87\xd7\xcb\x9e\x2a\xcb\x7e\x27\x52\xfc" "\xe8\x6b\x8d\x5e\xd9\x83\x65\xd9\xde\xfd\x51\x3f\xb9\x5e\xf6\xf9\x1f" "\xdc\xba\x23\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\xdc\xbb\x81\x54\xc4\x9f\x47\x8a\xff\xb9\xbe\x74\x6b\x2e\x7f" "\x5e\xff\x7f\xa0\xef\x69\xe5\xad\x6f\xf4\xad\xf7\xbf\xc9\xcd\x6a\x9d" "\xff\xa1\x6a\xfd\xff\x3b\x3d\xbe\x97\xf5\xff\xab\xfb\x0a\x2c\xde\xe9" "\x5d\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\xe0\xf1" "\x94\xa2\x88\x37\x23\xc5\xec\x85\xd5\xb4\x3c\x58\x3e\xef\xaa\x9f\xef" "\x4c\xdf\xb8\x39\x3e\x32\xba\x75\xb5\x03\xa9\xaa\xb9\xaf\x2a\x5f\x7e" "\xd5\x4f\x9c\x3c\x75\xfa\x8b\x2f\x0c\x9f\xe9\xe5\x2f\xaf\x7f\xbf\x7d" "\x2a\x5e\x1b\xbb\x74\xae\xf1\xf2\xcc\xf5\xd9\xb9\xf6\xfc\x7c\x7b\xb2" "\x31\x3e\xdd\xb9\x32\x33\xd9\xde\xf6\x1e\x76\x5a\x7f\xb3\xa3\xd5\x01" "\x68\x5c\x7f\xfd\xc6\xe4\xd5\xab\xf3\x8d\x93\xcf\x9f\xda\xf0\xf2\xcd" "\xa1\xf7\x07\x9f\x38\x3c\x74\x76\xf8\xd9\x63\xcf\xf4\xca\x8e\x8f\x8c" "\x8e\x8e\xf5\x95\xa9\x0d\xdc\xf3\xbb\xdf\x26\xdd\x61\xfb\xfe\x28\xe2" "\xaf\x23\xc5\x73\xdf\xfd\x69\xfa\xe1\x60\x44\x11\x3b\x3f\x16\x77\xf9" "\xec\xec\xb6\x03\x55\x27\x8e\x56\x9d\x18\x1f\x19\xad\x3a\x32\xd5\x69" "\x4d\x2f\x94\x2f\x5e\xec\x1d\x88\x22\xa2\xd1\x57\xa9\xd9\x3b\x46\x0f" "\xe0\x5c\xec\x48\x33\x62\xb1\x6c\x7e\xd9\xe0\xa3\x65\xf7\xc6\x66\x5b" "\x73\xad\xcb\x53\xed\xc6\xc5\xd6\xdc\x42\x67\xa1\x33\x33\x7d\x31\x75" "\x5b\x5b\xf6\xa7\x11\x45\x9c\x49\x11\x4b\x11\xb1\x32\x78\xfb\xee\x06" "\xa2\x88\xd7\x23\xc5\xb7\x0f\xad\xa6\x7f\x19\x8c\xd8\xd7\x3b\x0e\x5f" "\xb8\x30\xf6\x95\xe3\x27\xef\xdc\x8e\x62\x17\xfb\xb8\x0d\x65\x3b\x1b" "\x03\x11\x4b\xc5\x23\x70\xce\xf6\xb0\xc1\x28\xe2\x9f\x23\xc5\xcf\xde" "\x39\x12\xff\x3a\x18\x51\x8b\xee\x57\x7c\x3e\xe2\xd5\x32\xbf\x1f\xf1" "\x56\x74\xcf\x77\x2a\x3f\x18\xa7\x23\xde\xdb\xe2\x73\xc4\xa3\xa9\x16" "\x45\xfc\x5f\x79\xfe\xcf\xae\xa6\x77\x06\xcb\xf1\xa0\x37\xae\x9c\xff" "\x6a\xe3\xcb\xd3\x57\x67\xfa\xca\xf6\xc6\x95\x47\xfe\xfa\xf0\x20\xed" "\xf1\xb1\xa9\x1e\x45\xfc\xa8\x1a\xf1\x57\xd3\xbf\xf9\x7b\x0d\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xb0\x87\x14\xf1\xeb\x91\xe2" "\xc5\x77\x8f\xa4\x6a\x7e\xf0\xad\x39\xc5\x9d\xe9\x6b\x8d\x4b\xad\xcb" "\x53\xdd\x69\x7d\xbd\xb9\x7f\xbd\x39\xd3\x6b\x6b\x6b\x6b\x8d\xd4\xcd" "\x66\xce\x89\x9c\x8b\x39\x97\x72\x2e\xe7\x5c\xc9\x19\x45\xae\x9f\xb3" "\x59\x66\x7d\x6d\x6d\x22\x3f\x5f\xcc\xb9\x94\x73\x39\xe7\x4a\xce\xd8" "\x97\xeb\xe7\x6c\xe6\x9c\xc8\xb9\x98\x73\x29\xe7\x72\xce\x95\x9c\x51" "\xcb\xf5\x73\x36\x73\x4e\xe4\x5c\xcc\xb9\x94\x73\x39\xe7\x4a\xce\xd8" "\x23\x73\xf7\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x80\xc7\x4b\x51\xfd\x97\xe2\x5b\x5f\x5f\x4d\x6b\x83\xdd\xf5\xa5\x27" "\xa2\x9b\xcb\xd6\x03\x7d\xec\xfd\x22\x00\x00\xff\xff\x62\x75\xf6\x7e", 3145); syz_mount_image(/*fs=*/0x200000000080, /*dir=*/0x200000000100, /*flags=MS_LAZYTIME|MS_POSIXACL|MS_REC*/ 0x2014000, /*opts=*/0x200000000580, /*chdir=*/0x12, /*size=*/0xc49, /*img=*/0x200000001cc0); break; case 1: // openat arguments: [ // fd: fd_dir (resource) // file: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 31 00} (length 0x8) // } // flags: open_flags = 0x42 (4 bytes) // mode: open_mode = 0x0 (2 bytes) // ] // returns fd memcpy((void*)0x200000000040, "./file1\000", 8); res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x200000000040ul, /*flags=O_CREAT|O_RDWR*/ 0x42, /*mode=*/0); if (res != -1) r[0] = res; break; case 2: // pwrite64 arguments: [ // fd: fd (resource) // buf: ptr[in, buffer] { // buffer: {32} (length 0x1) // } // count: len = 0x1 (8 bytes) // pos: intptr = 0x8080c61 (8 bytes) // ] memset((void*)0x200000000140, 50, 1); syscall(__NR_pwrite64, /*fd=*/r[0], /*buf=*/0x200000000140ul, /*count=*/1ul, /*pos=*/0x8080c61ul); break; case 3: // openat arguments: [ // fd: fd_dir (resource) // file: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 31 00} (length 0x8) // } // flags: open_flags = 0x42 (4 bytes) // mode: open_mode = 0x0 (2 bytes) // ] // returns fd memcpy((void*)0x200000000040, "./file1\000", 8); res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x200000000040ul, /*flags=O_CREAT|O_RDWR*/ 0x42, /*mode=*/0); if (res != -1) r[1] = res; break; case 4: // pwrite64 arguments: [ // fd: fd (resource) // buf: ptr[in, buffer] { // buffer: {61} (length 0x1) // } // count: len = 0x200000c1 (8 bytes) // pos: intptr = 0x9000 (8 bytes) // ] memset((void*)0x2000000000c0, 97, 1); syscall(__NR_pwrite64, /*fd=*/r[1], /*buf=*/0x2000000000c0ul, /*count=*/0x200000c1ul, /*pos=*/0x9000ul); break; case 5: // setrlimit arguments: [ // res: rlimit_type = 0x1 (8 bytes) // rlim: ptr[in, rlimit] { // rlimit { // soft: intptr = 0xffffffffffffffff (8 bytes) // hard: intptr = 0xffffffffffffffff (8 bytes) // } // } // ] *(uint64_t*)0x200000000140 = -1; *(uint64_t*)0x200000000148 = -1; syscall(__NR_setrlimit, /*res=RLIMIT_FSIZE*/ 1ul, /*rlim=*/0x200000000140ul); break; case 6: // truncate arguments: [ // file: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 31 00} (length 0x8) // } // len: intptr = 0x400000f007 (8 bytes) // ] memcpy((void*)0x200000000080, "./file1\000", 8); syscall(__NR_truncate, /*file=*/0x200000000080ul, /*len=*/0x400000f007ul); break; } } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); const char* reason; (void)reason; for (procid = 0; procid < 5; procid++) { if (fork() == 0) { use_temporary_dir(); do_sandbox_none(); } } sleep(1000000); return 0; }