// https://syzkaller.appspot.com/bug?id=12a5d737c6cb6a2fd8e914a73d87759f83822cff // 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_memfd_create #define __NR_memfd_create 319 #endif static unsigned long long procid; static void sleep_ms(uint64_t ms) { usleep(ms * 1000); } static uint64_t current_time_ms(void) { struct timespec ts; if (clock_gettime(CLOCK_MONOTONIC, &ts)) exit(1); return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000; } static void 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; } //% 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"); } 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 < 10; 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 == 3 ? 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++) { 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[1] = {0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: // clock_adjtime arguments: [ // id: clock_id = 0x0 (8 bytes) // tx: ptr[in, timex] { // timex { // stuff0: intptr = 0x7fff (8 bytes) // stuff1: intptr = 0x0 (8 bytes) // stuff2: intptr = 0xfffffffffffffffd (8 bytes) // stuff3: intptr = 0x0 (8 bytes) // stuff4: intptr = 0x0 (8 bytes) // stuff5: intptr = 0x0 (8 bytes) // stuff6: intptr = 0x0 (8 bytes) // stuff7: intptr = 0x0 (8 bytes) // stuff8: intptr = 0x0 (8 bytes) // stuff9: intptr = 0x0 (8 bytes) // stuff10: intptr = 0x0 (8 bytes) // stuff11: intptr = 0x29e9 (8 bytes) // stuff12: intptr = 0x0 (8 bytes) // stuff13: intptr = 0x0 (8 bytes) // stuff14: intptr = 0x0 (8 bytes) // stuff15: intptr = 0x0 (8 bytes) // stuff16: intptr = 0x0 (8 bytes) // stuff17: intptr = 0x0 (8 bytes) // stuff18: intptr = 0x0 (8 bytes) // stuff19: intptr = 0x0 (8 bytes) // stuff20: intptr = 0x0 (8 bytes) // stuff21: intptr = 0x0 (8 bytes) // stuff22: intptr = 0x10 (8 bytes) // stuff23: intptr = 0x0 (8 bytes) // stuff24: intptr = 0x0 (8 bytes) // stuff25: intptr = 0x0 (8 bytes) // } // } // ] *(uint64_t*)0x200000000000 = 0x7fff; *(uint64_t*)0x200000000008 = 0; *(uint64_t*)0x200000000010 = 0xfffffffffffffffd; *(uint64_t*)0x200000000018 = 0; *(uint64_t*)0x200000000020 = 0; *(uint64_t*)0x200000000028 = 0; *(uint64_t*)0x200000000030 = 0; *(uint64_t*)0x200000000038 = 0; *(uint64_t*)0x200000000040 = 0; *(uint64_t*)0x200000000048 = 0; *(uint64_t*)0x200000000050 = 0; *(uint64_t*)0x200000000058 = 0x29e9; *(uint64_t*)0x200000000060 = 0; *(uint64_t*)0x200000000068 = 0; *(uint64_t*)0x200000000070 = 0; *(uint64_t*)0x200000000078 = 0; *(uint64_t*)0x200000000080 = 0; *(uint64_t*)0x200000000088 = 0; *(uint64_t*)0x200000000090 = 0; *(uint64_t*)0x200000000098 = 0; *(uint64_t*)0x2000000000a0 = 0; *(uint64_t*)0x2000000000a8 = 0; *(uint64_t*)0x2000000000b0 = 0x10; *(uint64_t*)0x2000000000b8 = 0; *(uint64_t*)0x2000000000c0 = 0; *(uint64_t*)0x2000000000c8 = 0; syscall(__NR_clock_adjtime, /*id=*/0ul, /*tx=*/0x200000000000ul); break; case 1: // prlimit64 arguments: [ // pid: pid (resource) // res: rlimit_type = 0xe (8 bytes) // new: ptr[in, rlimit] { // rlimit { // soft: intptr = 0x10001 (8 bytes) // hard: intptr = 0x20000001000 (8 bytes) // } // } // old: nil // ] *(uint64_t*)0x200000000600 = 0x10001; *(uint64_t*)0x200000000608 = 0x20000001000; syscall(__NR_prlimit64, /*pid=*/0, /*res=RLIMIT_RTPRIO*/ 0xeul, /*new=*/0x200000000600ul, /*old=*/0ul); break; case 2: // sched_setscheduler arguments: [ // pid: pid (resource) // policy: sched_policy = 0x1 (8 bytes) // prio: ptr[in, int32] { // int32 = 0x7 (4 bytes) // } // ] *(uint32_t*)0x200000000080 = 7; syscall(__NR_sched_setscheduler, /*pid=*/0, /*policy=SCHED_FIFO*/ 1ul, /*prio=*/0x200000000080ul); break; case 3: // syz_mount_image$vfat arguments: [ // fs: ptr[in, buffer] { // buffer: {76 66 61 74 00} (length 0x5) // } // dir: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 30 00} (length 0x8) // } // flags: mount_flags = 0x18000 (8 bytes) // opts: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYRES32: ANYRES32 (resource) // } // union ANYUNION { // ANYRES16: ANYRES16 (resource) // } // union ANYUNION { // ANYRESOCT: ANYRES64 (resource) // } // union ANYUNION { // ANYBLOB: buffer: {fe 2e cf 20 a9 a1 7b d2 ed 7e 80 3f 83 03 75 // c1 50 a1 f8 48 f6 04 c2 c1 f9 32 d2 b7 16 3b e4 b2 b9 a5 bd 52 // 1d 18 5c fb ee 55 5b 27 60 85 94 be ba 63 25 92 3a af 5d b7 4c // ff 01 00 00 53 db 92 c6 c5 fc bb a0 ab d9 75 fc 76 be a4 9b 00 // 51 3a fc 85 6e d8 9d 3f ad ed a3 07 ca 58 73 54 32 28 03 b0 98 // 3c c6 57 25 ae 7f 45 fb 95 e7 cd b2 8c 6b 88 69 59 b7 dd e2 c8 // 7c 73 f6 00 8c f6 ee d7 86 1f 24 b7 42 37 04 b9 5f 3d 05 b9 2d // 3d 7f f9 d3 92 83 3e cd 02 44 33 20 b6 01 31 a3 50 36 0f cc 1d // 65 9e 2a 03 cb 46 9c af 04 98 ba ca e0 73 5a 16 13 45 b3 d7 1a // 55 f1 4e f6 36 b6 f8 32 c7 a6 07 1f ce 83 90 4d fd 87 1b 6d 8e // 03 64 8d ba a3 a0 39 eb 56 73 79 2c ae 80 33 57 32 03 0f 9a ea // ba f3 bb 3c c4 ca 5f e7 52 71 d6 9b 2e 78 be b2 b8 1f c3 cf 3a // 18 a7 ae 93 a3 cd be 65 99 b9 94 08 27 5e 2b 4b 44 77 c6 fc f4 // 80 61 34 e8 39 e1 bd 33 ec 00 00 00 00 00 00 00 6a 1c 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 69 c3 28 83 11 b7 41 47 05 e9 75 eb 3f 1b 77 a1 20} // (length 0x148) // } // union ANYUNION { // ANYRES32: ANYRES32 (resource) // } // union ANYUNION { // ANYRES64: ANYRES64 (resource) // } // union ANYUNION { // ANYRESDEC: ANYRES64 (resource) // } // } // } // chdir: int8 = 0x1 (1 bytes) // size: len = 0x304 (8 bytes) // img: ptr[in, buffer] { // buffer: (compressed buffer with length 0x304) // } // ] // returns fd_dir memcpy((void*)0x200000000080, "vfat\000", 5); memcpy((void*)0x200000000480, "./file0\000", 8); *(uint32_t*)0x200000000640 = 0; *(uint16_t*)0x200000000644 = -1; sprintf((char*)0x200000000646, "%023llo", (long long)-1); memcpy( (void*)0x20000000065d, "\xfe\x2e\xcf\x20\xa9\xa1\x7b\xd2\xed\x7e\x80\x3f\x83\x03\x75\xc1\x50" "\xa1\xf8\x48\xf6\x04\xc2\xc1\xf9\x32\xd2\xb7\x16\x3b\xe4\xb2\xb9\xa5" "\xbd\x52\x1d\x18\x5c\xfb\xee\x55\x5b\x27\x60\x85\x94\xbe\xba\x63\x25" "\x92\x3a\xaf\x5d\xb7\x4c\xff\x01\x00\x00\x53\xdb\x92\xc6\xc5\xfc\xbb" "\xa0\xab\xd9\x75\xfc\x76\xbe\xa4\x9b\x00\x51\x3a\xfc\x85\x6e\xd8\x9d" "\x3f\xad\xed\xa3\x07\xca\x58\x73\x54\x32\x28\x03\xb0\x98\x3c\xc6\x57" "\x25\xae\x7f\x45\xfb\x95\xe7\xcd\xb2\x8c\x6b\x88\x69\x59\xb7\xdd\xe2" "\xc8\x7c\x73\xf6\x00\x8c\xf6\xee\xd7\x86\x1f\x24\xb7\x42\x37\x04\xb9" "\x5f\x3d\x05\xb9\x2d\x3d\x7f\xf9\xd3\x92\x83\x3e\xcd\x02\x44\x33\x20" "\xb6\x01\x31\xa3\x50\x36\x0f\xcc\x1d\x65\x9e\x2a\x03\xcb\x46\x9c\xaf" "\x04\x98\xba\xca\xe0\x73\x5a\x16\x13\x45\xb3\xd7\x1a\x55\xf1\x4e\xf6" "\x36\xb6\xf8\x32\xc7\xa6\x07\x1f\xce\x83\x90\x4d\xfd\x87\x1b\x6d\x8e" "\x03\x64\x8d\xba\xa3\xa0\x39\xeb\x56\x73\x79\x2c\xae\x80\x33\x57\x32" "\x03\x0f\x9a\xea\xba\xf3\xbb\x3c\xc4\xca\x5f\xe7\x52\x71\xd6\x9b\x2e" "\x78\xbe\xb2\xb8\x1f\xc3\xcf\x3a\x18\xa7\xae\x93\xa3\xcd\xbe\x65\x99" "\xb9\x94\x08\x27\x5e\x2b\x4b\x44\x77\xc6\xfc\xf4\x80\x61\x34\xe8\x39" "\xe1\xbd\x33\xec\x00\x00\x00\x00\x00\x00\x00\x6a\x1c\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x69\xc3\x28\x83\x11\xb7\x41\x47\x05\xe9\x75\xeb" "\x3f\x1b\x77\xa1\x20", 328); *(uint32_t*)0x2000000007a5 = 0; *(uint64_t*)0x2000000007a9 = -1; sprintf((char*)0x2000000007b1, "%020llu", (long long)0); memcpy( (void*)0x200000000bc0, "\x78\x9c\xec\xdc\xcf\x4f\x13\x69\x18\xc0\xf1\xa7\x3f\x28\x6d\x09\x94" "\xc3\x66\x37\xbb\xc9\x86\x77\x77\x2f\xeb\x65\x02\xd5\xb3\xd2\x18\x48" "\x8c\x4d\x24\x48\x8d\x3f\x12\x93\x01\xa6\xda\x74\x6c\x49\xa7\xc1\xd4" "\x18\x91\x93\x57\xe3\xcd\x7f\xc0\x03\xe1\xc8\x8d\x44\xf9\x07\xb8\x78" "\xd3\x8b\x17\x6f\x5c\x4c\x3c\xc8\xc1\x38\xa6\xd3\x19\x4a\xcb\x14\xa4" "\xb4\x94\x1f\xdf\x4f\x42\xe6\xe1\x7d\xde\x67\x3a\x6f\x5b\xc8\x33\x0d" "\x2f\x5b\xb7\x5f\x3e\xca\x67\x2d\x2d\xab\x97\x25\x18\x55\x12\x10\x11" "\xd9\x16\x19\x96\xa0\x78\x02\xee\x31\xe8\xc4\x11\xd9\xed\xb9\x5c\x18" "\xf8\xfa\xe1\xef\x9b\x77\xee\x5e\x4f\xa5\xd3\x13\xd3\x4a\x4d\xa6\x66" "\x2e\x26\x95\x52\x43\x23\x6f\x1f\x3f\x8d\xb9\xd3\xd6\xfb\x65\x73\xf8" "\xfe\xd6\x97\xe4\xe7\xcd\xdf\x37\xff\xdc\xfa\x31\xf3\x30\x67\xa9\x9c" "\xa5\x0a\xc5\xb2\xd2\xd5\x6c\xf1\x53\x59\x9f\x35\x0d\x35\x9f\xb3\xf2" "\x9a\x52\x53\xa6\xa1\x5b\x86\xca\x15\x2c\xa3\x54\xcb\x17\x6b\xf9\xac" "\x59\x5c\x58\xa8\x28\xbd\x30\x3f\x18\x5f\x28\x19\x96\xa5\xf4\x42\x45" "\xe5\x8d\x8a\x2a\x17\x55\xb9\x54\x51\xa1\x07\x7a\xae\xa0\x34\x4d\x53" "\x83\x71\xc1\x41\x32\x2b\xd3\xd3\x7a\xaa\xcd\xe2\xb9\x0e\x5f\x0c\xba" "\xa4\x54\x4a\xe9\x21\x11\x89\xed\xc9\x64\x56\x7a\x72\x41\x00\x00\xa0" "\xa7\x9a\xfb\xff\xa0\xa8\x4e\xf6\xff\xab\xff\x6e\x94\x07\x6e\xad\x0d" "\xb9\xfd\xff\x7a\xc4\xaf\xff\xbf\xf4\xb1\x76\xae\x86\xfe\x3f\x2a\x22" "\xbe\xfd\xbf\xf7\xf8\xbe\xfd\xbf\x7e\xb8\xfe\x7f\x6f\x47\x74\x4a\xd9" "\x76\x5b\x65\x47\xea\xff\x71\x32\x8c\x44\xf6\x0c\x05\xea\x61\x35\x59" "\x4a\xe9\x71\xf7\xe7\xd7\xb1\x7c\x6f\x75\xd4\x09\xe8\xff\x01\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x38\x0d\xb6" "\x6d\x3b\x61\xdb\x76\xc2\x3b\x7a\x5f\xfd\x22\x12\x75\x36\x96\xd4\xbe" "\xf7\x29\x0d\x89\xc8\x95\x1e\x5c\x32\x3a\xe8\x08\xaf\x3f\xce\x80\xfa" "\xc6\xbd\xf0\x90\x88\xf9\x62\x31\xb3\x98\xa9\x1d\xdd\x09\x1b\x22\x62" "\x3a\xaf\x7f\x42\xbe\x3b\xef\x07\x57\x35\xf6\x76\x1e\xa9\xaa\x61\x79" "\x67\x2e\xb9\xf5\x4b\x8b\x99\x90\x93\x49\x65\x25\x27\xa6\x18\x32\x26" "\x89\x3e\x69\xae\xb7\xed\xc9\x6b\xe9\x89\x31\x55\xd3\x58\xdf\x27\xf1" "\xdd\xf5\x49\x49\xc8\x6f\xfe\xf5\x49\xdf\xfa\x88\xfc\xff\xdf\xae\x7a" "\x4d\x12\xf2\x7e\x4e\x8a\x62\xca\xbc\xbb\x61\xce\xab\x7f\x36\xa6\xd4" "\xd5\x1b\xe9\xa6\xfa\x98\x33\x0f\x00\x00\x00\x00\x80\xb3\x40\x53\x3b" "\x7c\xef\xdf\x35\xad\x55\xbe\x56\xbf\x73\x7f\x3d\xda\xf4\xf9\x40\xa8" "\x7e\x7f\x3d\xea\x7b\x7f\x1e\x96\xbf\xc2\xbd\x5d\x3b\x00\x00\x00\x00" "\x00\xe7\x85\x55\x79\x92\xd7\x4d\xd3\x28\xed\x04\x83\x22\xd2\x38\x12" "\x93\xe6\x39\x9d\x0c\xc2\x5d\x3a\xb3\xb7\xc2\x5f\xad\xf2\xfe\x96\xa1" "\x7b\x2b\xdd\x27\xf0\x1e\xbc\x21\x15\x75\x07\x3b\xfe\xb4\x04\x0e\xf1" "\xb4\xb4\x08\x82\xd2\x4e\xd5\x48\x75\x35\xaa\x29\xf5\xcf\xb2\xcf\xda" "\xf7\x0b\xbc\x8f\x8d\x5a\xcd\x91\xa9\x71\x77\xe4\x75\xcb\x39\xdd\x09" "\xfe\x78\xf5\xe6\x5b\xe7\x4e\x78\x79\x2d\x7a\xc0\x4a\xdb\x0f\x42\xfb" "\xbf\x01\xfa\x8e\xe7\xb7\x0f\x00\x00\x00\x80\xe3\x54\x6f\xfa\xbd\x91" "\xf1\xde\x5e\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe7\xd0\x71\xfc\x77\xb4\x5e" "\xaf\x11\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x38\x29\x7e\x06\x00" "\x00\xff\xff\xd9\xad\x02\xed", 772); syz_mount_image(/*fs=*/0x200000000080, /*dir=*/0x200000000480, /*flags=MS_POSIXACL|MS_SILENT*/ 0x18000, /*opts=*/0x200000000640, /*chdir=*/1, /*size=*/0x304, /*img=*/0x200000000bc0); break; case 4: // openat$cgroup_ro arguments: [ // fd: fd_cgroup (resource) // file: ptr[in, buffer] { // buffer: {6d 65 6d 6f 72 79 2e 65 76 65 6e 74 73 2e 6c 6f 63 61 6c // 00} (length 0x14) // } // flags: const = 0x275a (4 bytes) // mode: const = 0x0 (2 bytes) // ] // returns fd memcpy((void*)0x200000000840, "memory.events.local\000", 20); res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x200000000840ul, /*flags=*/0x275a, /*mode=*/0); if (res != -1) r[0] = res; break; case 5: // write$binfmt_script arguments: [ // fd: fd_binfmt (resource) // data: ptr[in, binfmt_script] { // binfmt_script { // hdr: buffer: {23 21 20} (length 0x3) // bin: buffer: {} (length 0x0) // args: array[binfmt_script_arg] { // } // nl: const = 0xa (1 bytes) // data: buffer: {} (length 0x0) // } // } // len: bytesize = 0x208e24b (8 bytes) // ] memcpy((void*)0x200000000040, "#! ", 3); *(uint8_t*)0x200000000043 = 0xa; syscall(__NR_write, /*fd=*/r[0], /*data=*/0x200000000040ul, /*len=*/0x208e24bul); break; case 6: // mmap arguments: [ // addr: VMA[0xb36000] // len: len = 0xb36000 (4 bytes) // prot: mmap_prot = 0x2 (8 bytes) // flags: mmap_flags = 0x28011 (8 bytes) // fd: fd (resource) // offset: intptr = 0x0 (8 bytes) // ] syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0xb36000, /*prot=PROT_WRITE*/ 2ul, /*flags=MAP_STACK|MAP_POPULATE|MAP_FIXED|MAP_SHARED*/ 0x28011ul, /*fd=*/r[0], /*offset=*/0ul); break; case 7: // fdatasync arguments: [ // fd: fd (resource) // ] syscall(__NR_fdatasync, /*fd=*/r[0]); break; case 8: // madvise arguments: [ // addr: VMA[0x600000] // len: len = 0x600003 (8 bytes) // advice: madvise_flags = 0x15 (8 bytes) // ] syscall(__NR_madvise, /*addr=*/0x200000000000ul, /*len=*/0x600003ul, /*advice=MADV_PAGEOUT*/ 0x15ul); break; case 9: // mlock arguments: [ // addr: VMA[0x800000] // size: len = 0x800000 (8 bytes) // ] syscall(__NR_mlock, /*addr=*/0x200000000000ul, /*size=*/0x800000ul); break; } } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*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=*/0x200001000000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); const char* reason; (void)reason; for (procid = 0; procid < 5; procid++) { if (fork() == 0) { loop(); } } sleep(1000000); return 0; }