// https://syzkaller.appspot.com/bug?id=a0bd8d1c892e8115c2abfd3937a7600127ff1615 // 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 #ifndef __NR_memfd_create #define __NR_memfd_create 279 #endif #ifndef __NR_mkdirat #define __NR_mkdirat 34 #endif #ifndef __NR_mmap #define __NR_mmap 222 #endif #ifndef __NR_mount #define __NR_mount 40 #endif #ifndef __NR_openat #define __NR_openat 56 #endif #ifndef __NR_pwrite64 #define __NR_pwrite64 68 #endif #ifndef __NR_write #define __NR_write 64 #endif static unsigned long long procid; static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void use_temporary_dir(void) { char tmpdir_template[] = "./syzkaller.XXXXXX"; char* tmpdir = mkdtemp(tmpdir_template); if (!tmpdir) exit(1); if (chmod(tmpdir, 0777)) exit(1); if (chdir(tmpdir)) exit(1); } static bool write_file(const char* file, const char* what, ...) { char buf[1024]; va_list args; va_start(args, what); vsnprintf(buf, sizeof(buf), what, args); va_end(args); buf[sizeof(buf) - 1] = 0; int len = strlen(buf); int fd = open(file, O_WRONLY | O_CLOEXEC); if (fd == -1) return false; if (write(fd, buf, len) != len) { int err = errno; close(fd); errno = err; return false; } close(fd); return true; } static long syz_open_dev(volatile long a0, volatile long a1, volatile long a2) { if (a0 == 0xc || a0 == 0xb) { char buf[128]; sprintf(buf, "/dev/%s/%d:%d", a0 == 0xc ? "char" : "block", (uint8_t)a1, (uint8_t)a2); return open(buf, O_RDWR, 0); } else { unsigned long nb = a1; char buf[1024]; char* hash; strncpy(buf, (char*)a0, sizeof(buf) - 1); buf[sizeof(buf) - 1] = 0; while ((hash = strchr(buf, '#'))) { *hash = '0' + (char)(nb % 10); nb /= 10; } return open(buf, a2 & ~O_CREAT, 0); } } //% 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")) { } } 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_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // syz_mount_image$ext4 arguments: [ // fs: ptr[in, buffer] { // buffer: {65 78 74 32 00} (length 0x5) // } // dir: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 30 00} (length 0x8) // } // flags: mount_flags = 0x808082 (8 bytes) // opts: ptr[in, fs_options[ext4_options]] { // fs_options[ext4_options] { // elems: array[fs_opt_elem[ext4_options]] { // fs_opt_elem[ext4_options] { // elem: union ext4_options { // resuid: fs_opt["resuid", fmt[hex, uid]] { // name: buffer: {72 65 73 75 69 64} (length 0x6) // eq: const = 0x3d (1 bytes) // val: uid (resource) // } // } // comma: const = 0x2c (1 bytes) // } // } // common: array[fs_opt_elem[fs_options_common]] { // } // null: const = 0x0 (1 bytes) // } // } // chdir: int8 = 0x0 (1 bytes) // size: len = 0x4a3 (8 bytes) // img: ptr[in, buffer] { // buffer: (compressed buffer with length 0x4a3) // } // ] // returns fd_dir memcpy((void*)0x20000080, "ext2\000", 5); memcpy((void*)0x200000c0, "./file0\000", 8); memcpy((void*)0x20000200, "resuid", 6); *(uint8_t*)0x20000206 = 0x3d; sprintf((char*)0x20000207, "0x%016llx", (long long)0); *(uint8_t*)0x20000219 = 0x2c; *(uint8_t*)0x2000021a = 0; memcpy( (void*)0x20000a80, "\x78\x9c\xec\xdc\xcb\x6f\x1b\x45\x18\x00\xf0\x6f\xed\xd8\x49\xfa\x20\xa1" "\x94\x47\x4b\x0b\x81\x82\xa8\x78\x24\x4d\xfa\xa0\x07\x2e\x45\x20\x71\x00" "\x09\x09\x0e\x45\x9c\x42\x92\x56\xa5\x69\x83\x9a\x20\xd1\xaa\x82\xc2\xa1" "\x1c\x51\x25\xee\x88\x23\x12\x7f\x00\xe2\x42\x7b\x41\xc0\x09\x89\x2b\xdc" "\x11\x52\x85\x7a\x69\xa9\x90\x30\x5a\x7b\xd7\x4d\x13\xdb\xcd\xc3\xb1\x0b" "\xfe\xfd\x24\xd7\xb3\x3b\x63\xcf\x7c\x3b\x3b\xf1\xec\xac\xdd\x00\x7a\xd6" "\x48\xfa\x4f\x12\xb1\x25\x22\x7e\x8d\x88\xa1\xda\xe6\xed\x05\x46\x6a\x4f" "\x37\xae\x9d\x9f\xfa\xeb\xda\xf9\xa9\x24\x2a\x95\x37\xfe\x4c\xaa\xe5\xae" "\x5f\x3b\x3f\x95\x17\xcd\x5f\xb7\x39\xdb\x48\x5a\xd4\x7b\xf1\xed\x88\xc9" "\xd9\xd9\x99\x33\xd9\xf6\xd8\xc2\xa9\xf7\xc6\xe6\xcf\x9e\x7b\xee\xc4\xa9" "\xc9\xe3\x33\xc7\x67\x4e\x4f\x1c\x3e\x7c\x60\xff\xee\xf2\xa1\x89\x83\xeb" "\x8a\x2f\x6f\x43\x1a\xd7\xf5\x9d\x1f\xce\xed\xda\xf1\xca\x5b\x97\x5e\x9b" "\x3a\x7a\xe9\x9d\x1f\xbf\x4e\xf3\xb6\x64\xf9\x8b\xe3\x68\x97\x91\xda\xd1" "\xcd\x8f\xc8\x6d\x9e\x6c\x77\x65\x5d\xb6\x75\x51\x3a\xe9\xeb\x62\x43\x58" "\x95\x81\x88\x48\xbb\xab\x54\x1d\xff\x43\x51\x8c\xc1\x7a\xde\x50\xbc\xfc" "\x49\xd3\x17\x8e\x74\xa8\x81\xc0\x86\xa9\x54\x0a\x95\xfe\xe6\xd9\x17\x2a" "\xc0\xff\x58\x3a\x9b\x5f\xa5\x81\x0d\x69\x08\xd0\x61\xf9\x07\x7d\x7a\xfd" "\x9b\x3f\x3a\x34\xf5\xb8\x2b\x5c\x3d\x12\xf5\x75\x8c\x1b\xd9\xa3\xba\x58" "\x10\x7d\x51\xc8\xca\x94\xb2\x6b\xa4\x8d\x90\x5e\x46\x1d\xbd\x70\xf3\x8b" "\xf4\x11\x1b\xb4\x0e\x01\x00\xb0\xd8\xe5\x23\x11\xf1\x6c\xa3\xf9\x5f\x21" "\x1e\x58\x54\xee\x9e\xec\x1e\xca\x70\x44\xdc\x1b\x11\xdb\xca\x11\xf7\x45" "\xc4\xf6\x88\xb8\x3f\xa2\x5a\xf6\xc1\x88\x78\x68\x95\xf5\x2f\x5d\x46\x5e" "\x3e\xff\xa9\x0c\xad\x29\xb0\x15\x4a\xe7\x7f\x2f\x64\xf7\xb6\xea\xf3\xbf" "\xaa\x7c\xf6\x17\xc3\xc5\x6c\x6b\x6b\x35\xfe\x52\x72\xec\xc4\xec\xcc\xbe" "\xec\x98\xec\x8d\x52\x7f\xba\x3d\xde\xa2\x8e\x2b\x2f\xfd\xf2\x59\xb3\xbc" "\xc5\xf3\xbf\xf4\x91\xd6\x9f\xcf\x05\xb3\x76\xfc\xd1\xb7\x64\x81\x6e\x7a" "\x72\x61\x72\x3d\x31\x2f\x76\xf5\xe3\x88\x9d\x7d\x8d\xe2\x4f\xea\x73\xde" "\x74\x7e\xbc\x23\x22\x76\xae\xb1\x8e\x13\x4f\x7f\xb5\x6b\xf9\xde\x9b\xd5" "\xab\x8f\x3b\xc7\xdf\x42\x1b\x26\xe5\x95\x2f\x23\x9e\xaa\xf5\xff\x85\x58" "\x12\x7f\x2e\x69\x7a\x7f\x72\xfc\xf9\x43\x13\x07\xc7\x06\x62\x76\x66\xdf" "\x58\x7e\x56\x2c\xf7\xd3\xcf\x17\x5f\x6f\x56\xff\xba\xe2\x6f\x83\xab\x97" "\x2b\xb1\xa9\xe1\xf9\x9f\xc7\x9f\xfc\x93\x0c\x44\xcc\x9f\x3d\x77\xb2\x7a" "\xbf\x76\x7e\x05\x6f\x9a\x9f\xaf\xd9\xad\xa4\x8b\xbf\x7d\xda\xf8\x9a\xa6" "\x54\x7b\xaa\xc7\xdf\xdf\xe2\xfc\xbf\xb2\xa5\xbe\x27\x3d\xff\xcb\xc9\x9b" "\xd5\x74\x39\xdb\xf7\xc1\xe4\xc2\xc2\x99\xf1\x88\x72\xf2\xea\xf2\xfd\x13" "\xb7\xde\x2d\xdf\xce\xcb\xa7\xe7\xff\xde\x3d\x8d\xc7\xff\xb6\xec\x39\x3d" "\x12\x0f\x47\x44\x7a\x12\xef\x1e\x8c\x78\x24\x22\x1e\xcd\xfa\xee\xb1\x88" "\x78\x3c\x22\xf6\xb4\x38\x1c\x3f\xbc\xf8\xc4\xbb\xcd\xf2\x9a\xf7\x7f\x8b" "\x55\xf9\x36\x4a\xe3\x9f\x6e\xd9\xff\x31\x9c\xa6\x6e\xf5\x7f\x9a\x88\x42" "\x96\xa8\xef\x69\x95\x28\x9e\xfc\xfe\xdb\x15\xc5\x9f\x8f\xe7\x65\xfd\x7f" "\xa0\x9a\xda\x9b\xed\x59\xc9\xdf\xbf\x5b\xad\x48\xa2\x55\x03\xd7\x7a\xdc" "\x00\x00\x00\xe0\xbf\xa4\x50\xfd\x0e\x7c\x52\x18\xad\xa7\x0b\x85\xd1\xd1" "\xda\x37\xd6\xb7\xc7\xa6\xc2\xec\xdc\xfc\xc2\x33\xc7\xe6\xde\x3f\x3d\x5d" "\xfb\xae\xfc\x70\x94\x0a\xf9\x4a\xd7\x50\x1c\xff\x26\xb2\xf5\xd0\xf1\x6c" "\x6d\x38\x5f\x1f\x9d\x58\xb2\xbd\x3f\x5b\x37\xfe\xbc\x38\x58\xdd\x1e\x9d" "\x9a\x9b\x9d\xee\x76\xf0\xd0\xe3\x36\x37\x19\xff\xa9\xdf\x8b\xdd\x6e\x1d" "\xb0\xe1\xfc\x5e\x0b\x7a\x97\xf1\x0f\xbd\xcb\xf8\x87\xde\x65\xfc\x43\xef" "\x32\xfe\xa1\x77\x35\x1a\xff\x1f\x75\xa1\x1d\x40\xe7\xdd\xe1\xf3\x7f\xb0" "\x53\xed\x00\x3a\xaf\xf1\xf8\xff\xbb\xe3\xed\x00\x3a\xcf\xf5\x3f\xf4\x2e" "\xe3\x1f\x7a\x52\xd3\xdf\xc6\x17\x5a\xfe\x6c\xbe\x79\xa2\x18\xd9\x7f\xec" "\xbf\xb6\x97\x4b\xac\x2f\xf1\x5d\xb9\x45\x9f\xde\x39\x51\x5e\x79\xe1\x28" "\xdc\x25\x21\x77\x39\x51\x8c\x76\xbd\x61\x29\x1a\x64\x95\xa3\x2f\x56\xfd" "\x86\x83\xab\xaa\xbd\xbf\x61\x56\xb7\xff\x32\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\xb4\xc7\xbf\x01\x00\x00\xff\xff\x08\xb4\xdc\x7b", 1187); syz_mount_image( /*fs=*/0x20000080, /*dir=*/0x200000c0, /*flags=MS_I_VERSION|MS_SILENT|MS_NOSUID|MS_DIRSYNC*/ 0x808082, /*opts=*/0x20000200, /*chdir=*/0, /*size=*/0x4a3, /*img=*/0x20000a80); // syz_open_dev$loop arguments: [ // dev: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 6c 6f 6f 70 23 00} (length 0xb) // } // id: intptr = 0x0 (8 bytes) // flags: open_flags = 0x2 (8 bytes) // ] // returns fd_loop memcpy((void*)0x20000100, "/dev/loop#\000", 11); res = -1; res = syz_open_dev(/*dev=*/0x20000100, /*id=*/0, /*flags=O_RDWR*/ 2); if (res != -1) r[0] = res; // pwrite64 arguments: [ // fd: fd (resource) // buf: ptr[in, buffer] { // buffer: {50 14 6f e0 97 73 9d 2d 08 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 c6 85 73 f6 4e 1a 45 ca 82 65 f5 7f 48 ba 6d 81} (length // 0x28) // } // count: len = 0x28 (8 bytes) // pos: intptr = 0x1000 (8 bytes) // ] memcpy((void*)0x20001000, "\x50\x14\x6f\xe0\x97\x73\x9d\x2d\x08\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\xc6\x85\x73\xf6\x4e\x1a\x45\xca\x82\x65" "\xf5\x7f\x48\xba\x6d\x81", 40); syscall(__NR_pwrite64, /*fd=*/r[0], /*buf=*/0x20001000ul, /*count=*/0x28ul, /*pos=*/0x1000ul); // mkdirat arguments: [ // fd: fd_dir (resource) // path: ptr[in, buffer] { // buffer: {2e 2f 73 79 73 00} (length 0x6) // } // mode: open_mode = 0x1ff (8 bytes) // ] memcpy((void*)0x20000200, "./sys\000", 6); syscall( __NR_mkdirat, /*fd=*/0xffffff9c, /*path=*/0x20000200ul, /*mode=S_IXOTH|S_IWOTH|S_IROTH|S_IXGRP|S_IWGRP|S_IRGRP|S_IXUSR|S_IWUSR|0x100*/ 0x1fful); // mount arguments: [ // src: nil // dst: ptr[in, buffer] { // buffer: {2e 2f 73 79 73 00} (length 0x6) // } // type: ptr[in, buffer] { // buffer: {73 79 73 66 73 00} (length 0x6) // } // flags: mount_flags = 0x0 (8 bytes) // data: nil // ] memcpy((void*)0x20000200, "./sys\000", 6); memcpy((void*)0x20000240, "sysfs\000", 6); syscall(__NR_mount, /*src=*/0ul, /*dst=*/0x20000200ul, /*type=*/0x20000240ul, /*flags=*/0ul, /*data=*/0ul); // openat arguments: [ // fd: fd_dir (resource) // file: ptr[in, buffer] { // buffer: {2e 2f 73 79 73 2f 66 73 2f 62 63 61 63 68 65 2f 72 65 67 69 // 73 74 65 72 00} (length 0x19) // } // flags: open_flags = 0x1 (4 bytes) // mode: open_mode = 0x0 (2 bytes) // ] // returns fd memcpy((void*)0x20000300, "./sys/fs/bcache/register\000", 25); res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x20000300ul, /*flags=O_WRONLY*/ 1, /*mode=*/0); if (res != -1) r[1] = res; // write arguments: [ // fd: fd (resource) // buf: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 6c 6f 6f 70 30} (length 0xa) // } // count: len = 0xa (8 bytes) // ] memcpy((void*)0x20000400, "/dev/loop0", 10); syscall(__NR_write, /*fd=*/r[1], /*buf=*/0x20000400ul, /*count=*/0xaul); } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x21000000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); const char* reason; (void)reason; use_temporary_dir(); loop(); return 0; }