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