// https://syzkaller.appspot.com/bug?id=f4846413aea05f713fce426378f26c7bfabd539f // 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_fcntl #define __NR_fcntl 25 #endif #ifndef __NR_ftruncate #define __NR_ftruncate 46 #endif #ifndef __NR_ioctl #define __NR_ioctl 29 #endif #ifndef __NR_memfd_create #define __NR_memfd_create 279 #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 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 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; } //% This code is derived from puff.{c,h}, found in the zlib development. The //% original files come with the following copyright notice: //% Copyright (C) 2002-2013 Mark Adler, all rights reserved //% version 2.3, 21 Jan 2013 //% This software is provided 'as-is', without any express or implied //% warranty. In no event will the author be held liable for any damages //% arising from the use of this software. //% Permission is granted to anyone to use this software for any purpose, //% including commercial applications, and to alter it and redistribute it //% freely, subject to the following restrictions: //% 1. The origin of this software must not be misrepresented; you must not //% claim that you wrote the original software. If you use this software //% in a product, an acknowledgment in the product documentation would be //% appreciated but is not required. //% 2. Altered source versions must be plainly marked as such, and must not be //% misrepresented as being the original software. //% 3. This notice may not be removed or altered from any source distribution. //% Mark Adler madler@alumni.caltech.edu //% BEGIN CODE DERIVED FROM puff.{c,h} #define MAXBITS 15 #define MAXLCODES 286 #define MAXDCODES 30 #define MAXCODES (MAXLCODES + MAXDCODES) #define FIXLCODES 288 struct puff_state { unsigned char* out; unsigned long outlen; unsigned long outcnt; const unsigned char* in; unsigned long inlen; unsigned long incnt; int bitbuf; int bitcnt; jmp_buf env; }; static int puff_bits(struct puff_state* s, int need) { long val = s->bitbuf; while (s->bitcnt < need) { if (s->incnt == s->inlen) longjmp(s->env, 1); val |= (long)(s->in[s->incnt++]) << s->bitcnt; s->bitcnt += 8; } s->bitbuf = (int)(val >> need); s->bitcnt -= need; return (int)(val & ((1L << need) - 1)); } static int puff_stored(struct puff_state* s) { s->bitbuf = 0; s->bitcnt = 0; if (s->incnt + 4 > s->inlen) return 2; unsigned len = s->in[s->incnt++]; len |= s->in[s->incnt++] << 8; if (s->in[s->incnt++] != (~len & 0xff) || s->in[s->incnt++] != ((~len >> 8) & 0xff)) return -2; if (s->incnt + len > s->inlen) return 2; if (s->outcnt + len > s->outlen) return 1; for (; len--; s->outcnt++, s->incnt++) { if (s->in[s->incnt]) s->out[s->outcnt] = s->in[s->incnt]; } return 0; } struct puff_huffman { short* count; short* symbol; }; static int puff_decode(struct puff_state* s, const struct puff_huffman* h) { int first = 0; int index = 0; int bitbuf = s->bitbuf; int left = s->bitcnt; int code = first = index = 0; int len = 1; short* next = h->count + 1; while (1) { while (left--) { code |= bitbuf & 1; bitbuf >>= 1; int count = *next++; if (code - count < first) { s->bitbuf = bitbuf; s->bitcnt = (s->bitcnt - len) & 7; return h->symbol[index + (code - first)]; } index += count; first += count; first <<= 1; code <<= 1; len++; } left = (MAXBITS + 1) - len; if (left == 0) break; if (s->incnt == s->inlen) longjmp(s->env, 1); bitbuf = s->in[s->incnt++]; if (left > 8) left = 8; } return -10; } static int puff_construct(struct puff_huffman* h, const short* length, int n) { int len; for (len = 0; len <= MAXBITS; len++) h->count[len] = 0; int symbol; for (symbol = 0; symbol < n; symbol++) (h->count[length[symbol]])++; if (h->count[0] == n) return 0; int left = 1; for (len = 1; len <= MAXBITS; len++) { left <<= 1; left -= h->count[len]; if (left < 0) return left; } short offs[MAXBITS + 1]; offs[1] = 0; for (len = 1; len < MAXBITS; len++) offs[len + 1] = offs[len] + h->count[len]; for (symbol = 0; symbol < n; symbol++) if (length[symbol] != 0) h->symbol[offs[length[symbol]]++] = symbol; return left; } static int puff_codes(struct puff_state* s, const struct puff_huffman* lencode, const struct puff_huffman* distcode) { static const short lens[29] = {3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258}; static const short lext[29] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0}; static const short dists[30] = { 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577}; static const short dext[30] = {0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13}; int symbol; do { symbol = puff_decode(s, lencode); if (symbol < 0) return symbol; if (symbol < 256) { if (s->outcnt == s->outlen) return 1; if (symbol) s->out[s->outcnt] = symbol; s->outcnt++; } else if (symbol > 256) { symbol -= 257; if (symbol >= 29) return -10; int len = lens[symbol] + puff_bits(s, lext[symbol]); symbol = puff_decode(s, distcode); if (symbol < 0) return symbol; unsigned dist = dists[symbol] + puff_bits(s, dext[symbol]); if (dist > s->outcnt) return -11; if (s->outcnt + len > s->outlen) return 1; while (len--) { if (dist <= s->outcnt && s->out[s->outcnt - dist]) s->out[s->outcnt] = s->out[s->outcnt - dist]; s->outcnt++; } } } while (symbol != 256); return 0; } static int puff_fixed(struct puff_state* s) { static int virgin = 1; static short lencnt[MAXBITS + 1], lensym[FIXLCODES]; static short distcnt[MAXBITS + 1], distsym[MAXDCODES]; static struct puff_huffman lencode, distcode; if (virgin) { lencode.count = lencnt; lencode.symbol = lensym; distcode.count = distcnt; distcode.symbol = distsym; short lengths[FIXLCODES]; int symbol; for (symbol = 0; symbol < 144; symbol++) lengths[symbol] = 8; for (; symbol < 256; symbol++) lengths[symbol] = 9; for (; symbol < 280; symbol++) lengths[symbol] = 7; for (; symbol < FIXLCODES; symbol++) lengths[symbol] = 8; puff_construct(&lencode, lengths, FIXLCODES); for (symbol = 0; symbol < MAXDCODES; symbol++) lengths[symbol] = 5; puff_construct(&distcode, lengths, MAXDCODES); virgin = 0; } return puff_codes(s, &lencode, &distcode); } static int puff_dynamic(struct puff_state* s) { static const short order[19] = {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; int nlen = puff_bits(s, 5) + 257; int ndist = puff_bits(s, 5) + 1; int ncode = puff_bits(s, 4) + 4; if (nlen > MAXLCODES || ndist > MAXDCODES) return -3; short lengths[MAXCODES]; int index; for (index = 0; index < ncode; index++) lengths[order[index]] = puff_bits(s, 3); for (; index < 19; index++) lengths[order[index]] = 0; short lencnt[MAXBITS + 1], lensym[MAXLCODES]; struct puff_huffman lencode = {lencnt, lensym}; int err = puff_construct(&lencode, lengths, 19); if (err != 0) return -4; index = 0; while (index < nlen + ndist) { int symbol; int len; symbol = puff_decode(s, &lencode); if (symbol < 0) return symbol; if (symbol < 16) lengths[index++] = symbol; else { len = 0; if (symbol == 16) { if (index == 0) return -5; len = lengths[index - 1]; symbol = 3 + puff_bits(s, 2); } else if (symbol == 17) symbol = 3 + puff_bits(s, 3); else symbol = 11 + puff_bits(s, 7); if (index + symbol > nlen + ndist) return -6; while (symbol--) lengths[index++] = len; } } if (lengths[256] == 0) return -9; err = puff_construct(&lencode, lengths, nlen); if (err && (err < 0 || nlen != lencode.count[0] + lencode.count[1])) return -7; short distcnt[MAXBITS + 1], distsym[MAXDCODES]; struct puff_huffman distcode = {distcnt, distsym}; err = puff_construct(&distcode, lengths + nlen, ndist); if (err && (err < 0 || ndist != distcode.count[0] + distcode.count[1])) return -8; return puff_codes(s, &lencode, &distcode); } static int puff(unsigned char* dest, unsigned long* destlen, const unsigned char* source, unsigned long sourcelen) { struct puff_state s = { .out = dest, .outlen = *destlen, .outcnt = 0, .in = source, .inlen = sourcelen, .incnt = 0, .bitbuf = 0, .bitcnt = 0, }; int err; if (setjmp(s.env) != 0) err = 2; else { int last; do { last = puff_bits(&s, 1); int type = puff_bits(&s, 2); err = type == 0 ? puff_stored(&s) : (type == 1 ? puff_fixed(&s) : (type == 2 ? puff_dynamic(&s) : -1)); if (err != 0) break; } while (!last); } *destlen = s.outcnt; return err; } //% END CODE DERIVED FROM puff.{c,h} #define ZLIB_HEADER_WIDTH 2 static int puff_zlib_to_file(const unsigned char* source, unsigned long sourcelen, int dest_fd) { if (sourcelen < ZLIB_HEADER_WIDTH) return 0; source += ZLIB_HEADER_WIDTH; sourcelen -= ZLIB_HEADER_WIDTH; const unsigned long max_destlen = 132 << 20; void* ret = mmap(0, max_destlen, PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANON, -1, 0); if (ret == MAP_FAILED) return -1; unsigned char* dest = (unsigned char*)ret; unsigned long destlen = max_destlen; int err = puff(dest, &destlen, source, sourcelen); if (err) { munmap(dest, max_destlen); errno = -err; return -1; } if (write(dest_fd, dest, destlen) != (ssize_t)destlen) { munmap(dest, max_destlen); return -1; } return munmap(dest, max_destlen); } static int setup_loop_device(unsigned char* data, unsigned long size, const char* loopname, int* loopfd_p) { int err = 0, loopfd = -1; int memfd = syscall(__NR_memfd_create, "syzkaller", 0); if (memfd == -1) { err = errno; goto error; } if (puff_zlib_to_file(data, size, memfd)) { err = errno; goto error_close_memfd; } loopfd = open(loopname, O_RDWR); if (loopfd == -1) { err = errno; goto error_close_memfd; } if (ioctl(loopfd, LOOP_SET_FD, memfd)) { if (errno != EBUSY) { err = errno; goto error_close_loop; } ioctl(loopfd, LOOP_CLR_FD, 0); usleep(1000); if (ioctl(loopfd, LOOP_SET_FD, memfd)) { err = errno; goto error_close_loop; } } close(memfd); *loopfd_p = loopfd; return 0; error_close_loop: close(loopfd); error_close_memfd: close(memfd); error: errno = err; return -1; } static void reset_loop_device(const char* loopname) { int loopfd = open(loopname, O_RDWR); if (loopfd == -1) { return; } if (ioctl(loopfd, LOOP_CLR_FD, 0)) { } close(loopfd); } static long syz_mount_image(volatile long fsarg, volatile long dir, volatile long flags, volatile long optsarg, volatile long change_dir, volatile unsigned long size, volatile long image) { unsigned char* data = (unsigned char*)image; int res = -1, err = 0, need_loop_device = !!size; char* mount_opts = (char*)optsarg; char* target = (char*)dir; char* fs = (char*)fsarg; char* source = NULL; char loopname[64]; if (need_loop_device) { int loopfd; memset(loopname, 0, sizeof(loopname)); snprintf(loopname, sizeof(loopname), "/dev/loop%llu", procid); if (setup_loop_device(data, size, loopname, &loopfd) == -1) return -1; close(loopfd); source = loopname; } mkdir(target, 0777); char opts[256]; memset(opts, 0, sizeof(opts)); if (strlen(mount_opts) > (sizeof(opts) - 32)) { } strncpy(opts, mount_opts, sizeof(opts) - 32); if (strcmp(fs, "iso9660") == 0) { flags |= MS_RDONLY; } else if (strncmp(fs, "ext", 3) == 0) { bool has_remount_ro = false; char* remount_ro_start = strstr(opts, "errors=remount-ro"); if (remount_ro_start != NULL) { char after = *(remount_ro_start + strlen("errors=remount-ro")); char before = remount_ro_start == opts ? '\0' : *(remount_ro_start - 1); has_remount_ro = ((before == '\0' || before == ',') && (after == '\0' || after == ',')); } if (strstr(opts, "errors=panic") || !has_remount_ro) strcat(opts, ",errors=continue"); } else if (strcmp(fs, "xfs") == 0) { strcat(opts, ",nouuid"); } else if (strncmp(fs, "gfs2", 4) == 0 && (strstr(opts, "errors=panic") || strstr(opts, "debug"))) { strcat(opts, ",errors=withdraw"); } res = mount(source, target, fs, flags, opts); if (res == -1) { err = errno; goto error_clear_loop; } res = open(target, O_RDONLY | O_DIRECTORY); if (res == -1) { err = errno; goto error_clear_loop; } if (change_dir) { res = chdir(target); if (res == -1) { err = errno; } } error_clear_loop: if (need_loop_device) reset_loop_device(loopname); errno = err; return res; } static void 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"); } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { int iter = 0; for (;; iter++) { reset_loop(); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { 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; } } } uint64_t r[4] = {0xffffffffffffffff, 0xffffffffffffffff, 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 34 00} (length 0x5) // } // dir: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 30 00} (length 0x8) // } // flags: mount_flags = 0x100009a (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 { // oldalloc: buffer: {6f 6c 64 61 6c 6c 6f 63} (length 0x8) // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[ext4_options] { // elem: union ext4_options { // noinit_itable: buffer: {6e 6f 69 6e 69 74 5f 69 74 61 62 6c // 65} (length 0xd) // } // comma: const = 0x22 (1 bytes) // } // fs_opt_elem[ext4_options] { // elem: union ext4_options { // dioread_lock: buffer: {64 69 6f 72 65 61 64 5f 6c 6f 63 6b} // (length 0xc) // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[ext4_options] { // elem: union ext4_options { // data_journal: buffer: {64 61 74 61 3d 6a 6f 75 72 6e 61 6c} // (length 0xc) // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[ext4_options] { // elem: union ext4_options { // nouid32: buffer: {6e 6f 75 69 64 33 32} (length 0x7) // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[ext4_options] { // elem: union ext4_options { // usrjquota: buffer: {75 73 72 6a 71 75 6f 74 61 3d} (length // 0xa) // } // comma: const = 0x22 (1 bytes) // } // fs_opt_elem[ext4_options] { // elem: union ext4_options { // errors_continue: buffer: {65 72 72 6f 72 73 3d 63 6f 6e 74 69 // 6e 75 65} (length 0xf) // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[ext4_options] { // elem: union ext4_options { // errors_remount: buffer: {65 72 72 6f 72 73 3d 72 65 6d 6f 75 // 6e 74 2d 72 6f} (length 0x11) // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[ext4_options] { // elem: union ext4_options { // jqfmt_vfsv1: buffer: {6a 71 66 6d 74 3d 76 66 73 76 31} // (length 0xb) // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[ext4_options] { // elem: union ext4_options { // grpquota: buffer: {67 72 70 71 75 6f 74 61} (length 0x8) // } // comma: const = 0x2c (1 bytes) // } // } // common: array[fs_opt_elem[fs_options_common]] { // fs_opt_elem[fs_options_common] { // elem: union fs_options_common { // smackfshat: fs_opt["smackfshat", stringnoz] { // name: buffer: {73 6d 61 63 6b 66 73 68 61 74} (length 0xa) // eq: const = 0x3d (1 bytes) // val: buffer: {64 61 74 61 3d 6a 6f 75 72 6e 61 6c} (length // 0xc) // } // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[fs_options_common] { // elem: union fs_options_common { // context: fs_opt["context", stringnoz[selinux_user_context]] { // name: buffer: {63 6f 6e 74 65 78 74} (length 0x7) // eq: const = 0x3d (1 bytes) // val: buffer: {73 79 73 74 65 6d 5f 75} (length 0x8) // } // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[fs_options_common] { // elem: union fs_options_common { // uid_lt: fs_opt_nodelim["uid<", fmt[dec, uid]] { // name: buffer: {75 69 64 3c} (length 0x4) // val: uid (resource) // } // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[fs_options_common] { // elem: union fs_options_common { // uid_eq: fs_opt["uid", fmt[dec, uid]] { // name: buffer: {75 69 64} (length 0x3) // eq: const = 0x3d (1 bytes) // val: uid (resource) // } // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[fs_options_common] { // elem: union fs_options_common { // appraise_type: buffer: {61 70 70 72 61 69 73 65 5f 74 79 70 65 // 3d 69 6d 61 73 69 67} (length 0x14) // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[fs_options_common] { // elem: union fs_options_common { // seclabel: buffer: {73 65 63 6c 61 62 65 6c} (length 0x8) // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[fs_options_common] { // elem: union fs_options_common { // audit: buffer: {61 75 64 69 74} (length 0x5) // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[fs_options_common] { // elem: union fs_options_common { // measure: buffer: {6d 65 61 73 75 72 65} (length 0x7) // } // comma: const = 0x2c (1 bytes) // } // } // null: const = 0x0 (1 bytes) // } // } // chdir: int8 = 0xfe (1 bytes) // size: len = 0x44f (8 bytes) // img: ptr[in, buffer] { // buffer: (compressed buffer with length 0x44f) // } // ] // returns fd_dir memcpy((void*)0x20000080, "ext4\000", 5); memcpy((void*)0x20000200, "./file0\000", 8); memcpy((void*)0x20001100, "oldalloc", 8); *(uint8_t*)0x20001108 = 0x2c; memcpy((void*)0x20001109, "noinit_itable", 13); *(uint8_t*)0x20001116 = 0x22; memcpy((void*)0x20001117, "dioread_lock", 12); *(uint8_t*)0x20001123 = 0x2c; memcpy((void*)0x20001124, "data=journal", 12); *(uint8_t*)0x20001130 = 0x2c; memcpy((void*)0x20001131, "nouid32", 7); *(uint8_t*)0x20001138 = 0x2c; memcpy((void*)0x20001139, "usrjquota=", 10); *(uint8_t*)0x20001143 = 0x22; memcpy((void*)0x20001144, "errors=continue", 15); *(uint8_t*)0x20001153 = 0x2c; memcpy((void*)0x20001154, "errors=remount-ro", 17); *(uint8_t*)0x20001165 = 0x2c; memcpy((void*)0x20001166, "jqfmt=vfsv1", 11); *(uint8_t*)0x20001171 = 0x2c; memcpy((void*)0x20001172, "grpquota", 8); *(uint8_t*)0x2000117a = 0x2c; memcpy((void*)0x2000117b, "smackfshat", 10); *(uint8_t*)0x20001185 = 0x3d; memcpy((void*)0x20001186, "data=journal", 12); *(uint8_t*)0x20001192 = 0x2c; memcpy((void*)0x20001193, "context", 7); *(uint8_t*)0x2000119a = 0x3d; memcpy((void*)0x2000119b, "system_u", 8); *(uint8_t*)0x200011a3 = 0x2c; memcpy((void*)0x200011a4, "uid<", 4); sprintf((char*)0x200011a8, "%020llu", (long long)0); *(uint8_t*)0x200011bc = 0x2c; memcpy((void*)0x200011bd, "uid", 3); *(uint8_t*)0x200011c0 = 0x3d; sprintf((char*)0x200011c1, "%020llu", (long long)0); *(uint8_t*)0x200011d5 = 0x2c; memcpy((void*)0x200011d6, "appraise_type=imasig", 20); *(uint8_t*)0x200011ea = 0x2c; memcpy((void*)0x200011eb, "seclabel", 8); *(uint8_t*)0x200011f3 = 0x2c; memcpy((void*)0x200011f4, "audit", 5); *(uint8_t*)0x200011f9 = 0x2c; memcpy((void*)0x200011fa, "measure", 7); *(uint8_t*)0x20001201 = 0x2c; *(uint8_t*)0x20001202 = 0; memcpy( (void*)0x20000900, "\x78\x9c\xec\xdc\xcd\x4f\x5c\x55\x1b\x00\xf0\x67\x66\x18\x5a\xda\xf2\xc2" "\x5b\xeb\x47\xb1\x55\xb4\x1a\x89\x1f\x50\xe8\x87\x5d\xb8\xb0\x46\x13\x17" "\x9a\x98\xe8\xa2\xc6\x15\x02\x6d\xb0\xd3\x62\x0a\x26\xb6\x21\x8a\x2e\x70" "\x69\x9a\xb8\x37\x2e\x4d\xfc\x0b\xdc\x58\x37\x46\x5d\x99\xb8\xd5\xbd\x31" "\x21\x86\x8d\xd5\xd5\x98\x3b\x73\x2f\x8c\x30\x03\x0c\x0c\x4c\xed\xfc\x7e" "\xc9\x25\xe7\xcc\x39\xe4\x9c\xe7\xde\x7b\x66\xce\x9c\x7b\xef\x04\xd0\xb1" "\x06\x93\x3f\xb9\x88\x43\x11\xf1\x4b\x44\xf4\x55\xb3\xab\x9e\xaf\x56\x4a" "\xea\xdd\x5e\x9e\x9f\xf8\x6b\x79\x7e\x22\x17\xe5\xf2\xeb\x7f\xe4\x2a\xf5" "\xfe\x5c\x9e\x9f\xc8\xaa\x66\xff\x77\xb0\x9a\x29\x97\x37\x68\x77\xf1\xad" "\x88\xf1\x52\x69\xea\x5a\x9a\x1f\x99\xbb\xf2\xee\xc8\xec\xf5\x1b\xcf\x4c" "\x5f\x19\xbf\x34\x75\x69\xea\xea\xd8\xb9\x73\xa7\x4f\x1d\xef\x3e\x3b\x76" "\xa6\x25\x71\xf6\x26\x7d\x1d\xf8\x60\xe6\xd8\xd1\x97\xdf\xbc\xf9\xea\xc4" "\x85\x9b\x6f\xff\xf0\x55\xd2\xdf\x43\x69\x79\x6d\x1c\xad\x32\x58\xdd\xbb" "\x75\x3d\xde\xea\xc6\xda\xac\xb7\x26\x9d\xeb\x6a\x63\x47\x68\x4a\x21\x22" "\x92\xc3\x55\xac\x8c\xff\xbe\x28\x44\xcf\x4a\x59\x5f\xbc\xf4\x71\x5b\x3b" "\x07\xec\xaa\x72\x39\x5f\xde\xd7\xb8\x78\xa1\x0c\xdc\xc5\x92\x89\x3a\xd0" "\x89\xb2\x0f\xfa\xe4\xfb\x6f\xb6\xed\xd1\xd4\xe3\x8e\xb0\x74\x3e\x56\xd6" "\x31\x6e\xa7\x5b\xb5\xa4\x2b\xf2\x69\x9d\x62\xfa\x1d\x69\x37\x0c\x46\xc4" "\x85\x85\xbf\x3f\x4f\xb6\xd8\xa5\x75\x08\x00\x80\x5a\xb7\xce\x47\xc4\xd3" "\xf5\xe6\x7f\xf9\xb8\xaf\xa6\xde\xff\xd2\x6b\x43\xfd\x11\xf1\xff\x88\x38" "\x1c\x11\xf7\x44\xc4\x91\x88\xb8\x37\xa2\x52\xf7\xfe\x88\x78\xa0\xc9\xf6" "\xd7\x5e\x21\x59\x3f\xff\x29\xf7\x6d\x2b\xb0\x2d\x4a\xe6\x7f\xcf\xa5\xd7" "\xb6\xfe\x3d\xff\xcb\x66\x7f\xd1\x5f\x48\x73\xbd\x95\xf8\x8b\xb9\x8b\xd3" "\xa5\xa9\x93\xe9\x3e\x19\x8a\xe2\xbe\x24\x3f\xba\x41\x1b\xdf\xbe\xf8\xf3" "\xa7\x8d\xca\x6a\xe7\x7f\xc9\x96\xb4\x9f\xcd\x05\xd3\x7e\xfc\xde\xb5\x66" "\x81\x6e\x72\x7c\x6e\x7c\x27\x31\xd7\x5a\xfa\x28\x62\xa0\xab\x5e\xfc\xb9" "\x95\x39\x6f\x32\x3f\x3e\x1a\x11\x03\xdb\x6c\x63\xfa\xc9\x2f\x8f\x35\x2a" "\xdb\x3c\xfe\x0d\xb4\x60\x52\x5e\xfe\x22\xe2\x89\xea\xf1\x5f\x88\x35\xf1" "\x67\x72\x0d\xaf\x4f\x8e\x3e\x7b\x76\xec\xcc\xc8\xfe\x28\x4d\x9d\x1c\xc9" "\xce\x8a\xf5\x7e\xfc\x69\xf1\xb5\x46\xed\xef\x28\xfe\x16\x58\xba\x55\x8e" "\x03\x75\xcf\xff\x95\xf8\xfb\x73\xfb\x23\x66\xaf\xdf\xb8\x5c\xb9\x5e\x3b" "\xdb\x7c\x1b\x8b\xbf\x7e\xd2\xf0\x3b\xcd\x76\xcf\xff\xee\xdc\x1b\x95\x74" "\x77\xfa\xda\xfb\xe3\x73\x73\xd7\x46\x23\xba\x73\xaf\xac\x7f\x7d\x6c\xf5" "\x7f\xb3\x7c\x56\x3f\x39\xff\x87\x4e\xd4\x1f\xff\x87\x63\x75\x4f\x3c\x18" "\x11\xc9\x49\x7c\x3c\x22\x1e\x8a\x88\x87\xd3\xbe\x3f\x12\x11\x8f\x46\xc4" "\x89\x0d\xe2\xff\xfe\x85\xc7\xde\x69\x3e\xfe\x0d\x56\xe5\x5b\x28\x89\x7f" "\x72\xb3\xe3\x1f\xb5\xc7\xbf\xf9\x44\xe1\xf2\x77\x5f\x37\x1f\x7f\x26\x39" "\xfe\xa7\x2b\xa9\xa1\xf4\x95\xad\xbc\xff\x6d\xb5\x83\x3b\xd9\x77\x00\x00" "\x00\xf0\x5f\x91\xaf\xdc\x03\x9f\xcb\x0f\xaf\xa4\xf3\xf9\xe1\xe1\xea\x3d" "\xfc\x47\xe2\x40\xbe\x34\x33\x3b\xf7\xd4\xc5\x99\xf7\xae\x4e\x56\xef\x95" "\xef\x8f\x62\x3e\x5b\xe9\xea\xab\x59\x0f\x1d\x4d\xd7\x86\xb3\xfc\xd8\x9a" "\xfc\xa9\x74\xdd\xf8\xb3\x42\x4f\x25\x3f\x3c\x31\x53\x9a\x6c\x77\xf0\xd0" "\xe1\x0e\x36\x18\xff\x89\xdf\x0a\xed\xee\x1d\xb0\xeb\x3c\xaf\x05\x9d\xcb" "\xf8\x87\xce\x65\xfc\x43\xe7\x32\xfe\xa1\x73\x19\xff\xd0\xb9\xea\x8d\xff" "\x0f\xdb\xd0\x0f\x60\xef\x6d\xf2\xf9\xdf\xb3\x57\xfd\x00\xf6\x9e\xf9\x3f" "\x74\x2e\xe3\x1f\x3a\x97\xf1\x0f\x1d\xa9\xe1\xb3\xf1\xf9\x1d\x3d\xf2\x2f" "\xd1\xa6\xc4\x37\xdd\x3b\xfb\xad\x86\xad\x27\x22\x7f\x87\x84\x7c\xd7\x24" "\x8a\x51\xb7\xa8\x6b\xcb\x3f\x66\xb1\xcd\xc4\xbe\xba\x45\xed\x7e\x67\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\x68\x8d\x7f\x02\x00\x00\xff" "\xff\x12\xfe\xe3\x34", 1103); syz_mount_image( /*fs=*/0x20000080, /*dir=*/0x20000200, /*flags=MS_SYNCHRONOUS|MS_STRICTATIME|MS_NOSUID|MS_NOEXEC|0x80*/ 0x100009a, /*opts=*/0x20001100, /*chdir=*/0xfe, /*size=*/0x44f, /*img=*/0x20000900); // openat$udambuf arguments: [ // fd: const = 0xffffffffffffff9c (8 bytes) // file: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 75 64 6d 61 62 75 66 00} (length 0xd) // } // flags: const = 0x2 (4 bytes) // ] // returns fd_udambuf memcpy((void*)0x20000140, "/dev/udmabuf\000", 13); res = syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0x20000140ul, /*flags=*/2, 0); if (res != -1) r[0] = res; // memfd_create arguments: [ // name: ptr[in, buffer] { // buffer: {79 10 35 fb f7 75 83 25 3a 72 c2 b9 78 a4 71 c1 ea 5f 8c 5a // 84 7d 58 73 37 e7 61 9b 11 78 0e a1 cf 1a 98 53 37 c9 00 00 00 00 00 // 00 07 00 00 e7 d7 3e 0a 84 8c 54 e3 35 6b e9 90 87 39 a2 34 a9 61 6d // de b2 d3 cb 5a 4a 6f 61 c4 1a 63 42 aa c1 fb 20 51 d4 d4 bd 7b 9f a9 // 97 9b 40 db 00 62 e1 62 72 b6 00 38 e3 10 ff c2 9d 0d 32 9e 8e 04 73 // 57 1b b7 b3 a2 c9 26 40 ca da dc e2 2f 97 58 ac 08 b0 c2 3c 80 45 1a // bc c7 57 da 39 56 73 41 af c6 cf e1 a1 b5 4d a2 85 a6 79 c4 4a f1 f7 // fc 44 95 e3 eb c7 bc 91 b0 a8 9e 6f eb 46 28 9d 4c 01 76 52 6b aa 63 // 42 04 a7 49 0b 86 45 5a 96 d5 14 01 00 00 00 00 00 00 00 cc d1 0f 72 // 65 e8 36 cd eb c4 24 b0 06 4a d6 64 44 8d 5f 55 60 6a 69 7b ab 97 af // 3b 6c 1f af b3 38 55 cb fa b3 6a 92 0c 81 a0 a2 2d 67 08 99 0e 8d 8d // 16 d9 77 5c f8 ce b0 6a 9d 27 93 ef 1d a0 48 d9 bd d9 af 12 24 8d 16 // 25 8b 00 00 00 00 00 00 00 00 00} (length 0x11c) // } // flags: memfd_flags = 0x2 (8 bytes) // ] // returns fd_memfd memcpy( (void*)0x20000ec0, "y\0205\373\367u\203%:r\302\271x\244q\301\352_\214Z\204}" "Xs7\347a\233\021x\016\241\317\032\230S7\311\000\000\000\000\000\000\a" "\000\000\347\327>" "\n\204\214T\3435k\351\220\2079\2424\251am\336\262\323\313ZJoa\304\032cB" "\252\301\373 " "Q\324\324\275{\237\251\227\233@" "\333\000b\341br\266\0008\343\020\377\302\235\r2\236\216\004sW\033\267" "\263\242\311&@\312\332\334\342/" "\227X\254\b\260\302<" "\200E\032\274\307W\3329VsA\257\306\317\341\241\265M\242\205\246y\304J" "\361\367\374D\225\343\353\307\274\221\260\250\236o\353F(" "\235L\001vRk\252cB\004\247I\v\206EZ\226\325\024\001\000\000\000\000\000" "\000\000\314\321\017re\3506\315\353\304$\260\006J\326dD\215_U`ji{" "\253\227\257;l\037\257\2638U\313\372\263j\222\f\201\240\242-" "g\b\231\016\215\215\026\331w\\\370\316\260j\235\'\223\357\035\240H\331" "\275\331\257\022$\215\026%\213\000\000\000\000\000\000\000\000\000", 284); res = syscall(__NR_memfd_create, /*name=*/0x20000ec0ul, /*flags=MFD_ALLOW_SEALING*/ 2ul); if (res != -1) r[1] = res; // ftruncate arguments: [ // fd: fd (resource) // len: intptr = 0xffff (8 bytes) // ] syscall(__NR_ftruncate, /*fd=*/r[1], /*len=*/0xfffful); // fcntl$addseals arguments: [ // fd: fd (resource) // cmd: const = 0x409 (8 bytes) // seals: seal_types = 0x7 (8 bytes) // ] syscall(__NR_fcntl, /*fd=*/r[1], /*cmd=*/0x409ul, /*seals=F_SEAL_GROW|F_SEAL_SHRINK|F_SEAL_SEAL*/ 7ul); // ioctl$UDMABUF_CREATE arguments: [ // fd: fd_udambuf (resource) // cmd: const = 0x40187542 (4 bytes) // arg: ptr[in, udmabuf_create] { // udmabuf_create { // memfd: fd_memfd (resource) // flags: int32 = 0x0 (4 bytes) // offset: udmabuf_offset_size = 0x0 (8 bytes) // size: udmabuf_offset_size = 0x1000 (8 bytes) // } // } // ] // returns fd_dma_buf *(uint32_t*)0x20000000 = r[1]; *(uint32_t*)0x20000004 = 0; *(uint64_t*)0x20000008 = 0; *(uint64_t*)0x20000010 = 0x1000; res = syscall(__NR_ioctl, /*fd=*/r[0], /*cmd=*/0x40187542, /*arg=*/0x20000000ul); if (res != -1) r[2] = res; // fcntl$dupfd arguments: [ // fd: fd (resource) // cmd: fcntl_dupfd = 0x0 (8 bytes) // arg: fd (resource) // ] // returns fd res = syscall(__NR_fcntl, /*fd=*/r[2], /*cmd=*/0ul, /*arg=*/r[1]); if (res != -1) r[3] = res; // mount$9p_fd arguments: [ // src: const = 0x0 (8 bytes) // dst: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 30 2f 2e 2e 2f 66 69 6c 65 30 00} (length // 0x11) // } // type: ptr[in, buffer] { // buffer: {39 70 00} (length 0x3) // } // flags: mount_flags = 0x0 (8 bytes) // opts: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {74 72 61 6e 73 3d 66 64 2c 72 66 64 6e 6f 3d} // (length 0xf) // } // union ANYUNION { // ANYRESHEX: ANYRES64 (resource) // } // union ANYUNION { // ANYBLOB: buffer: {2c 77 66 64 6e 6f 3d} (length 0x7) // } // union ANYUNION { // ANYRESOCT: ANYRES64 (resource) // } // } // } // ] memcpy((void*)0x20000080, "./file0/../file0\000", 17); memcpy((void*)0x20000240, "9p\000", 3); memcpy((void*)0x20000040, "trans=fd,rfdno=", 15); sprintf((char*)0x2000004f, "0x%016llx", (long long)r[3]); memcpy((void*)0x20000061, ",wfdno=", 7); sprintf((char*)0x20000068, "%023llo", (long long)r[1]); syscall(__NR_mount, /*src=*/0ul, /*dst=*/0x20000080ul, /*type=*/0x20000240ul, /*flags=*/0ul, /*opts=*/0x20000040ul); } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x21000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); const char* reason; (void)reason; loop(); return 0; }