// https://syzkaller.appspot.com/bug?id=46dad9184d8294a90c841b553a5dfc0f86aab2a4 // 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"); } 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 == 0 ? 4000 : 0) + (call == 2 ? 4000 : 0) + (call == 5 ? 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[2] = {0xffffffffffffffff, 0xffffffffffffffff}; void execute_call(int call) { intptr_t res = 0; switch (call) { case 0: memcpy((void*)0x20000140, "vfat\000", 5); memcpy((void*)0x20000040, "./file0\000", 8); memcpy( (void*)0x20000180, "\x78\x9c\xec\xdd\xcf\x6b\x23\x65\x18\xc0\xf1\x27\x69\x36\xbf\x96\x6d" "\x72\x10\x45\x41\xfa\xa0\x17\xbd\x0c\x6d\xf4\xac\x06\xd9\x05\x31\xe0" "\xd2\xdd\x88\xbb\x82\x30\xbb\x9d\x68\xc8\x98\x94\x99\x50\x89\x88\xad" "\x27\xaf\xe2\xcd\x7f\x40\x70\xd9\x63\x6f\x05\xf5\x1f\xe8\xc5\x5b\xbd" "\x78\xf1\xd6\x4b\x41\xd0\x22\xe2\xc8\x4c\x66\xda\xfc\x98\x24\x4d\x9a" "\x92\xd6\x7e\x3f\x50\xf2\x4c\xde\xf7\x99\x99\x37\x33\x84\xe7\x0d\xcc" "\xdb\xc3\x0f\xbe\xf9\xb4\x51\x73\x8d\x9a\xd9\x96\x64\x56\x25\x21\x22" "\x72\x2c\x52\x94\xa4\x44\x12\xe1\x6b\x32\x88\xd3\xd2\x6b\x47\x5e\xbd" "\xf9\xc7\xc1\x8b\xf7\x1e\x3c\x7c\xb7\x5c\xa9\xdc\x5e\x57\xbd\x53\xbe" "\xff\x5a\x49\x55\x97\x57\x7e\xfc\xec\x8b\x5c\xd8\x6d\x2f\x23\xfb\xc5" "\x8f\x0e\x8f\x4a\xbf\xef\x3f\xbb\xff\xfc\xe1\xbf\xf7\x3f\xa9\xbb\x5a" "\x77\xb5\xd9\x6a\xab\xa9\x8f\x5a\xbf\xb5\xcd\x47\xb6\xa5\x1b\x75\xb7" "\x61\xa8\xde\xb5\x2d\xd3\xb5\xb4\xde\x74\x2d\xa7\xdb\xde\xea\xb6\xd7" "\xec\xd6\xe6\x66\x47\xcd\xe6\xc6\xad\xfc\xa6\x63\xb9\xae\x9a\xcd\x8e" "\x36\xac\x8e\xb6\x5b\xda\x76\x3a\x6a\x7e\x6c\xd6\x9b\x6a\x18\x86\xde" "\xca\xcb\xf5\x92\x1d\xd8\xf6\x12\x93\x73\xaa\x4f\xd6\xd7\xcd\xf2\x8c" "\x07\x7c\x3c\x63\x1e\xe6\xed\x6f\xcf\xf3\xc6\x34\x3b\x4e\xd9\x5c\x12" "\x31\x72\x43\x2d\xd5\x27\x17\x7a\x5e\x00\x00\xe0\x52\x1a\xa8\xff\xbf" "\x8b\x6a\x84\xa2\x24\x4f\x0a\xca\x44\xdf\x5c\x60\xb8\xfe\x8f\xe2\xa0" "\xfe\xf7\xab\xce\xd3\xfa\xff\xe9\x4b\x3f\xb7\x6f\xbe\xbf\xbb\x1c\xd6" "\xff\x7b\xe9\xb8\xfa\xff\xf5\x5f\xbb\xf9\x7d\xf5\xbf\x7f\xf4\xb9\xd7" "\xff\x3f\x0c\x6c\x0f\x57\x44\x57\xde\xf6\x34\x9d\xcf\x55\xff\xe3\x72" "\x58\x49\x0f\xbd\xd5\x3f\xf5\xf3\xeb\xff\x7c\x38\x7f\x0f\x7c\xf5\xe1" "\xd3\xd5\x20\xa0\xfe\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\xe0\x2a\x38\xf6\xbc\x82\xe7\x79\x85\xe8\x35\xfa" "\x3b\x7d\x84\x20\xdc\x8e\xb6\xc6\x3d\x68\x8c\x2b\x67\xd4\xf5\xcf\x84" "\x2b\x0a\x9c\xdc\x0f\xf8\x5f\xba\xf7\xe0\xa1\x64\x83\x07\xf7\x52\xcb" "\x22\xf6\xd7\x5b\xd5\xad\x6a\xf7\x35\x6c\x8f\x3a\xae\x4a\x41\xfe\x09" "\xee\x87\x50\x77\xc1\x89\x9d\xa0\x51\x7d\x45\xf9\xc9\xde\x0e\xf3\xb7" "\xb7\xaa\x4b\x41\x4b\x59\x44\xc5\x16\x4b\xd6\xa4\x20\xc5\xbe\xfc\x20" "\xbe\xf3\x4e\xe5\xf6\x9a\x76\xf5\xe7\x27\x52\x79\x3f\xbf\x26\xf5\x20" "\xbf\x24\x05\x79\x26\x3e\xbf\x14\x9b\x9f\x96\x57\x5e\xee\xc9\x37\xa4" "\x20\xbf\x3c\x96\x96\xd8\xb2\x11\x7e\x8f\x45\xf9\x5f\xae\xa9\xbe\xfd" "\x5e\x65\x20\x3f\x17\xf4\x8b\xf3\xe6\xc5\x5f\x16\x00\x00\x00\x00\x00" "\xe6\xca\x50\xcd\x86\xd3\xe7\xd8\xf9\xbb\x61\xa8\xc6\xb5\xfb\x73\x79" "\xe9\x9d\x9f\x0f\xff\x3e\x70\x32\xbf\x5e\x8d\x9d\x9f\xa7\x0a\x2f\xa4" "\x16\x3b\x76\x00\x00\x00\x00\x00\xae\x0b\x37\xfd\x79\xc3\xb4\x6d\xcb" "\x71\x3b\x23\x83\x9c\x4c\xea\x93\x09\xf7\x36\x7e\x3f\xf1\x41\x6a\x9a" "\xce\x7e\x70\x10\x04\x37\xc6\xf5\x59\xea\x19\xe1\x59\xf7\x9c\x0e\xff" "\x83\xc6\x14\x27\x2f\xd3\x8d\xd4\xb4\xed\x3f\x33\x12\xfb\x61\x46\x4b" "\xb8\xf6\x35\x65\xcf\xf1\xa9\x9a\x76\x34\xfe\x33\x74\xce\x4e\x7b\x09" "\x1c\x37\x39\xfd\xd8\x2d\xc7\x5d\xf1\xcf\x47\x67\x1a\x4e\x4f\x10\xfd" "\x6c\x34\xaa\x8f\xdc\x9d\x75\xcf\xa3\x82\x68\xe5\xdc\x49\x9d\x9f\xfb" "\xf6\xfb\xbf\x66\x3b\x44\x22\x5c\xb5\xb7\xb7\xe9\x8d\xdd\xec\x84\x91" "\x06\x41\x62\xe0\x9d\x9d\x09\x37\xed\x91\xe7\x4d\x3c\x9f\x1b\x17\xf9" "\x9d\x03\x00\x00\x00\x60\x31\xa2\xa2\x3f\xe7\x46\xef\xbc\xb5\xd8\x13" "\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\xe0\x1a\x9a\xeb\x32\x69\x23\x82\x45\x8f\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\xb8\x2c\xfe\x0b\x00\x00\xff" "\xff\xbd\x9b\xf9\x62", 855); syz_mount_image(/*fs=*/0x20000140, /*dir=*/0x20000040, /*flags=MS_NOATIME*/ 0x400, /*opts=*/0x20000000, /*chdir=*/1, /*size=*/0x357, /*img=*/0x20000180); break; case 1: memcpy((void*)0x20000380, "./file0\000", 8); res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x20000380ul, /*flags=O_TRUNC|O_NOFOLLOW|O_CREAT|O_RDWR*/ 0x20242, /*mode=*/0); if (res != -1) r[0] = res; break; case 2: memcpy((void*)0x20000f40, "msdos\000", 6); memcpy((void*)0x20000140, ".\000", 2); syz_mount_image( /*fs=*/0x20000f40, /*dir=*/0x20000140, /*flags=MS_I_VERSION|MS_PRIVATE|MS_SYNCHRONOUS|MS_STRICTATIME|MS_SILENT|MS_REMOUNT|0x202408*/ 0x1a4a438, /*opts=*/0x200008c0, /*chdir=*/0xb, /*size=*/0, /*img=*/0x20000000); break; case 3: *(uint16_t*)0x20000140 = 0; *(uint16_t*)0x20000142 = 0; *(uint64_t*)0x20000148 = 0x100000; *(uint64_t*)0x20000150 = 5; *(uint32_t*)0x20000158 = 0; *(uint32_t*)0x2000015c = 0; memset((void*)0x20000160, 0, 16); syscall(__NR_ioctl, /*fd=*/r[0], /*cmd=*/0x40305828, /*arg=*/0x20000140ul); break; case 4: memcpy((void*)0x20000000, "./bus\000", 6); syscall(__NR_open, /*file=*/0x20000000ul, /*flags=O_NOFOLLOW|O_NOCTTY|O_NOATIME|O_CREAT|O_RDWR*/ 0x60142ul, /*mode=*/0ul); break; case 5: memcpy((void*)0x20003880, "vfat\000", 5); memcpy((void*)0x20000000, "./file0\000", 8); memcpy((void*)0x200000c0, "iocharset=iso8859-%,utf8=1,shortname=lower,uni_xlate=1,shortname=" "win95,iocharset=cp775,uni_xlate=1,rodir,utf8=1,uni_xlate=0,tz=UTC," "rodir,uni_xlate=0,utf8=0,codepage=1255,nonumtail=0,\000", 183); memcpy( (void*)0x20002300, "\x78\x9c\xec\xdd\x3f\x6b\x23\x47\x14\x00\xf0\xb7\xb2\x2c\x29\x49\x21" "\x15\xa9\x42\x20\x0b\x49\x91\xca\xd8\x6e\xd3\xc8\x04\x1b\x4c\x54\x25" "\xa8\x48\x52\x24\x26\xb6\x21\x58\x22\x60\x83\x21\x7f\x88\xe2\x2a\x6d" "\x9a\x94\xf9\x04\x81\x40\xba\xfb\x12\xd7\xdc\x37\x38\xb8\xf6\xe0\xba" "\x73\x61\xd8\x63\xa5\xdd\x93\xec\x93\x65\xeb\xb0\xec\xfb\xf3\xfb\x35" "\x1e\xcf\xce\x9b\x79\x33\x1e\x6c\x5c\xec\xd3\xf7\x1f\xf6\x0f\x76\xd3" "\xd8\x3f\xf9\xed\x61\x34\x1a\x49\x54\xda\xd1\x8e\xd3\x24\x5a\x51\x89" "\xd2\x1f\x71\x4e\xfb\xaf\x00\x00\x5e\x67\xa7\x59\x16\x4f\xb2\x91\x79" "\xe2\x92\x88\x68\x2c\x2e\x2d\x00\x60\x81\xe6\xfe\xfb\xff\xff\xc2\x53" "\x02\x00\x16\xec\xab\xaf\xbf\xf9\x62\xa3\xd3\xd9\xfc\x32\x4d\x1b\xb1" "\xd5\xff\xf3\xb8\x9b\xff\x67\x9f\x7f\x1d\x3d\xdf\xd8\x8f\x1f\xa3\x17" "\x7b\xb1\x1a\xcd\x38\x8b\xc8\x9e\x1b\xb5\xb7\xb2\x2c\x1b\x54\xd3\x5c" "\x2b\x3e\xe9\x0f\x8e\xbb\x79\x64\xff\xbb\xfb\xc5\xfc\x1b\x8f\x23\x86" "\xf1\x6b\xd1\x8c\xd6\xb0\xeb\x7c\xfc\x76\x67\x73\x2d\x1d\x99\x88\x1f" "\xe4\x79\xbc\x5b\xac\xdf\xce\xe3\xd7\xa3\x19\xef\x4f\x59\x7f\xbb\xb3" "\xb9\x3e\x25\x3e\xba\xb5\xf8\xf4\xe3\x89\xfc\x57\xa2\x19\x0f\x7e\x88" "\x9f\xa2\x17\xbb\xc3\x24\xc6\xf1\xbf\xaf\xa5\xe9\xe7\xd9\xdf\x4f\x7f" "\xfd\x36\x4f\x2f\x8f\x4f\x06\xc7\xdd\xfa\x70\xdc\x58\xb6\x74\xcb\x3f" "\x1a\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\xde\x60\x2b\x45\xed\x9c\x7a\x0c\xeb\xf7\xe4\x5d\x45\xfd\x9d\xa5" "\xb3\xfc\x9b\xe5\x48\x4b\xad\xf3\xf5\x79\x46\xf1\x49\x39\xd1\x85\xfa" "\x40\x83\x2c\xfe\x29\xeb\xeb\xac\xa6\x69\x9a\x15\x03\xc7\xf1\xd5\xf8" "\xa0\x1a\xd5\xbb\xd9\x35\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\xbc\x5a\x8e\x7e\xfe\xe5\x60\xa7\xd7\xdb\x3b\xbc\x91" "\x46\x59\x0d\xa0\x7c\xad\xff\x65\xe7\x69\x4f\xf4\x7c\x14\xb3\x07\xd7" "\xc7\x6b\x55\x8a\xe6\x8c\x99\x63\xa9\x1c\x93\x44\xcc\x4c\x23\xdf\xc4" "\x0d\x1d\xcb\x55\x8d\x77\x2e\xcb\xf9\xdf\xff\xe6\x9d\xb0\x71\xf5\x98" "\xe5\x59\xe7\x73\x33\x8d\xf2\x76\x1d\xec\x24\xd3\xcf\xb0\x1e\x65\x4f" "\xa3\xbc\x24\xf7\x26\xc7\xd4\xe2\x9a\x6b\xd5\x2e\x7b\x94\xcd\x75\xfd" "\x6a\x53\x1f\x35\xe7\xde\x7b\xed\xbd\x61\x63\x30\x63\x4c\x24\xb3\x12" "\xfb\xec\xd1\xe8\xe4\x8a\x9e\xe4\xe2\x2e\x6a\xc3\x53\x9d\x1a\xbe\x5c" "\x34\x26\xc2\x2f\xdc\x8d\xb9\xee\xf3\x8b\xbf\x2b\x12\xd5\x3a\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x60\xa1\xc6\x2f\xfd" "\x4e\x79\x78\x32\x33\xb4\x92\xd5\x17\x96\x16\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\xdc\xaa\xf1\xe7\xff\xcf\xd1\x18\x14" "\xc1\xd7\x18\x5c\x8b\xc3\xa3\x3b\xde\x22\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x6f\x81" "\x67\x01\x00\x00\xff\xff\xc3\x51\x62\x02", 673); syz_mount_image( /*fs=*/0x20003880, /*dir=*/0x20000000, /*flags=MS_POSIXACL|MS_REC|MS_SYNCHRONOUS|MS_NOSUID|MS_NODIRATIME*/ 0x14812, /*opts=*/0x200000c0, /*chdir=*/0x25, /*size=*/0x2a1, /*img=*/0x20002300); break; case 6: memcpy((void*)0x20000380, "/dev/loop", 9); *(uint8_t*)0x20000389 = 0x30 + procid * 1; *(uint8_t*)0x2000038a = 0; memcpy((void*)0x20000340, "./bus\000", 6); syscall(__NR_mount, /*src=*/0x20000380ul, /*dst=*/0x20000340ul, /*type=*/0ul, /*flags=MS_BIND*/ 0x1000ul, /*data=*/0ul); break; case 7: memcpy((void*)0x200005c0, "./bus\000", 6); res = syscall(__NR_open, /*file=*/0x200005c0ul, /*flags=*/0ul, /*mode=*/0ul); if (res != -1) r[1] = res; break; case 8: *(uint32_t*)0x20000140 = 0; syscall(__NR_ioctl, /*fd=*/r[1], /*cmd=*/0x4c02, /*arg=*/0x20000140ul); break; case 9: memcpy((void*)0x20000000, "./file2\000", 8); memcpy((void*)0x20000040, "./file1\000", 8); syscall(__NR_rename, /*old=*/0x20000000ul, /*new=*/0x20000040ul); break; } } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-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=*/-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x21000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1, /*offset=*/0ul); const char* reason; (void)reason; for (procid = 0; procid < 5; procid++) { if (fork() == 0) { loop(); } } sleep(1000000); return 0; }