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