// https://syzkaller.appspot.com/bug?id=deb061ff946b02c2f4821f91683d89a68b2f45f8
// autogenerated by syzkaller (https://github.com/google/syzkaller)

#define _GNU_SOURCE

#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <sched.h>
#include <setjmp.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/mount.h>
#include <sys/prctl.h>
#include <sys/resource.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>

#include <linux/capability.h>
#include <linux/loop.h>

#ifndef __NR_memfd_create
#define __NR_memfd_create 319
#endif

static unsigned long long procid;

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) {
    errno = EMSGSIZE;
    return -1;
  }
  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, 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 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, loopfd = -1, 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) {
    memset(loopname, 0, sizeof(loopname));
    snprintf(loopname, sizeof(loopname), "/dev/loop%llu", procid);
    if (setup_loop_device(data, size, loopname, &loopfd) == -1)
      return -1;
    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) {
    if (strstr(opts, "errors=panic") || strstr(opts, "errors=remount-ro") == 0)
      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) {
    ioctl(loopfd, LOOP_CLR_FD, 0);
    close(loopfd);
  }
  errno = err;
  return res;
}

static void setup_common()
{
  if (mount(0, "/sys/fs/fuse/connections", "fusectl", 0, 0)) {
  }
}

static void setup_binderfs()
{
  if (mkdir("/dev/binderfs", 0777)) {
  }
  if (mount("binder", "/dev/binderfs", "binder", 0, NULL)) {
  }
  if (symlink("/dev/binderfs", "./binderfs")) {
  }
}

static void loop();

static void sandbox_common()
{
  prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
  setsid();
  struct rlimit rlim;
  rlim.rlim_cur = rlim.rlim_max = (200 << 20);
  setrlimit(RLIMIT_AS, &rlim);
  rlim.rlim_cur = rlim.rlim_max = 32 << 20;
  setrlimit(RLIMIT_MEMLOCK, &rlim);
  rlim.rlim_cur = rlim.rlim_max = 136 << 20;
  setrlimit(RLIMIT_FSIZE, &rlim);
  rlim.rlim_cur = rlim.rlim_max = 1 << 20;
  setrlimit(RLIMIT_STACK, &rlim);
  rlim.rlim_cur = rlim.rlim_max = 128 << 20;
  setrlimit(RLIMIT_CORE, &rlim);
  rlim.rlim_cur = rlim.rlim_max = 256;
  setrlimit(RLIMIT_NOFILE, &rlim);
  if (unshare(CLONE_NEWNS)) {
  }
  if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL)) {
  }
  if (unshare(CLONE_NEWIPC)) {
  }
  if (unshare(0x02000000)) {
  }
  if (unshare(CLONE_NEWUTS)) {
  }
  if (unshare(CLONE_SYSVSEM)) {
  }
  typedef struct {
    const char* name;
    const char* value;
  } sysctl_t;
  static const sysctl_t sysctls[] = {
      {"/proc/sys/kernel/shmmax", "16777216"},
      {"/proc/sys/kernel/shmall", "536870912"},
      {"/proc/sys/kernel/shmmni", "1024"},
      {"/proc/sys/kernel/msgmax", "8192"},
      {"/proc/sys/kernel/msgmni", "1024"},
      {"/proc/sys/kernel/msgmnb", "1024"},
      {"/proc/sys/kernel/sem", "1024 1048576 500 1024"},
  };
  unsigned i;
  for (i = 0; i < sizeof(sysctls) / sizeof(sysctls[0]); i++)
    write_file(sysctls[i].name, sysctls[i].value);
}

static int wait_for_loop(int pid)
{
  if (pid < 0)
    exit(1);
  int status = 0;
  while (waitpid(-1, &status, __WALL) != pid) {
  }
  return WEXITSTATUS(status);
}

static void drop_caps(void)
{
  struct __user_cap_header_struct cap_hdr = {};
  struct __user_cap_data_struct cap_data[2] = {};
  cap_hdr.version = _LINUX_CAPABILITY_VERSION_3;
  cap_hdr.pid = getpid();
  if (syscall(SYS_capget, &cap_hdr, &cap_data))
    exit(1);
  const int drop = (1 << CAP_SYS_PTRACE) | (1 << CAP_SYS_NICE);
  cap_data[0].effective &= ~drop;
  cap_data[0].permitted &= ~drop;
  cap_data[0].inheritable &= ~drop;
  if (syscall(SYS_capset, &cap_hdr, &cap_data))
    exit(1);
}

