// 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);
}

uint64_t r[1] = {0xffffffffffffffff};

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