// https://syzkaller.appspot.com/bug?id=b3d4ed3e41b3085ce97f4504f4183e3f99115fb2 // 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_fsconfig #define __NR_fsconfig 431 #endif #ifndef __NR_fspick #define __NR_fspick 433 #endif #ifndef __NR_memfd_create #define __NR_memfd_create 319 #endif static unsigned long long procid; static __thread int clone_ongoing; static __thread int skip_segv; static __thread jmp_buf segv_env; static void segv_handler(int sig, siginfo_t* info, void* ctx) { if (__atomic_load_n(&clone_ongoing, __ATOMIC_RELAXED) != 0) { exit(sig); } uintptr_t addr = (uintptr_t)info->si_addr; const uintptr_t prog_start = 1 << 20; const uintptr_t prog_end = 100 << 20; int skip = __atomic_load_n(&skip_segv, __ATOMIC_RELAXED) != 0; int valid = addr < prog_start || addr > prog_end; if (skip && valid) { _longjmp(segv_env, 1); } exit(sig); } static void install_segv_handler(void) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = SIG_IGN; syscall(SYS_rt_sigaction, 0x20, &sa, NULL, 8); syscall(SYS_rt_sigaction, 0x21, &sa, NULL, 8); memset(&sa, 0, sizeof(sa)); sa.sa_sigaction = segv_handler; sa.sa_flags = SA_NODEFER | SA_SIGINFO; sigaction(SIGSEGV, &sa, NULL); sigaction(SIGBUS, &sa, NULL); } #define NONFAILING(...) \ ({ \ int ok = 1; \ __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); \ if (_setjmp(segv_env) == 0) { \ __VA_ARGS__; \ } else \ ok = 0; \ __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); \ ok; \ }) static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static 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"); } 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_binfmt_misc() { if (mount(0, "/proc/sys/fs/binfmt_misc", "binfmt_misc", 0, 0) && errno != EBUSY) { return NULL; } if (!write_file("/proc/sys/fs/binfmt_misc/register", ":syz0:M:0:\x01::./file0:") || !write_file("/proc/sys/fs/binfmt_misc/register", ":syz1:M:1:\x02::./file0:POC")) return "write(/proc/sys/fs/binfmt_misc/register) failed"; 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[2] = {0xffffffffffffffff, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } NONFAILING(memcpy((void*)0x200000000140, "ext4\000", 5)); NONFAILING(memcpy((void*)0x2000000005c0, "./file0\000", 8)); NONFAILING(memcpy((void*)0x200000000380, "test_dummy_encryption", 21)); NONFAILING(*(uint8_t*)0x200000000395 = 0x2c); NONFAILING(memcpy((void*)0x200000000396, "debug_want_extra_isize", 22)); NONFAILING(*(uint8_t*)0x2000000003ac = 0x3d); NONFAILING(sprintf((char*)0x2000000003ad, "0x%016llx", (long long)0x84)); NONFAILING(*(uint8_t*)0x2000000003bf = 0x2c); NONFAILING(memcpy((void*)0x2000000003c0, "stripe", 6)); NONFAILING(*(uint8_t*)0x2000000003c6 = 0x3d); NONFAILING(sprintf((char*)0x2000000003c7, "0x%016llx", (long long)7)); NONFAILING(*(uint8_t*)0x2000000003d9 = 0x2c); NONFAILING(memcpy((void*)0x2000000003da, "commit", 6)); NONFAILING(*(uint8_t*)0x2000000003e0 = 0x3d); NONFAILING(sprintf((char*)0x2000000003e1, "0x%016llx", (long long)5)); NONFAILING(*(uint8_t*)0x2000000003f3 = 0x2c); NONFAILING(memcpy((void*)0x2000000003f4, "orlov", 5)); NONFAILING(*(uint8_t*)0x2000000003f9 = 0x2c); NONFAILING(memcpy((void*)0x2000000003fa, "barrier", 7)); NONFAILING(*(uint8_t*)0x200000000401 = 0x3d); NONFAILING(sprintf((char*)0x200000000402, "0x%016llx", (long long)5)); NONFAILING(*(uint8_t*)0x200000000414 = 0x2c); NONFAILING(memcpy((void*)0x200000000415, "max_batch_time", 14)); NONFAILING(*(uint8_t*)0x200000000423 = 0x3d); NONFAILING(sprintf((char*)0x200000000424, "0x%016llx", (long long)0)); NONFAILING(*(uint8_t*)0x200000000436 = 0x2c); NONFAILING(memcpy((void*)0x200000000437, "data_err=abort", 14)); NONFAILING(*(uint8_t*)0x200000000445 = 0x2c); NONFAILING(*(uint8_t*)0x200000000446 = 0); NONFAILING(memcpy( (void*)0x200000000c00, "\x78\x9c\xec\xdd\xcf\x6f\x14\x55\x1c\x00\xf0\xef\x6c\x7f\xd0\x52\xb4\x85" "\x18\x15\x0f\xd2\xc4\x18\x48\x94\x96\x16\x30\xc4\x78\x80\xab\x21\x0d\xfe" "\x88\x17\x2f\x56\x5a\x10\x29\xd0\xd0\x1a\x2d\x9a\x50\x12\xbc\x98\x18\x2f" "\xc6\x98\x78\xf2\x20\xfe\x17\x4a\xe4\xca\x49\x4f\x1e\xbc\x78\x32\x24\x44" "\x0d\x47\x13\xd7\xcc\x76\xa6\x74\xdb\xd9\x96\x2e\x6d\xa7\x32\x9f\x4f\xb2" "\xf4\xcd\x7b\x3b\xbc\x37\xdd\x7e\xfb\xde\xbe\xbe\x37\x1b\x40\x65\x0d\xa6" "\xff\xd4\x22\xf6\x46\xc4\x74\x12\xd1\x9f\xcc\x2f\x96\x75\x46\x56\x38\xb8" "\xf0\xbc\x7b\x7f\x7f\x72\x3a\x7d\x24\x51\xaf\xbf\xf1\x67\x12\x49\x96\x97" "\x3f\x3f\xc9\xbe\xf6\x65\x27\xf7\x44\xc4\xcf\x3f\x25\xb1\xa7\x63\x65\xbd" "\x33\x73\x57\xce\x8f\x4f\x4d\x4d\x5e\xce\x8e\x87\x67\x2f\x4c\x0f\xcf\xcc" "\x5d\x39\x78\xee\xc2\xf8\xd9\xc9\xb3\x93\x17\x47\x5f\x1a\x3d\x76\xf4\xc8" "\xd1\x63\x23\x87\xda\xba\xae\xab\x05\x79\x27\xaf\xbf\xff\x61\xff\x67\x63" "\x6f\x7f\xf7\xcd\x3f\xc9\xc8\xf7\xbf\x8d\x25\x71\x3c\x5e\xcd\x9e\xb8\xf4" "\x3a\x36\xca\x60\x0c\x36\xbe\x27\xc9\xca\xa2\xbe\x63\x1b\x5d\x59\x49\x3a" "\xb2\x9f\x93\xa5\x2f\x71\xd2\x59\x62\x83\x58\x97\xfc\xf5\xeb\x8a\x88\xa7" "\xa2\x3f\x3a\xe2\xfe\x8b\xd7\x1f\x9f\xbe\x56\x6a\xe3\x80\x4d\x55\x4f\x22" "\xea\x40\x45\x25\xe2\x1f\x2a\x2a\x1f\x07\xe4\xef\xed\x97\xbf\x0f\xae\x95" "\x32\x2a\x01\xb6\xc2\xdd\x13\x0b\x13\x00\x2b\xe3\xbf\x73\x61\x6e\x30\x7a" "\x1a\x73\x03\x3b\xef\x25\xb1\x74\x5a\x27\x89\x88\xf6\x66\xe6\x9a\xed\x8a" "\x88\xdb\xb7\xc6\xae\x9f\xb9\x35\x76\x3d\x36\x69\x1e\x0e\x28\x36\x7f\x2d" "\x22\x9e\x2e\x8a\xff\xa4\x11\xff\x03\xd1\x13\x03\x8d\xf8\xaf\x35\xc5\x7f" "\x3a\x2e\x38\x95\x7d\x4d\xf3\x5f\x6f\xb3\xfe\xe5\x53\xc5\xe2\x1f\xb6\xce" "\x42\xfc\xf7\xac\x1a\xff\xd1\x22\xfe\xdf\x59\x12\xff\xef\xb6\x59\xff\xe0" "\xfd\xe4\x7b\xbd\x4d\xf1\xdf\xdb\xee\x25\x01\x00\x00\x00\x00\x00\x40\x65" "\xdd\x3c\x11\x11\x2f\x16\xfd\xfd\xbf\xb6\xb8\xfe\x27\x0a\xd6\xff\xf4\x45" "\xc4\xf1\x0d\xa8\x7f\x70\xd9\xf1\xca\xbf\xff\xd7\xee\x6c\x40\x35\x40\x81" "\xbb\x27\x22\x5e\x29\x5c\xff\x5b\xcb\x57\xff\x0e\x74\x64\xa9\xc7\x1a\xeb" "\x01\xba\x92\x33\xe7\xa6\x26\x0f\x45\xc4\xe3\x11\x71\x20\xba\x76\xa4\xc7" "\x23\xab\xd4\x71\xf0\xf3\x3d\x5f\xb7\x2a\x1b\xcc\xd6\xff\xe5\x8f\xb4\xfe" "\xdb\xd9\x5a\xc0\xac\x1d\x77\x3a\x77\x34\x9f\x33\x31\x3e\x3b\xfe\xb0\xd7" "\x0d\x44\xdc\xbd\x16\xf1\x4c\xe1\xfa\xdf\x64\xb1\xff\x4f\x0a\xfa\xff\xf4" "\xf7\xc1\xf4\x03\xd6\xb1\xe7\xf9\x1b\xa7\x5a\x95\xad\x1d\xff\xc0\x66\xa9" "\x7f\x1b\xb1\xbf\xb0\xff\xbf\x7f\xd7\x8a\x64\xf5\xfb\x73\x0c\x37\xc6\x03" "\xc3\xf9\xa8\x60\xa5\x67\x3f\xfe\xe2\x87\x56\xf5\xb7\x1b\xff\x6e\x31\x01" "\x0f\x2f\xed\xff\x77\xae\x1e\xff\x03\xc9\xd2\xfb\xf5\xcc\xac\xbf\x8e\xc3" "\x73\x9d\xf5\x56\x65\xed\x8e\xff\xbb\x93\x37\x1b\xb7\x9c\xe9\xce\xf2\x3e" "\x1a\x9f\x9d\xbd\x3c\x12\xd1\x9d\x9c\xec\x48\x73\x9b\xf2\x47\xd7\xdf\x66" "\x78\x14\xe5\xf1\x90\xc7\x4b\x1a\xff\x07\x9e\x5b\x7d\xfe\xaf\x68\xfc\xdf" "\x1b\x11\xf3\xcb\xfe\xef\xe4\xaf\xe6\x3d\xc5\xb9\x27\xff\xed\xfb\xbd\x55" "\x7b\x8c\xff\xa1\x3c\x69\xfc\x4f\xac\xab\xff\x5f\x7f\x62\xf4\xc6\xc0\x8f" "\xad\xea\x7f\xb0\xfe\xff\x48\xa3\xaf\x3f\x90\xe5\x98\xff\x83\x05\x5f\xe5" "\x61\xda\xdd\x9c\x5f\x10\x8e\x9d\x45\x45\x5b\xdd\x5e\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x78\x14\xd4\x22\x62\x57\x24\xb5\xa1\xc5\x74\xad\x36\x34\x14\xd1" "\x17\x11\x4f\xc4\xce\xda\xd4\xa5\x99\xd9\x17\xce\x5c\xfa\xe0\xe2\x44\x5a" "\xd6\xf8\xfc\xff\x5a\xfe\x49\xbf\xfd\x0b\xc7\x49\xfe\xf9\xff\x03\x4b\x8e" "\x47\x97\x1d\x1f\x8e\x88\xdd\x11\xf1\x65\x47\x6f\xe3\x78\xe8\xf4\xa5\xa9" "\x89\xb2\x2f\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\xb6\x89\xbe\x16\xfb\xff\x53\x7f\x74\x94\xdd\x3a\x60\xd3\x75\x96\xdd" "\x00\xa0\x34\x05\xf1\xff\x4b\x19\xed\x00\xb6\x9e\xfe\x1f\xaa\x4b\xfc\x43" "\x75\x89\x7f\xa8\x2e\xf1\x0f\xd5\x25\xfe\xa1\xba\xc4\x3f\x54\x97\xf8\x87" "\xea\x12\xff\x00\x00\x00\x00\x00\xf0\x48\xd9\xbd\xef\xe6\xaf\x49\x44\xcc" "\xbf\xdc\xdb\x78\xa4\xba\xb3\xb2\xae\x52\x5b\x06\x6c\xb6\x5a\xd9\x0d\x00" "\x4a\xe3\x16\x3f\x50\x5d\x96\xfe\x40\x75\x79\x8f\x0f\x24\x6b\x94\xf7\xb4" "\x3c\x69\xad\x33\x57\x33\x7d\xfa\x21\x4e\x06\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x80\xca\xd9\xbf\xd7\xfe\x7f\xa8\x2a\xfb\xff\xa1\xba\xec\xff\x87" "\xea\xca\xf7\xff\xef\x2b\xb9\x1d\xc0\xd6\xf3\x1e\x1f\x88\x35\x76\xf2\x17" "\xee\xff\x5f\xf3\x2c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x60\x23\xcd" "\xcc\x5d\x39\x3f\x3e\x35\x35\x79\x59\xe2\xad\xed\xd1\x8c\xad\x4c\xd4\xeb" "\xf5\xab\xe9\x4f\xc1\x76\x69\xcf\xff\x3c\x91\x2f\x85\xdf\x2e\xed\x59\x96" "\xc8\xf7\xfa\x3d\xd8\x59\xe5\xfd\x4e\x02\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x9a\xfd\x17\x00\x00\xff\xff\x16\x12" "\x24\xc5", 1496)); NONFAILING(syz_mount_image(/*fs=*/0x200000000140, /*dir=*/0x2000000005c0, /*flags=MS_REC*/ 0x4000, /*opts=*/0x200000000380, /*chdir=*/0xd, /*size=*/0x5d8, /*img=*/0x200000000c00)); NONFAILING(memcpy((void*)0x200000000100, "./bus\000", 6)); NONFAILING(syz_mount_image(/*fs=*/0, /*dir=*/0x200000000100, /*flags=MS_REC|MS_NODIRATIME*/ 0x4800, /*opts=*/0, /*chdir=*/0, /*size=*/0, /*img=*/0x200000000000)); NONFAILING(memcpy((void*)0x2000000000c0, "ext4\000", 5)); NONFAILING(memcpy((void*)0x2000000001c0, "./bus\000", 6)); NONFAILING(*(uint8_t*)0x200000000080 = 0); NONFAILING(memcpy( (void*)0x200000000f40, "\x78\x9c\xec\xdd\x5f\x6b\x2c\x67\x19\x00\xf0\x67\x36\xbb\xc7\x93\x73\x72" "\x9a\x54\xbd\xd0\x82\xb5\xda\x4a\xce\x41\xcf\x6e\xd2\xd8\x36\x78\x51\x2b" "\x88\x5e\x15\xd4\x7a\x5f\x63\xb2\x09\x21\x9b\x6c\xc8\x6e\xda\x93\x50\x4c" "\x0e\x7e\x00\x41\x44\x05\xaf\xf4\xc6\x1b\xc1\x0f\x20\x48\xc1\x1b\x2f\x45" "\x28\xe8\xb5\xa2\xa2\x88\x9e\xea\x85\x17\xda\x91\xd9\x9d\x4d\x73\x92\xfd" "\xd7\x76\x93\x4d\x93\xdf\x0f\x26\xf3\xbe\x33\xef\xcc\xf3\xbc\x1b\x66\x76" "\x66\x67\x98\x09\xe0\xca\x7a\x22\x22\x5e\x88\x88\xb7\xd2\x34\xbd\x13\x11" "\xd3\xf9\xf4\x42\x3e\xc4\x61\x7b\xc8\xda\xbd\xf9\xe0\xb5\xe5\x6c\x48\x22" "\x4d\x5f\xfa\x47\x12\x49\x3e\xad\xb3\xae\x24\x1f\xdf\xcc\x17\xbb\x1e\x11" "\x5f\xfb\x72\xc4\x37\x93\xd3\x71\x1b\x7b\xfb\x1b\x4b\xb5\x5a\x75\x27\xaf" "\x57\x9a\x9b\xdb\x95\xc6\xde\xfe\xdd\xf5\xcd\xa5\xb5\xea\x5a\x75\x6b\x61" "\x61\xfe\xd9\xc5\xe7\x16\x9f\x59\x9c\x1b\x49\x3f\x6f\x45\xc4\xf3\x5f\xfc" "\xcb\xf7\xbf\xf3\xd3\x2f\x3d\xff\xcb\xcf\xbc\xfa\xc7\x97\xff\x76\xfb\x5b" "\x59\x5a\x53\xf9\xfc\xe3\xfd\x78\x87\x8a\xfd\x66\xb6\xbb\x5e\x6a\x7d\x16" "\xc7\x17\xd8\x79\x97\xc1\x2e\xa2\x62\xab\x87\xb9\xc9\x6e\x2d\x26\x4e\x4d" "\xb9\x7f\xc6\x39\x01\x00\xd0\x5d\x76\x8c\xff\xc1\x88\xf8\x64\x44\xdc\x89" "\xe9\x98\xe8\x7f\x38\x0b\x00\x00\x00\xbc\x0f\xa5\x9f\x9f\x8a\xff\x26\x11" "\x69\x77\xd7\x7a\x4c\x07\x00\x00\x00\xde\x47\x0a\xad\x7b\x60\x93\x42\x39" "\xbf\x17\x60\x2a\x0a\x85\x72\xb9\x7d\x0f\xef\x87\xe3\x46\xa1\x56\x6f\x34" "\x3f\xbd\x5a\xdf\xdd\x5a\x69\xdf\x2b\x3b\x13\xa5\xc2\xea\x7a\xad\x3a\x97" "\xdf\x2b\x3c\x13\xa5\x24\xab\xcf\xb7\xca\x6f\xd7\x9f\x3e\x51\x5f\x88\x88" "\x47\x23\xe2\x7b\xd3\x93\xad\x7a\x79\xb9\x5e\x5b\x19\xf7\x8f\x1f\x00\x00" "\x00\x70\x45\xdc\x3c\x71\xfe\xff\xef\xe9\xf6\xf9\x7f\xc7\xc1\x38\x93\x03" "\x00\x00\x00\x46\x67\x66\xdc\x09\x00\x00\x00\x00\x67\x6e\xd8\xf3\xff\x1b" "\x67\x9c\x07\x00\x00\x00\x70\x76\x5c\xff\x07\x00\x00\x80\x4b\xed\x2b\x2f" "\xbe\x98\x0d\x69\xe7\xfd\xd7\x2b\xaf\xec\xed\x6e\xd4\x5f\xb9\xbb\x52\x6d" "\x6c\x94\x37\x77\x97\xcb\xcb\xf5\x9d\xed\xf2\x5a\xbd\xbe\xd6\x7a\x66\xdf" "\xe6\xa0\xf5\xd5\xea\xf5\xed\xcf\xc6\xd6\xee\xbd\x4a\xb3\xda\x68\x56\x1a" "\x7b\xd7\x63\xb3\xbe\xbb\xd5\x7c\x79\xfd\xa1\x57\x60\x03\x00\x00\x00\xe7" "\xe8\xd1\x8f\xbf\xfe\xfb\x24\x22\x0e\x3f\x37\xd9\x1a\x32\xd7\x86\x5b\x74" "\xc8\x66\xc0\x45\x55\x3c\x2a\x25\xf9\xb8\xcb\x66\xfd\x87\x47\xda\xe3\x3f" "\x9f\x53\x52\xc0\xb9\x98\x18\x77\x02\xc0\xd8\x14\xc7\x9d\x00\x30\x36\xa5" "\x71\x27\x00\x8c\x5d\x32\x60\x7e\xcf\x9b\x77\x7e\x93\x8f\x3f\x31\xda\x7c" "\x00\x00\x80\xd1\x9b\xfd\x68\xef\xeb\xff\x85\xbe\x4b\x1e\xf6\x9f\x0d\x5c" "\x78\x36\x62\xb8\xba\x5c\xff\x87\xab\xab\x75\xfd\x7f\xd8\x3b\x79\x1d\x2c" "\xc0\xa5\x52\x1a\x74\x04\xd0\x77\x9b\x3f\x18\x71\x36\xc0\x38\xbc\xe7\xeb" "\xff\x03\xa5\xe9\x3b\x4a\x08\x00\x00\x18\xb9\xa9\xd6\x90\x14\xca\xc5\x4e" "\xbd\x50\x28\x97\x23\x6e\xb5\x5e\x0b\x50\x4a\x56\xd7\x6b\xd5\xb9\x88\x78" "\x24\x22\x7e\x37\x5d\xfa\x40\x56\x9f\x6f\xb5\x4c\x06\x9e\x33\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x6d" "\x69\x9a\x44\x0a\x00\x00\x00\x5c\x6a\x11\x85\xbf\x26\xbf\x6a\x3f\xcb\x7f" "\x76\xfa\xa9\xa9\x93\xbf\x0f\x5c\x4b\xfe\x33\x1d\xf9\x2b\x42\x5f\xfd\xd1" "\x4b\x3f\xb8\xb7\xd4\x6c\xee\xcc\x67\xd3\xff\x79\x34\xbd\xf9\xc3\x7c\xfa" "\xd3\xe3\xf8\x05\x03\x00\x00\x00\xae\x84\x01\x2f\xf0\x7f\x58\xe7\x3c\xbd" "\x73\x1e\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\xa3\xf4\xe6\x83\xd7\x96\x3b\xc3\x79\xc6\xfd\xfb\x17\x22" "\x62\xa6\x5b\xfc\x62\x5c\x6f\x8d\xaf\x47\x29\x22\x6e\xfc\x2b\x89\xe2\xb1" "\xe5\x92\x88\x98\x18\x41\xfc\xc9\xec\xcf\x47\xba\xc5\x4f\xb2\xb4\x8e\x42" "\x76\x8b\x3f\x39\x82\xf8\x87\xf7\xfb\xc6\x8f\xc3\xfc\x53\xe8\x16\xff\xe6" "\x08\xe2\xc3\x55\xf6\x7a\xb6\xff\x79\xa1\xdb\xf6\x57\x88\x27\x5a\xe3\xee" "\xdb\x5f\x31\xe2\xa1\xfa\xbb\xd5\x7b\xff\x17\x47\xfb\xbf\x89\x1e\xdb\xff" "\xad\x21\x63\x3c\xf6\xc6\xcf\x2b\x3d\xe3\xdf\x8f\x78\xac\x78\x2a\xfe\x41" "\x16\xa1\x13\x3f\xe9\x11\xff\xc9\x21\xe3\x7f\xe3\xeb\xfb\xfb\xbd\xe6\xa5" "\x3f\x8e\x98\xed\xfa\xfd\x93\x74\x9a\x64\x7b\xc8\xa8\x34\x37\xb7\x2b\x8d" "\xbd\xfd\xbb\xeb\x9b\x4b\x6b\xd5\xb5\xea\xd6\xc2\xc2\xfc\xb3\x8b\xcf\x2d" "\x3e\xb3\x38\x57\x59\x5d\xaf\x55\xf3\xbf\x5d\x63\x7c\xf7\x63\xbf\x78\xab" "\x5f\xff\x6f\xf4\x88\x3f\x33\xa0\xff\x4f\x9d\x5a\xdb\xb5\xae\x31\xfe\xf7" "\xc6\xbd\x07\x1f\x6a\x17\x4b\xdd\xe2\xdf\x7e\xb2\x4b\xfc\x5f\xff\x24\x6f" "\x71\x3a\x7e\x21\xff\xee\xfb\x54\x5e\xce\xe6\xcf\x76\xca\x87\xed\xf2\x71" "\x8f\xff\xec\xb7\x8f\xf7\xeb\xff\x4a\x8f\xfe\x0f\xfa\xff\xdf\xee\xb5\xd2" "\x13\xee\x7c\xf5\xdb\x7f\x1a\xb2\x29\x00\x70\x0e\x1a\x7b\xfb\x1b\x4b\xb5" "\x5a\x75\xe7\xd2\x16\xb2\xb3\xf4\x21\x1b\x67\x47\x67\x17\x22\x67\x85\xf3" "\x29\x1c\x8c\x74\x85\x69\x9a\xa6\xd9\x36\xf5\x1e\xd6\x93\xc4\x45\xf8\x58" "\x5a\x85\x71\xef\x99\x00\x00\x80\x51\x7b\xfb\xa0\x7f\xdc\x99\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xd5\x75\x1e\x8f\x13" "\x3b\x19\xf3\xf0\xa8\x94\x8c\xe2\x11\xda\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x23\xf1\xff" "\x00\x00\x00\xff\xff\xec\xd7\xd9\x32", 1323)); NONFAILING(syz_mount_image(/*fs=*/0x2000000000c0, /*dir=*/0x2000000001c0, /*flags=MS_RDONLY|MS_MANDLOCK*/ 0x41, /*opts=*/0x200000000080, /*chdir=*/0x64, /*size=*/0x52b, /*img=*/0x200000000f40)); NONFAILING(memcpy((void*)0x200000000000, ".\000", 2)); res = syscall(__NR_fspick, /*dfd=*/0xffffff9c, /*path=*/0x200000000000ul, /*flags=*/0ul); if (res != -1) r[0] = res; NONFAILING(memcpy((void*)0x200000000080, "/proc/sys/fs/binfmt_misc/register\000", 34)); res = syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0x200000000080ul, /*flags=*/1, /*mode=*/0); if (res != -1) r[1] = res; NONFAILING(*(uint8_t*)0x200000000440 = 0x3a); NONFAILING(memcpy((void*)0x200000000441, "syz1", 4)); NONFAILING(*(uint8_t*)0x200000000445 = 0x3a); NONFAILING(memset((void*)0x200000000446, 77, 1)); NONFAILING(*(uint8_t*)0x200000000447 = 0x3a); NONFAILING(sprintf((char*)0x200000000448, "%020llu", (long long)0)); NONFAILING(*(uint8_t*)0x20000000045c = 0x3a); NONFAILING(memcpy((void*)0x20000000045d, "usrjquota=", 10)); NONFAILING(*(uint8_t*)0x200000000467 = 0x3a); NONFAILING(*(uint8_t*)0x200000000468 = 0x3a); NONFAILING(memcpy((void*)0x200000000469, "./file2", 7)); NONFAILING(*(uint8_t*)0x200000000470 = 0x3a); NONFAILING(*(uint8_t*)0x200000000471 = 0x46); syscall(__NR_write, /*fd=*/r[1], /*data=*/0x200000000440ul, /*len=*/0x32ul); syscall(__NR_fsconfig, /*fd=*/r[0], /*cmd=*/7ul, /*key=*/0ul, /*value=*/0ul, /*aux=*/0ul); } 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; if ((reason = setup_binfmt_misc())) printf("the reproducer may not work as expected: binfmt_misc setup failed: " "%s\n", reason); install_segv_handler(); use_temporary_dir(); do_sandbox_none(); return 0; }