// https://syzkaller.appspot.com/bug?id=7a53091be2839c92272bbbeb7c7e9cf89503b9e8 // 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 #ifndef __NR_io_uring_setup #define __NR_io_uring_setup 425 #endif #ifndef __NR_memfd_create #define __NR_memfd_create 319 #endif static unsigned long long procid; static __thread int clone_ongoing; static __thread int skip_segv; static __thread jmp_buf segv_env; static void segv_handler(int sig, siginfo_t* info, void* ctx) { if (__atomic_load_n(&clone_ongoing, __ATOMIC_RELAXED) != 0) { exit(sig); } uintptr_t addr = (uintptr_t)info->si_addr; const uintptr_t prog_start = 1 << 20; const uintptr_t prog_end = 100 << 20; int skip = __atomic_load_n(&skip_segv, __ATOMIC_RELAXED) != 0; int valid = addr < prog_start || addr > prog_end; if (skip && valid) { _longjmp(segv_env, 1); } exit(sig); } static void install_segv_handler(void) { struct sigaction sa; memset(&sa, 0, sizeof(sa)); sa.sa_handler = SIG_IGN; syscall(SYS_rt_sigaction, 0x20, &sa, NULL, 8); syscall(SYS_rt_sigaction, 0x21, &sa, NULL, 8); memset(&sa, 0, sizeof(sa)); sa.sa_sigaction = segv_handler; sa.sa_flags = SA_NODEFER | SA_SIGINFO; sigaction(SIGSEGV, &sa, NULL); sigaction(SIGBUS, &sa, NULL); } #define NONFAILING(...) \ ({ \ int ok = 1; \ __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST); \ if (_setjmp(segv_env) == 0) { \ __VA_ARGS__; \ } else \ ok = 0; \ __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST); \ ok; \ }) static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static void thread_start(void* (*fn)(void*), void* arg) { pthread_t th; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_setstacksize(&attr, 128 << 10); int i = 0; for (; i < 100; i++) { if (pthread_create(&th, &attr, fn, arg) == 0) { pthread_attr_destroy(&attr); return; } if (errno == EAGAIN) { usleep(50); continue; } break; } exit(1); } typedef struct { int state; } event_t; static void event_init(event_t* ev) { ev->state = 0; } static void event_reset(event_t* ev) { ev->state = 0; } static void event_set(event_t* ev) { if (ev->state) exit(1); __atomic_store_n(&ev->state, 1, __ATOMIC_RELEASE); syscall(SYS_futex, &ev->state, FUTEX_WAKE | FUTEX_PRIVATE_FLAG, 1000000); } static void event_wait(event_t* ev) { while (!__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, 0); } static int event_isset(event_t* ev) { return __atomic_load_n(&ev->state, __ATOMIC_ACQUIRE); } static int event_timedwait(event_t* ev, uint64_t timeout) { uint64_t start = current_time_ms(); uint64_t now = start; for (;;) { uint64_t remain = timeout - (now - start); struct timespec ts; ts.tv_sec = remain / 1000; ts.tv_nsec = (remain % 1000) * 1000 * 1000; syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, &ts); if (__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE)) return 1; now = current_time_ms(); if (now - start > timeout) return 0; } } static bool write_file(const char* file, const char* what, ...) { char buf[1024]; va_list args; va_start(args, what); vsnprintf(buf, sizeof(buf), what, args); va_end(args); buf[sizeof(buf) - 1] = 0; int len = strlen(buf); int fd = open(file, O_WRONLY | O_CLOEXEC); if (fd == -1) return false; if (write(fd, buf, len) != len) { int err = errno; close(fd); errno = err; return false; } close(fd); return true; } #define SIZEOF_IO_URING_SQE 64 #define SIZEOF_IO_URING_CQE 16 #define SQ_HEAD_OFFSET 0 #define SQ_TAIL_OFFSET 64 #define SQ_RING_MASK_OFFSET 256 #define SQ_RING_ENTRIES_OFFSET 264 #define SQ_FLAGS_OFFSET 276 #define SQ_DROPPED_OFFSET 272 #define CQ_HEAD_OFFSET 128 #define CQ_TAIL_OFFSET 192 #define CQ_RING_MASK_OFFSET 260 #define CQ_RING_ENTRIES_OFFSET 268 #define CQ_RING_OVERFLOW_OFFSET 284 #define CQ_FLAGS_OFFSET 280 #define CQ_CQES_OFFSET 320 struct io_sqring_offsets { uint32_t head; uint32_t tail; uint32_t ring_mask; uint32_t ring_entries; uint32_t flags; uint32_t dropped; uint32_t array; uint32_t resv1; uint64_t resv2; }; struct io_cqring_offsets { uint32_t head; uint32_t tail; uint32_t ring_mask; uint32_t ring_entries; uint32_t overflow; uint32_t cqes; uint64_t resv[2]; }; struct io_uring_params { uint32_t sq_entries; uint32_t cq_entries; uint32_t flags; uint32_t sq_thread_cpu; uint32_t sq_thread_idle; uint32_t features; uint32_t resv[4]; struct io_sqring_offsets sq_off; struct io_cqring_offsets cq_off; }; #define IORING_OFF_SQ_RING 0 #define IORING_OFF_SQES 0x10000000ULL #define IORING_SETUP_SQE128 (1U << 10) #define IORING_SETUP_CQE32 (1U << 11) static long syz_io_uring_setup(volatile long a0, volatile long a1, volatile long a2, volatile long a3) { uint32_t entries = (uint32_t)a0; struct io_uring_params* setup_params = (struct io_uring_params*)a1; void** ring_ptr_out = (void**)a2; void** sqes_ptr_out = (void**)a3; setup_params->flags &= ~(IORING_SETUP_CQE32 | IORING_SETUP_SQE128); uint32_t fd_io_uring = syscall(__NR_io_uring_setup, entries, setup_params); uint32_t sq_ring_sz = setup_params->sq_off.array + setup_params->sq_entries * sizeof(uint32_t); uint32_t cq_ring_sz = setup_params->cq_off.cqes + setup_params->cq_entries * SIZEOF_IO_URING_CQE; uint32_t ring_sz = sq_ring_sz > cq_ring_sz ? sq_ring_sz : cq_ring_sz; *ring_ptr_out = mmap(0, ring_sz, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, fd_io_uring, IORING_OFF_SQ_RING); uint32_t sqes_sz = setup_params->sq_entries * SIZEOF_IO_URING_SQE; *sqes_ptr_out = mmap(0, sqes_sz, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_POPULATE, fd_io_uring, IORING_OFF_SQES); uint32_t* array = (uint32_t*)((uintptr_t)*ring_ptr_out + setup_params->sq_off.array); for (uint32_t index = 0; index < entries; index++) array[index] = index; return fd_io_uring; } static long syz_memcpy_off(volatile long a0, volatile long a1, volatile long a2, volatile long a3, volatile long a4) { char* dest = (char*)a0; uint32_t dest_off = (uint32_t)a1; char* src = (char*)a2; uint32_t src_off = (uint32_t)a3; size_t n = (size_t)a4; return (long)memcpy(dest + dest_off, src + src_off, n); } static long syz_open_procfs(volatile long a0, volatile long a1) { char buf[128]; memset(buf, 0, sizeof(buf)); if (a0 == 0) { snprintf(buf, sizeof(buf), "/proc/self/%s", (char*)a1); } else if (a0 == -1) { snprintf(buf, sizeof(buf), "/proc/thread-self/%s", (char*)a1); } else { snprintf(buf, sizeof(buf), "/proc/self/task/%d/%s", (int)a0, (char*)a1); } int fd = open(buf, O_RDWR); if (fd == -1) fd = open(buf, O_RDONLY); return fd; } //% 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; } #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")) { } } #define FUSE_MIN_READ_BUFFER 8192 enum fuse_opcode { FUSE_LOOKUP = 1, FUSE_FORGET = 2, FUSE_GETATTR = 3, FUSE_SETATTR = 4, FUSE_READLINK = 5, FUSE_SYMLINK = 6, FUSE_MKNOD = 8, FUSE_MKDIR = 9, FUSE_UNLINK = 10, FUSE_RMDIR = 11, FUSE_RENAME = 12, FUSE_LINK = 13, FUSE_OPEN = 14, FUSE_READ = 15, FUSE_WRITE = 16, FUSE_STATFS = 17, FUSE_RELEASE = 18, FUSE_FSYNC = 20, FUSE_SETXATTR = 21, FUSE_GETXATTR = 22, FUSE_LISTXATTR = 23, FUSE_REMOVEXATTR = 24, FUSE_FLUSH = 25, FUSE_INIT = 26, FUSE_OPENDIR = 27, FUSE_READDIR = 28, FUSE_RELEASEDIR = 29, FUSE_FSYNCDIR = 30, FUSE_GETLK = 31, FUSE_SETLK = 32, FUSE_SETLKW = 33, FUSE_ACCESS = 34, FUSE_CREATE = 35, FUSE_INTERRUPT = 36, FUSE_BMAP = 37, FUSE_DESTROY = 38, FUSE_IOCTL = 39, FUSE_POLL = 40, FUSE_NOTIFY_REPLY = 41, FUSE_BATCH_FORGET = 42, FUSE_FALLOCATE = 43, FUSE_READDIRPLUS = 44, FUSE_RENAME2 = 45, FUSE_LSEEK = 46, FUSE_COPY_FILE_RANGE = 47, FUSE_SETUPMAPPING = 48, FUSE_REMOVEMAPPING = 49, FUSE_SYNCFS = 50, FUSE_TMPFILE = 51, FUSE_STATX = 52, CUSE_INIT = 4096, CUSE_INIT_BSWAP_RESERVED = 1048576, FUSE_INIT_BSWAP_RESERVED = 436207616, }; struct fuse_in_header { uint32_t len; uint32_t opcode; uint64_t unique; uint64_t nodeid; uint32_t uid; uint32_t gid; uint32_t pid; uint32_t padding; }; struct fuse_out_header { uint32_t len; uint32_t error; uint64_t unique; }; struct syz_fuse_req_out { struct fuse_out_header* init; struct fuse_out_header* lseek; struct fuse_out_header* bmap; struct fuse_out_header* poll; struct fuse_out_header* getxattr; struct fuse_out_header* lk; struct fuse_out_header* statfs; struct fuse_out_header* write; struct fuse_out_header* read; struct fuse_out_header* open; struct fuse_out_header* attr; struct fuse_out_header* entry; struct fuse_out_header* dirent; struct fuse_out_header* direntplus; struct fuse_out_header* create_open; struct fuse_out_header* ioctl; struct fuse_out_header* statx; }; static int fuse_send_response(int fd, const struct fuse_in_header* in_hdr, struct fuse_out_header* out_hdr) { if (!out_hdr) { return -1; } out_hdr->unique = in_hdr->unique; if (write(fd, out_hdr, out_hdr->len) == -1) { return -1; } return 0; } static volatile long syz_fuse_handle_req(volatile long a0, volatile long a1, volatile long a2, volatile long a3) { struct syz_fuse_req_out* req_out = (struct syz_fuse_req_out*)a3; struct fuse_out_header* out_hdr = NULL; char* buf = (char*)a1; int buf_len = (int)a2; int fd = (int)a0; if (!req_out) { return -1; } if (buf_len < FUSE_MIN_READ_BUFFER) { return -1; } int ret = read(fd, buf, buf_len); if (ret == -1) { return -1; } if ((size_t)ret < sizeof(struct fuse_in_header)) { return -1; } const struct fuse_in_header* in_hdr = (const struct fuse_in_header*)buf; if (in_hdr->len > (uint32_t)ret) { return -1; } switch (in_hdr->opcode) { case FUSE_GETATTR: case FUSE_SETATTR: out_hdr = req_out->attr; break; case FUSE_LOOKUP: case FUSE_SYMLINK: case FUSE_LINK: case FUSE_MKNOD: case FUSE_MKDIR: out_hdr = req_out->entry; break; case FUSE_OPEN: case FUSE_OPENDIR: out_hdr = req_out->open; break; case FUSE_STATFS: out_hdr = req_out->statfs; break; case FUSE_RMDIR: case FUSE_RENAME: case FUSE_RENAME2: case FUSE_FALLOCATE: case FUSE_SETXATTR: case FUSE_REMOVEXATTR: case FUSE_FSYNCDIR: case FUSE_FSYNC: case FUSE_SETLKW: case FUSE_SETLK: case FUSE_ACCESS: case FUSE_FLUSH: case FUSE_RELEASE: case FUSE_RELEASEDIR: case FUSE_UNLINK: case FUSE_DESTROY: out_hdr = req_out->init; if (!out_hdr) { return -1; } out_hdr->len = sizeof(struct fuse_out_header); break; case FUSE_READ: out_hdr = req_out->read; break; case FUSE_READDIR: out_hdr = req_out->dirent; break; case FUSE_READDIRPLUS: out_hdr = req_out->direntplus; break; case FUSE_INIT: out_hdr = req_out->init; break; case FUSE_LSEEK: out_hdr = req_out->lseek; break; case FUSE_GETLK: out_hdr = req_out->lk; break; case FUSE_BMAP: out_hdr = req_out->bmap; break; case FUSE_POLL: out_hdr = req_out->poll; break; case FUSE_GETXATTR: case FUSE_LISTXATTR: out_hdr = req_out->getxattr; break; case FUSE_WRITE: case FUSE_COPY_FILE_RANGE: out_hdr = req_out->write; break; case FUSE_FORGET: case FUSE_BATCH_FORGET: return 0; case FUSE_CREATE: out_hdr = req_out->create_open; break; case FUSE_IOCTL: out_hdr = req_out->ioctl; break; case FUSE_STATX: out_hdr = req_out->statx; break; default: return -1; } return fuse_send_response(fd, in_hdr, out_hdr); } 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 < 11; 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 == 6 ? 4000 : 0)); break; } } for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++) sleep_ms(1); } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { int iter = 0; for (;; iter++) { char cwdbuf[32]; sprintf(cwdbuf, "./%d", iter); if (mkdir(cwdbuf, 0777)) exit(1); reset_loop(); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { if (chdir(cwdbuf)) exit(1); setup_test(); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } remove_dir(cwdbuf); } } uint64_t r[3] = {0x0, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: // syz_io_uring_setup arguments: [ // entries: int32 = 0x1eae (4 bytes) // params: ptr[inout, io_uring_params] { // io_uring_params { // sq_entries: int32 = 0x0 (4 bytes) // cq_entries: int32 = 0x9d2d (4 bytes) // flags: io_uring_setup_flags = 0x3100 (4 bytes) // sq_thread_cpu: int32 = 0x2 (4 bytes) // sq_thread_idle: int32 = 0x800335 (4 bytes) // features: int32 = 0x0 (4 bytes) // wq_fd: fd_io_uring (resource) // resv: buffer: {00 00 00 00 00 00 00 00 00 00 00 00} (length 0xc) // sq_off: array[int32] { // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // } // cq_off: array[int32] { // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // int32 = 0x0 (4 bytes) // } // } // } // ring_ptr: ptr[out, ring_ptr] { // ring_ptr (resource) // } // sqes_ptr: ptr[out, sqes_ptr] { // sqes_ptr (resource) // } // ] // returns fd_io_uring NONFAILING(*(uint32_t*)0x2000000001c4 = 0x9d2d); NONFAILING(*(uint32_t*)0x2000000001c8 = 0x3100); NONFAILING(*(uint32_t*)0x2000000001cc = 2); NONFAILING(*(uint32_t*)0x2000000001d0 = 0x800335); NONFAILING(*(uint32_t*)0x2000000001d8 = -1); NONFAILING(memset((void*)0x2000000001dc, 0, 12)); res = -1; NONFAILING(res = syz_io_uring_setup( /*entries=*/0x1eae, /*params=*/0x2000000001c0, /*ring_ptr=*/0x200000000080, /*sqes_ptr=*/0x200000001080)); if (res != -1) NONFAILING(r[0] = *(uint64_t*)0x200000000080); break; case 1: // syz_fuse_handle_req arguments: [ // fd: fd_fuse (resource) // buf: nil // len: bytesize = 0x0 (8 bytes) // res: nil // ] NONFAILING(syz_fuse_handle_req(/*fd=*/-1, /*buf=*/0, /*len=*/0, /*res=*/0)); break; case 2: // syz_fuse_handle_req arguments: [ // fd: fd_fuse (resource) // buf: nil // len: bytesize = 0x0 (8 bytes) // res: nil // ] NONFAILING(syz_fuse_handle_req(/*fd=*/-1, /*buf=*/0, /*len=*/0, /*res=*/0)); break; case 3: // syz_memcpy_off$IO_URING_METADATA_GENERIC arguments: [ // ring_ptr: ring_ptr (resource) // off: io_uring_offsets = 0x40 (8 bytes) // src: ptr[in, int32] { // int32 = 0xfffffffc (4 bytes) // } // src_off: const = 0x0 (8 bytes) // nbytes: const = 0x4 (8 bytes) // ] NONFAILING(*(uint32_t*)0x200000000180 = 0xfffffffc); NONFAILING(syz_memcpy_off(/*ring_ptr=*/r[0], /*off=SQ_TAIL_OFFSET*/ 0x40, /*src=*/0x200000000180, /*src_off=*/0, /*nbytes=*/4)); break; case 4: // syz_open_procfs arguments: [ // pid: pid (resource) // file: ptr[in, buffer] { // buffer: {66 64 69 6e 66 6f 2f 33 00} (length 0x9) // } // ] // returns fd NONFAILING(memcpy((void*)0x200000000080, "fdinfo/3\000", 9)); res = -1; NONFAILING(res = syz_open_procfs(/*pid=*/0, /*file=*/0x200000000080)); if (res != -1) r[1] = res; break; case 5: // read$eventfd arguments: [ // fd: fd_event (resource) // val: ptr[out, int64] { // int64 = 0x0 (8 bytes) // } // len: len = 0xfffffd79 (8 bytes) // ] syscall(__NR_read, /*fd=*/r[1], /*val=*/0x200000000100ul, /*len=*/0xfffffd79ul); break; case 6: // 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 30 00} (length 0x8) // } // flags: mount_flags = 0x14444 (8 bytes) // opts: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {69 6f 63 68 61 72 73 65 74 3d 61 73 63 69 69 // 2c 6e 6f 61 64 69 6e 69 63 62 00 00 64 69 6e 69 63 62 2c 67 69 // 64 3d 69 67 6e 6f 72 65 2c 75 69 64 3d 66 6f 72 67 65 74 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 32 2c 07 6f 6e 67 61 64 2c 67 69 64 3d 77 1d // 0f 4d 30 dc 61 46 9a 58 13 42 d9 8a 7a 4c 35 34 a9 71 c3 e2 6d // e7 2e dc 9e c3 db 40 3d 8b 2e 97 0b 9d ce a4 48 dd bb 5a 11 6c // e6 f6 7d 99 a7 7a a5 0b ce 7f c5 45 1b cf 5b 13 e9 69 8d 80 38 // 5c 54 ff f7 7d 38 aa 97 03 31 4c d1 9a 07 58 93 a1 64 8d d8 ef // 78 a1 18 12 2e e7 a0 e4 00 00 00 00 00 00 00 00 00 00 00 00} // (length 0xcb) // } // union ANYUNION { // ANYRESDEC: ANYRES64 (resource) // } // union ANYUNION { // ANYBLOB: buffer: {2c 6e 6f 73 74 72 69 63 74 2c 00} (length 0xb) // } // } // } // chdir: int8 = 0xfd (1 bytes) // size: len = 0xc22 (8 bytes) // img: ptr[in, buffer] { // buffer: (compressed buffer with length 0xc22) // } // ] // returns fd_dir NONFAILING(memcpy((void*)0x200000000100, "udf\000", 4)); NONFAILING(memcpy((void*)0x200000000f00, "./file0\000", 8)); NONFAILING(memcpy( (void*)0x200000001d80, "\x69\x6f\x63\x68\x61\x72\x73\x65\x74\x3d\x61\x73\x63\x69\x69\x2c\x6e" "\x6f\x61\x64\x69\x6e\x69\x63\x62\x00\x00\x64\x69\x6e\x69\x63\x62\x2c" "\x67\x69\x64\x3d\x69\x67\x6e\x6f\x72\x65\x2c\x75\x69\x64\x3d\x66\x6f" "\x72\x67\x65\x74\x2c\x75\x6d\x61\x73\x6b\x3d\x30\x30\x30\x30\x30\x30" "\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x30\x32" "\x2c\x07\x6f\x6e\x67\x61\x64\x2c\x67\x69\x64\x3d\x77\x1d\x0f\x4d\x30" "\xdc\x61\x46\x9a\x58\x13\x42\xd9\x8a\x7a\x4c\x35\x34\xa9\x71\xc3\xe2" "\x6d\xe7\x2e\xdc\x9e\xc3\xdb\x40\x3d\x8b\x2e\x97\x0b\x9d\xce\xa4\x48" "\xdd\xbb\x5a\x11\x6c\xe6\xf6\x7d\x99\xa7\x7a\xa5\x0b\xce\x7f\xc5\x45" "\x1b\xcf\x5b\x13\xe9\x69\x8d\x80\x38\x5c\x54\xff\xf7\x7d\x38\xaa\x97" "\x03\x31\x4c\xd1\x9a\x07\x58\x93\xa1\x64\x8d\xd8\xef\x78\xa1\x18\x12" "\x2e\xe7\xa0\xe4\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 203)); NONFAILING(sprintf((char*)0x200000001e4b, "%020llu", (long long)-1)); NONFAILING(memcpy((void*)0x200000001e5f, ",nostrict,\000", 11)); NONFAILING(memcpy( (void*)0x2000000002c0, "\x78\x9c\xec\xdd\x41\x6c\x1c\xd7\x7d\x07\xe0\xff\x1b\x2d\x45\x4a\x6e" "\x2b\x26\x4e\x54\xbb\x8d\xdb\x4d\x5b\xa4\x32\x63\xb9\xb2\xa4\x98\x8a" "\x55\xb8\xab\x9a\x66\x1b\x40\x96\x89\x50\xcc\x2d\x00\x57\xe4\x4a\x5d" "\x98\x22\x09\x92\x6a\x64\x23\x6d\x98\x5e\x7a\xe8\x21\x40\x51\xf4\x90" "\x13\x81\xd6\x28\x90\xa2\x81\xd1\x14\x41\x8f\x6c\xeb\x02\xc9\xc5\x87" "\x22\xa7\x9e\x88\x16\x36\x82\xa2\x07\xb6\x08\x90\x53\xc0\x60\x66\xdf" "\x8a\x4b\x8a\xb2\x68\x53\xa4\x28\xfb\xfb\x6c\xea\x37\x3b\xf3\xde\xcc" "\x7b\x33\xeb\x19\x59\xd0\x9b\x17\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x40\xc4\xef\xbf\x7c\xe9\xcc\x73\xe9\x61\xb7\x02" "\x00\x38\x48\x57\xc6\xbf\x7c\xe6\xac\xe7\x3f\x00\x7c\xac\x5c\xf5\xff" "\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x70\xd8\xa5\x28\xe2" "\xf1\x48\x31\x7f\x65\x3d\x4d\x56\x9f\x3b\x06\x2e\xb7\x67\x6f\xdd\x9e" "\x18\x19\xdd\xb9\xda\xb1\x54\xd5\x3c\x52\x95\x2f\x7f\x06\x9e\x3b\x7b" "\xee\xfc\x17\x9e\x1f\xbe\xd0\xcd\xf7\xaf\xff\xa0\x3d\x19\xaf\x8e\x5f" "\xbd\x54\x7f\x69\xee\xe6\xfc\x42\x6b\x71\xb1\x35\x5d\x9f\x98\x6d\x4f" "\xcd\x4d\xb7\x76\xbd\x87\xbd\xd6\xdf\x6e\xa8\x3a\x01\xf5\x9b\xaf\xdd" "\x9a\xbe\x7e\x7d\xb1\x7e\xf6\xd9\x73\x5b\x36\xdf\x1e\x7c\xaf\xff\xb1" "\x93\x83\x17\x87\x9f\x3e\xfd\x54\xb7\xec\xc4\xc8\xe8\xe8\x78\x4f\x99" "\x5a\xdf\x87\x3e\xfa\x5d\xee\x35\xc2\xe3\x68\x14\x71\x3a\x52\x3c\xf3" "\xdd\x1f\xa7\x66\x44\x14\xb1\xf7\x73\x71\x9f\xef\xce\x7e\x3b\x56\x75" "\x62\xa8\xea\xc4\xc4\xc8\x68\xd5\x91\x99\x76\x73\x76\xa9\xdc\x38\xd6" "\x3d\x11\x45\x44\xbd\xa7\x52\xa3\x7b\x8e\x0e\xe0\x5a\xec\x49\x23\x62" "\xb9\x6c\x7e\xd9\xe0\xa1\xb2\x7b\xe3\xf3\xcd\x85\xe6\xb5\x99\x56\x7d" "\xac\xb9\xb0\xd4\x5e\x6a\xcf\xcd\x8e\xa5\x4e\x6b\xcb\xfe\xd4\xa3\x88" "\x0b\x29\x62\x25\x22\xd6\xfa\xef\xde\x5d\x5f\x14\x51\x8b\x14\xdf\x3e" "\xb1\x9e\xae\x45\xc4\x91\xee\x79\xf8\x7c\x35\x30\xf8\xde\xed\x28\xf6" "\xb1\x8f\xbb\x50\xb6\xb3\xde\x17\xb1\x52\x3c\x02\xd7\xec\x10\xeb\x8f" "\x22\x5e\x89\x14\x3f\x79\xbb\x88\xa9\xf2\x9c\xe5\x9f\xf8\x5c\xc4\x2b" "\x65\x7e\x3f\xe2\xcd\x32\x5f\x8c\x48\xe5\x17\xe3\x7c\xc4\xbb\x3b\x7c" "\x8f\x78\x34\xd5\xa2\x88\xbf\x28\xaf\xff\xc5\xf5\x34\x1d\x11\x1b\x27" "\x3a\xeb\x47\xeb\x97\xbf\x52\xff\xd2\xec\xf5\xb9\x9e\xb2\xdd\xfb\xca" "\x23\xff\x7c\x38\x48\x87\xfc\xde\x34\x10\x45\x34\xab\x3b\xfe\x7a\xfa" "\xf0\xbf\xd9\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe0" "\x41\x3b\x16\x45\x3c\x19\x29\x5e\xfe\x8f\x3f\xae\xc6\x15\x47\x35\x2e" "\xfd\xc4\xc5\xe1\x3f\x18\xfc\xc5\xde\x31\xe3\x4f\xdc\x67\x3f\x65\xd9" "\x67\x23\x62\xb9\xd8\xdd\x98\xdc\xa3\x79\x08\xf1\x58\x1a\x4b\xe9\x21" "\x8f\x25\xfe\x38\x1b\x88\x22\xfe\x24\x8f\xff\xfb\xe6\xc3\x6e\x0c\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xc7\x5a\x11" "\x3f\x8a\x14\x2f\xbc\x73\x2a\xad\x44\xef\x9c\xe2\xed\xd9\x1b\xf5\xab" "\xcd\x6b\x33\x9d\x59\x61\xbb\x73\xff\x76\xe7\x4c\xdf\xd8\xd8\xd8\xa8" "\xa7\x4e\x36\x72\x4e\xe6\x5c\xce\xb9\x92\x73\x35\xe7\x5a\xce\x28\x72" "\xfd\x9c\x8d\x9c\x93\x39\x97\x73\xae\xe4\x5c\xcd\xb9\x96\x33\x8e\xe4" "\xfa\x39\x1b\x39\x27\x73\x2e\xe7\x5c\xc9\xb9\x9a\x73\x2d\x67\xd4\x72" "\xfd\x9c\x8d\x9c\x93\x39\x97\x73\xae\xe4\x5c\xcd\xb9\x96\x33\x0e\xc9" "\xdc\xbd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x25" "\x45\x14\xf1\xb3\x48\xf1\xad\xaf\xad\xa7\x48\x11\xd1\x88\x98\x8c\x4e" "\xae\xf6\x77\xcb\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x0f\x53\x7f\x2a\xe2\x7b\x91\xa2\xfe\x87\x8d\x3b\xeb\x6a\x11\x91" "\xaa\x7f\x3b\x4e\x95\xbf\x9c\x8f\xc6\xd1\x32\x3f\x19\x8d\xe1\x32\x5f" "\x8c\xc6\xa5\x9c\xcd\x2a\x6b\x8d\x6f\xde\xf7\x68\x69\x5f\xfa\xc0\x87" "\xd7\x97\x8a\xf8\x61\xa4\xe8\x1f\x78\xeb\xce\xd5\xc9\xd7\xbf\xaf\xf3" "\x69\xf3\x9a\xbd\xf9\xf5\xcd\x4f\xbf\x52\xeb\xe4\x91\xee\xc6\xc1\xf7" "\xfa\x1f\x3b\x79\xe2\xe2\xf0\xe8\xaf\x3d\x71\xaf\xe5\x1d\xaf\xfe\xd0" "\xe5\xf6\xec\xad\xdb\xf5\x89\x91\xd1\xd1\xf1\x9e\xd5\xb5\x7c\xf4\x4f" "\xf6\xac\x1b\xcc\xc7\x2d\x1e\x4c\xd7\x89\x88\xc5\xd7\xdf\x78\xad\x39" "\x33\xd3\x5a\xb0\xf0\xf1\x58\xa8\x75\x16\x6a\x71\x48\xda\x73\x50\x0b" "\xf9\x7e\x15\x87\xa5\x3d\xdb\x17\x1a\x87\xa3\x19\x9b\x0b\x0f\xf9\xc6" "\xc4\x81\x28\x9f\xff\xef\x46\x8a\xdf\x79\xe7\x3f\xbb\x0f\xfc\xee\xf3" "\xff\x17\x3a\x9f\xee\x3c\xe1\xe3\xa7\x7f\xba\xf9\xfc\x7f\x61\xfb\x8e" "\xf6\xe9\xf9\xff\x78\xcf\xba\x17\xf2\xef\x46\xfa\x6a\x11\x03\x4b\x37" "\xe7\xfb\x4e\x46\x0c\x2c\xbe\xfe\xc6\xe9\xf6\xcd\xe6\x8d\xd6\x8d\xd6" "\xec\xf9\x33\x67\xbe\x38\x3c\xfc\xc5\x73\x67\xfa\x8e\x46\x0c\x5c\x6f" "\xcf\xb4\x7a\x96\xf6\x7c\xaa\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x0e\x56\x2a\xe2\xf7\x22\x45\xf3\x87\xeb\xa9\x1e\x11\xb7" "\xab\xf1\x5a\x83\x17\x87\x9f\x3e\xfd\xd4\x91\x38\x52\x8d\xb7\xda\x32" "\x6e\xeb\xd5\xf1\xab\x97\xea\x2f\xcd\xdd\x9c\x5f\x68\x2d\x2e\xb6\xa6" "\xeb\x13\xb3\xed\xa9\xb9\xe9\xd6\x6e\x0f\x37\x50\x0d\xf7\x9a\x18\x19" "\xdd\x97\xce\xdc\xd7\xb1\x7d\x6e\xff\xb1\x81\x97\xe6\xe6\x5f\x5f\x68" "\xdf\xf8\xa3\xa5\x1d\xb7\x1f\x1f\xb8\x74\x6d\x71\x69\xa1\x39\xb5\xf3" "\xe6\x38\x16\x45\x44\xa3\x77\xcd\x50\xd5\xe0\x89\x91\xd1\xaa\xd1\x33" "\xed\xe6\x6c\x55\x75\xec\x01\xbd\x4a\xa1\x2f\x15\xf1\x5f\x91\x62\xea" "\x7c\x3d\x7d\x36\xaf\xcb\xe3\xff\xb6\x8f\xf0\xdf\x32\xfe\x7f\x79\xfb" "\x8e\xf6\x69\xfc\xdf\x27\x7a\xd6\x95\xc7\x4c\xa9\x88\x9f\x46\x8a\xdf" "\xfe\xcb\x27\xe2\xb3\x55\x3b\x8f\xc7\x5d\xe7\x2c\x97\xfb\xdb\x48\x31" "\x74\xe1\x33\xb9\x5c\x1c\x2d\xcb\x75\xdb\xd0\x79\xaf\x40\x67\x64\x60" "\x59\xf6\xff\x22\xc5\x3f\xfe\x6c\x6b\xd9\xee\x78\xc8\xc7\x37\xcb\x3e" "\xb7\xeb\x13\xfb\x88\x28\xaf\xff\x89\x48\xf1\xbd\x3f\xff\x4e\xfc\x46" "\x5e\xb7\xf5\xfd\x0f\x3b\x5f\xff\xe3\xdb\x77\xb4\x4f\xd7\xff\x53\x3d" "\xeb\x8e\x6f\x79\x5f\xc1\x9e\xbb\x4e\xbe\xfe\xa7\x23\xc5\x8b\x8f\xbf" "\x15\xbf\x99\xd7\xbd\xdf\xfb\x3f\x8a\xd8\xd8\xd8\xf8\x46\xc4\xa9\x5c" "\xf8\xce\xfb\x39\xf6\xe9\xfa\x7f\xba\x67\xdd\x60\x74\x8e\xfb\x5b\x0f" "\xae\xfb\x00\x00\x00\x00\x00\x00\x00\x00\x00\x8f\xac\xbe\x54\xc4\xdf" "\x45\x8a\xa7\x46\x6b\xe9\xf9\xbc\x6e\x37\x7f\xff\x6f\x7a\xfb\x8e\xf6" "\xe9\xef\x7f\xfd\x72\xcf\xba\xe9\x03\x9a\xaf\x68\xcf\x27\x15\x00\x00" "\x00\x00\x0e\x89\xbe\x54\xc4\x8f\x22\xc5\x8d\xa5\xb7\xee\x8c\xa1\xde" "\x3a\xfe\xbb\x67\xfc\xe7\xef\x6e\xce\xbd\x3e\x92\xb6\x6d\xad\xfe\x9c" "\xef\x97\xaa\xf7\x06\x3c\xc8\x3f\xff\xeb\x35\x98\x8f\x3b\xb9\xf7\x6e" "\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xa1" "\x92\x52\x11\xcf\xe7\xf9\xd4\x27\xef\x33\x9f\xfa\x6a\xa4\x78\xf9\x7f" "\x9e\xc9\xe5\xd2\xc9\xb2\x5c\x77\x1e\xf8\xc1\xea\xd7\x81\x2b\x73\xb3" "\xa7\x2f\xcd\xcc\xcc\x4d\x35\x97\x9a\xd7\x66\x5a\xf5\xf1\xf9\xe6\x54" "\xab\xac\xfb\xa9\x48\xb1\xfe\x37\x9f\xc9\x75\x8b\x6a\x7e\xf5\xee\x7c" "\xf3\x9d\x39\xde\x07\x36\xba\x73\xb1\x2f\x44\x8a\xd1\xbf\xef\x96\xed" "\xcc\xc5\xde\x9d\x9b\xbc\x33\x1f\x78\x67\x2e\xf6\xb2\xec\x27\x22\xc5" "\x7f\xff\xc3\xd6\xb2\xdd\x79\xac\x3f\xbd\x59\xf6\x6c\x59\xf6\xaf\x23" "\xc5\x57\xff\x79\xe7\xb2\x27\x37\xcb\x9e\x2b\xcb\x7e\x27\x52\xfc\xe0" "\xab\xf5\x6e\xd9\xe3\x65\xd9\xee\xfb\x51\x3b\xef\x24\x1d\xa8\xc5\x4c" "\xeb\xd9\xa9\xb9\x99\xbb\x5e\x85\x0a\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x1f\x54\x5f\x2a\xe2\xcf\x22\xc5\xff\xde" "\x5c\x89\xe5\x3c\xec\x3f\xcf\xff\xdf\x9d\x81\xbf\xd6\x2d\xfb\xe6\xd7" "\x7b\xe6\xfb\xdf\xe6\x76\x35\xcf\xff\x60\x35\xff\xff\xbd\x96\x3f\xcc" "\xfc\xff\x83\x0f\xac\xa7\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\xf0\xe8\x48\x51\xc4\x1b\x91\x62\xfe\xca\x7a\x5a\xed\x2f" "\x3f\x77\x0c\x5c\x6e\xcf\xde\xba\x3d\x31\x32\xba\x73\xb5\x63\xa9\xaa" "\x79\xa4\x2a\x5f\xfe\x0c\x3c\x77\xf6\xdc\xf9\x2f\x3c\x3f\x7c\xa1\x9b" "\xef\x5f\xff\x41\x7b\x32\x5e\x1d\xbf\x7a\xa9\xfe\xd2\xdc\xcd\xf9\x85" "\xd6\xe2\x62\x6b\xba\x3e\x31\xdb\x9e\x9a\x9b\x6e\xed\x7a\x0f\x7b\xad" "\xbf\x79\xea\x3a\x86\xaa\x13\x50\xbf\xf9\xda\xad\xe9\xeb\xd7\x17\xeb" "\x67\x9f\x3d\xb7\x65\xf3\xed\xc1\xf7\xfa\x1f\x3b\x39\x78\x71\xf8\xe9" "\xd3\x4f\x75\xcb\x4e\x8c\x8c\x8e\x8e\xf7\x94\xa9\xf5\x7d\x80\xa3\x7f" "\xa0\xc6\x6d\x3a\x1a\x45\xfc\x55\xa4\x78\xe6\xbb\x3f\x4e\xff\xd2\x1f" "\x51\xc4\xde\xcf\xc5\x7d\xbe\x3b\xfb\xed\x58\xd5\x89\xa1\xaa\x13\x13" "\x23\xa3\x55\x47\x66\xda\xcd\xd9\xa5\x72\xe3\x58\xf7\x44\x14\x11\xf5" "\x9e\x4a\x8d\xee\x39\x3a\x80\x6b\xb1\x27\x8d\x88\xe5\xb2\xf9\x65\x83" "\x87\xca\xee\x8d\xcf\x37\x17\x9a\xd7\x66\x5a\xf5\xb1\xe6\xc2\x52\x7b" "\xa9\x3d\x37\x3b\x96\x3a\xad\x2d\xfb\x53\x8f\x22\x2e\xa4\x88\x95\x88" "\x58\xeb\xbf\x7b\x77\x7d\x51\xc4\x6b\x91\xe2\xdb\x27\xd6\xd3\xbf\xf6" "\x47\x1c\xe9\x9e\x87\xcf\x5f\x19\xff\xf2\x99\xb3\xf7\x6e\x47\xb1\x8f" "\x7d\xdc\x85\xb2\x9d\xf5\xbe\x88\x95\xe2\x11\xb8\x66\x87\x58\x7f\x14" "\xf1\x4f\x91\xe2\x27\x6f\x9f\x8a\x7f\xeb\x8f\xa8\x45\xe7\x27\x3e\x17" "\xf1\x4a\x99\xdf\x8f\x78\xb3\xcc\x17\x23\x52\x8a\xd8\xf8\x46\xc4\xbb" "\x3b\x7c\x8f\x78\x34\xd5\xa2\x88\xff\x2f\xaf\xff\xc5\xf5\xf4\x76\x7f" "\x79\x3f\xe8\xde\x57\x2e\x7f\xa5\xfe\xa5\xd9\xeb\x73\x3d\x65\xbb\xf7" "\x95\x5d\x3d\x1f\x7e\xfd\xde\xc7\x7c\xe8\xcf\x87\x83\x74\xc8\xef\x4d" "\x03\x51\xc4\x0f\xaa\x3b\xfe\x7a\xfa\x77\xff\x5d\x03\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x1c\x22\x45\xfc\x6a\xa4\x78\xe1\x9d" "\x53\xa9\x1a\x1f\x7c\x67\x4c\x71\x7b\xf6\x46\xfd\x6a\xf3\xda\x4c\x67" "\x58\x5f\x77\xec\x5f\x77\xcc\xf4\xc6\xc6\xc6\x46\x3d\x75\xb2\x91\x73" "\x32\xe7\x72\xce\x95\x9c\xab\x39\xd7\x72\x46\x91\xeb\xe7\x6c\xe4\x9c" "\xcc\xb9\x9c\x73\x25\xe7\x6a\xce\xb5\x9c\x71\x24\xd7\xcf\xd9\xc8\x39" "\x99\x73\x39\xe7\x4a\xce\xd5\x9c\x6b\x39\xa3\x96\xeb\xe7\x6c\xe4\x9c" "\xcc\xb9\x9c\x73\x25\xe7\x6a\xce\xb5\x9c\x71\x48\xc6\xee\x01\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x1f\x2d\x45\xf5\x4f" "\x8a\x6f\x7d\x6d\x3d\x6d\xf4\x77\xe6\x97\x9e\x8c\x4e\xae\x9a\x0f\xf4" "\x23\xef\xe7\x01\x00\x00\xff\xff\x37\x80\xfe\xbb", 3106)); NONFAILING(syz_mount_image( /*fs=*/0x200000000100, /*dir=*/0x200000000f00, /*flags=MS_POSIXACL|MS_REC|MS_NODEV|MS_NOATIME|0x40*/ 0x14444, /*opts=*/0x200000001d80, /*chdir=*/0xfd, /*size=*/0xc22, /*img=*/0x2000000002c0)); break; case 7: // quotactl$Q_QUOTAON arguments: [ // cmd: quota_cmd_quota_on = 0xffffffff80000201 (8 bytes) // special: ptr[in, blockdev_filename] { // union blockdev_filename { // loop: loop_filename { // prefix: buffer: {2f 64 65 76 2f 6c 6f 6f 70} (length 0x9) // id: proc = 0x0 (1 bytes) // z: const = 0x0 (1 bytes) // } // } // } // id: uid (resource) // addr: nil // ] NONFAILING(memcpy((void*)0x200000000180, "/dev/loop", 9)); NONFAILING(*(uint8_t*)0x200000000189 = 0x30); NONFAILING(*(uint8_t*)0x20000000018a = 0); syscall(__NR_quotactl, /*cmd=Q_QUOTAON_GRP*/ 0xffffffff80000201ul, /*special=*/0x200000000180ul, /*id=*/0, /*addr=*/0ul); break; case 8: // mprotect arguments: [ // addr: VMA[0x3000] // len: len = 0x3000 (8 bytes) // prot: mmap_prot = 0x9 (8 bytes) // ] syscall(__NR_mprotect, /*addr=*/0x200000000000ul, /*len=*/0x3000ul, /*prot=PROT_SEM|PROT_READ*/ 9ul); break; case 9: // openat$cgroup_ro arguments: [ // fd: fd_cgroup (resource) // file: ptr[in, buffer] { // buffer: {68 75 67 65 74 6c 62 2e 31 47 42 2e 75 73 61 67 65 5f 69 6e // 5f 62 79 74 65 73 00} (length 0x1b) // } // flags: const = 0x275a (4 bytes) // mode: const = 0x0 (2 bytes) // ] // returns fd NONFAILING( memcpy((void*)0x200000000180, "hugetlb.1GB.usage_in_bytes\000", 27)); res = syscall(__NR_openat, /*fd=*/(intptr_t)-1, /*file=*/0x200000000180ul, /*flags=*/0x275a, /*mode=*/0); if (res != -1) r[2] = res; break; case 10: // mmap arguments: [ // addr: VMA[0xb36000] // len: len = 0xb36000 (8 bytes) // prot: mmap_prot = 0xa (8 bytes) // flags: mmap_flags = 0x28011 (8 bytes) // fd: fd (resource) // offset: intptr = 0x0 (8 bytes) // ] syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0xb36000ul, /*prot=PROT_SEM|PROT_WRITE*/ 0xaul, /*flags=MAP_STACK|MAP_POPULATE|MAP_FIXED|MAP_SHARED*/ 0x28011ul, /*fd=*/r[2], /*offset=*/0ul); 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; install_segv_handler(); use_temporary_dir(); loop(); return 0; }