static int do_sandbox_none(void)
{
  if (unshare(CLONE_NEWPID)) {
  }
  int pid = fork();
  if (pid != 0)
    return wait_for_loop(pid);
  setup_common();
  sandbox_common();
  drop_caps();
  if (unshare(CLONE_NEWNET)) {
  }
  write_file("/proc/sys/net/ipv4/ping_group_range", "0 65535");
  setup_binderfs();
  loop();
  exit(1);
}

void loop(void)
{
  memcpy((void*)0x20000600, "hfsplus\000", 8);
  memcpy((void*)0x20000040, "./file0\000", 8);
  memcpy(
      (void*)0x20000140,
      "\x00\xe1\x8c\x00\xeb\x80\x78\x01\x99\xe9\xac\xa7\x06\xa2\xd2\x4b\xf0\x50"
      "\xc6\x83\x01\xd2\xa0\xc0\x00\xfa\x00\x00\x00\x00\x00\x00\x00\x01\x4d\xbe"
      "\x69\xd4\x9e\x11\x4e\x82\xbe\xfa\x86\x07\x00\x15\x60\x93\xad\x39\xba\xbc"
      "\x01\x41\xf8\xdd\x7c\xb8\xbc\xf6\xa7\xce\x0e\x00\x00\x00\x00\x00\x00\xd4"
      "\xf2\x22\xc5\x34\x67\xf0\xd5\xc9\x96\xe2\xee\x7a\x3e\x65\x6a\x5a\x40\xf1"
      "\x2d\x0c\x2a\xe9\x6b\xe7\x79\x6e\x51\x7e\x06\xf0\xf7\x6d\xe6\xd4\x5f\x3f"
      "\x3d\xa0\x72\x19\xb3\x2a\x13\xa6\x2b\x36\xe1\x0b\xe2\xe4\x66\xe9\x75\x7e"
      "\xbd\x6c\x2a\x7a\xd8\x6d\xad\x5d\x3c\xa9\xdf\xa0\xf8\x82\x0f\x6a\xb9\x66"
      "\x00\x55\x30\x5a\xc3\xfa\xb6\x74\x46\x32\x70\x4e\x8b\xb1\xc9\xbe\x92\x0e"
      "\xf0\x4f\xfe\x4c\xfa\x4f\xe4\xf9\x8c\x72\x48\xd9\xd0\x3c\xeb\xbe\xc3\x51"
      "\x68\x4f\xdc\xab\xce\xf6\x90\xf9\xc4\xc6\x55\xe3\x5b\x7f\x6b\xc1\xe1\x91"
      "\x5e\xf8\x4f\x60\x61\x55\xc6\x17\x63\x2a\x8a\x86\xb0\xa8\xb9\xd7\xf9\xdd"
      "\xce\x19\xa8\x9d\xca\xe3\x05\xa8\xfd\xd9\x02\x62\xe4\x1f\x09\xec\xe3\xa0"
      "\xe9\xd7\x0a\xb5\xb5\xa5\xa0\x08\x3d\x58\x08\xfe\x9b\xd4\x73\xf1\x23\x02"
      "\x67\x28\xbe\x5d\xa6\x19\x63\xcd\x1d\x9b\x5e\x1b\x99\x85\x46\x2b\xbb\xfd"
      "\x75\x4b\xae\x42\x1a\x8e\x3c\x63",
      278);
  memcpy(
      (void*)0x20000640,
      "\x78\x9c\xec\xdd\xcd\x6f\x1c\x67\x1d\x07\xf0\xef\x6c\x36\x4e\x36\x48\xa9"
      "\xdb\x26\x69\x40\x95\xb0\x1a\xa9\x20\x2c\x12\xbf\xc8\x05\x73\x21\x20\x84"
      "\x7c\xa8\x50\x55\x0e\x9c\xad\xc4\x69\xac\x6c\xdc\x62\x6f\x91\x5b\x21\x08"
      "\xef\x57\x0e\xfd\x03\xca\xc1\x37\x4e\x48\xdc\x23\x95\x33\xdc\x7a\xf5\xb1"
      "\x12\x12\x97\x9e\xcc\x69\xd1\xcc\xce\xda\x1b\xdb\x71\xd7\x8d\x93\x5d\x93"
      "\xcf\x27\x7a\xf6\x79\x9e\x7d\x66\x9e\xf9\xcd\x6f\x67\x76\x76\xd6\x8a\x36"
      "\xc0\x73\x6b\x69\x3a\xcd\x87\x29\xb2\x34\xfd\xe6\x66\xd9\xdf\xde\x9a\x6f"
      "\x6f\x6f\xcd\xdf\xef\xb7\x93\x9c\x4b\xd2\x48\x9a\xbd\x2a\xc5\x5a\x52\x7c"
      "\x92\xdc\x4c\xaf\xe4\xab\xe5\x93\xf5\x74\xc5\xe3\xb6\xf3\xd1\xea\xe2\xdb"
      "\x9f\x7e\xbe\xfd\x59\xaf\xd7\xac\x4b\xb5\x7c\xe3\xa8\xf5\x86\xf3\xa0\x2e"
      "\x99\x4a\x72\xa6\xae\x4f\x6a\xbe\x5b\x4f\x3c\x5f\xf1\xc8\x1e\x5e\xeb\x27"
      "\x0e\x46\xad\x7b\xc0\xcf\xaf\x1c\x63\xf5\x27\x3c\x6f\x81\x71\x50\xf4\xae"
      "\x9b\x07\x4c\x26\x17\x92\x9c\xaf\x3f\x07\xf4\xae\x8a\xbd\x6b\xf6\xa9\xf6"
      "\x60\xd4\x01\x00\x00\x00\xc0\x33\xf0\xc2\x4e\x76\xb2\x99\x8b\xa3\x8e\x03"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x4e\x93\xfa\xf7\xff\x8b\xba\x34\xfa"
      "\xed\xa9\x14\xfd\xdf\xff\x9f\xa8\x9f\x4b\xdd\x3e\xd5\x1e\x8e\x3a\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x38\x01\x5f\xdf\xc9\x4e\x36\x73\xb1\xdf\xef\x16"
      "\xd5\xdf\xfc\x5f\xab\x3a\x97\xaa\xc7\xaf\xe4\xfd\x6c\x64\x25\xeb\xb9\x9e"
      "\xcd\x2c\xa7\x93\x4e\xd6\x33\x9b\x64\x72\x60\xa2\x89\xcd\xe5\x4e\x67\x7d"
      "\x76\x88\x35\xe7\x0e\x5d\x73\xee\xd9\xec\x2f\x00\x00\x00\x00\x00\x00\x00"
      "\xfc\x9f\xfa\x6d\x96\xf6\xfe\xfe\x0f\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\xe3\xa0\x48\xce\xf4\xaa\xaa\x5c\xea\xb7\x27\xd3\x68\x26\x39\x9f"
      "\x64\xa2\x5c\xee\x41\xf2\xaf\x7e\xfb\x34\x7b\x38\xea\x00\x00\x00\x00\xe0"
      "\x19\x78\x61\x27\x3b\xd9\xcc\xc5\x7e\xbf\x5b\x54\xf7\xfc\x57\xaa\xfb\xfe"
      "\xf3\x79\x3f\x6b\xe9\x64\x35\x9d\xb4\xb3\x92\xdb\xd5\x77\x01\xbd\xbb\xfe"
      "\xc6\xf6\xd6\x7c\x7b\x7b\x6b\xfe\x7e\x59\x0e\xce\xfb\x83\xff\x1c\x2b\x8c"
      "\x6a\xc6\xf4\xbe\x7b\x38\x7c\xcb\x57\xab\x25\x5a\x8d\x3b\x59\xad\x9e\xb9"
      "\x9e\x5b\x79\x37\xed\xdc\x4e\xa3\x5a\xb3\x74\xb5\x1f\xcf\xe1\x71\xfd\xa6"
      "\x8c\xa9\xf8\x7e\x6d\xc8\xc8\x6e\xd7\x75\xb9\xe7\x7f\xae\xeb\xf1\x30\x59"
      "\x65\xe4\x6c\xfa\x19\x99\xa9\x63\x2b\xb3\xf1\xe2\xd1\x99\x38\xe6\xab\xb3"
      "\x7f\x4b\xb3\x69\xec\x7e\xf3\x73\xe9\x29\xe4\xfc\x42\x5d\x97\xfb\xf3\xc7"
      "\x47\x72\xde\x3c\x56\xdc\x27\x6f\x7f\x26\xe6\x06\x8e\xbe\x2b\x47\x67\x22"
      "\xf9\xc6\xdf\xff\xfa\xb3\xbb\xed\xb5\x7b\x77\xef\x6c\x4c\x8f\xcf\x61\xf4"
      "\x25\xed\xcf\xc4\xfc\x40\x26\x5e\x79\xae\x32\x31\x53\x65\xe2\xf2\x6e\x7f"
      "\x29\x3f\xce\x4f\x33\x9d\xa9\xbc\x95\xf5\xac\xe6\x17\x59\x4e\x27\x2b\x99"
      "\xca\x8f\xaa\xd6\x72\x7d\x3c\x97\x8f\x93\x47\x67\xea\xe6\x23\xbd\xb7\xbe"
      "\x28\x92\x89\xfa\x75\xe9\xbd\x8b\x1e\x2f\xa6\xd7\xaa\x75\x2f\x66\x35\x3f"
      "\xc9\xbb\xb9\x9d\x95\xbc\x51\xfd\x9b\xcb\x6c\xbe\x93\x85\x2c\x64\x71\xe0"
      "\x15\xbe\x3c\xc4\x59\xdf\x38\xde\x59\x7f\xed\x9b\x75\xa3\x95\xe4\x4f\x75"
      "\x3d\x1e\xca\xbc\xbe\x38\x90\xd7\xc1\xf7\xdc\xc9\x6a\x6c\xf0\x99\xbd\x2c"
      "\xbd\x74\xf2\xef\x8d\xcd\xaf\xd5\x8d\x72\x1b\xbf\xab\xeb\xf1\xb0\x3f\x13"
      "\xb3\x03\x99\x78\xf9\xe8\x4c\xfc\xa5\x5b\x3e\x6e\xb4\xd7\xee\xad\xdf\x5d"
      "\x7e\x6f\xc8\xed\xbd\x5e\xd7\xe5\x79\xf4\x87\xb1\xba\x32\x97\xc7\xcb\x4b"
      "\xbb\x57\xab\x47\x8f\x8e\x72\xec\xe5\x43\xc7\x66\xab\xb1\x4b\xbb\x63\x8d"
      "\x03\x63\x97\x77\xc7\xbe\xe8\x4c\x9d\xa8\x3f\xc3\x1d\x9c\x69\xae\x1a\x7b"
      "\xe5\xd0\xb1\xf9\x6a\xec\xea\xc0\x58\x2b\x07\x3f\x6f\x01\x30\xf6\x2e\x7c"
      "\xeb\xc2\x44\xeb\xdf\xad\x7f\xb6\x3e\x6e\xfd\xbe\x75\xb7\xf5\xe6\xf9\x1f"
      "\x9e\xfb\xee\xb9\x57\x27\x72\xf6\x1f\x67\xbf\xd7\x9c\x39\xf3\x7a\xe3\xd5"
      "\xe2\x6f\xf9\x38\xbf\xda\xbb\xff\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xbe\xbc\x8d\x0f"
      "\x3e\xbc\xb7\xdc\x6e\xaf\xac\xef\x6b\x74\xbb\xdd\x5f\x3f\x66\x48\x43\xe3"
      "\xd8\x8d\xff\x76\xbb\xdd\x31\x08\x63\xc8\x46\xb7\x36\x2e\xf1\x8c\xa2\x31"
      "\xea\x77\x26\xe0\x69\xbb\xd1\xb9\xff\xde\x8d\x8d\x0f\x3e\xfc\xf6\xea\xfd"
      "\xe5\x77\x56\xde\x59\x59\x5b\x5c\x58\x58\x9c\x59\x5c\x78\x63\xfe\xc6\x9d"
      "\xd5\xf6\xca\x4c\xef\x71\xd4\x51\x02\x4f\xc3\xde\x45\x7f\xd4\x91\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\xc3\x7a\x16\xff\x9d\x60\xd4\xfb\x08\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x9c\x6e\x4b\xd3\x69\x3e\x4c\x91\xd9\x99\xeb\x33\x65\x7f\x7b\x6b"
      "\xbe\x5d\x96\x7e\x7b\x6f\xc9\x66\x92\x46\x92\xe2\x97\x49\xf1\x49\x72\x33"
      "\xbd\x92\xc9\x81\xe9\x8a\xc7\x6d\xe7\xa3\xd5\xc5\xb7\x3f\xfd\x7c\xfb\xb3"
      "\xbd\xb9\x9a\xfd\xe5\x1b\x47\xad\x37\x9c\x07\x75\xc9\x54\x92\x33\x75\x7d"
      "\x52\xf3\xdd\x7a\xe2\xf9\x8a\xdd\x3d\x2c\x13\x76\xad\x9f\x38\x18\xb5\xff"
      "\x05\x00\x00\xff\xff\x0c\x15\x18\x1a",
      1521);
  syz_mount_image(0x20000600, 0x20000040, 0x8004d0, 0x20000140, 1, 0x5f1,
                  0x20000640);
  memcpy((void*)0x20000000, "./file0\000", 8);
  syscall(__NR_creat, 0x20000000ul, 0x100ul);
}
int main(void)
{
  syscall(__NR_mmap, 0x1ffff000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
  syscall(__NR_mmap, 0x20000000ul, 0x1000000ul, 7ul, 0x32ul, -1, 0ul);
  syscall(__NR_mmap, 0x21000000ul, 0x1000ul, 0ul, 0x32ul, -1, 0ul);
  do_sandbox_none();
  return 0;
}