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

#define _GNU_SOURCE

#include <dirent.h>
#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <setjmp.h>
#include <signal.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/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>

#include <linux/loop.h>

#ifndef __NR_memfd_create
#define __NR_memfd_create 319
#endif

static unsigned long long procid;

static void sleep_ms(uint64_t ms)
{
  usleep(ms * 1000);
}

static uint64_t current_time_ms(void)
{
  struct timespec ts;
  if (clock_gettime(CLOCK_MONOTONIC, &ts))
    exit(1);
  return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000;
}

static 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;
}

const int kInitNetNsFd = 201;

static long syz_init_net_socket(volatile long domain, volatile long type,
                                volatile long proto)
{
  return syscall(__NR_socket, domain, type, proto);
}

//% This code is derived from puff.{c,h}, found in the zlib development. The
//% original files come with the following copyright notice:

//% Copyright (C) 2002-2013 Mark Adler, all rights reserved
//% version 2.3, 21 Jan 2013
//% This software is provided 'as-is', without any express or implied
//% warranty.  In no event will the author be held liable for any damages
//% arising from the use of this software.
//% Permission is granted to anyone to use this software for any purpose,
//% including commercial applications, and to alter it and redistribute it
//% freely, subject to the following restrictions:
//% 1. The origin of this software must not be misrepresented; you must not
//%    claim that you wrote the original software. If you use this software
//%    in a product, an acknowledgment in the product documentation would be
//%    appreciated but is not required.
//% 2. Altered source versions must be plainly marked as such, and must not be
//%    misrepresented as being the original software.
//% 3. This notice may not be removed or altered from any source distribution.
//% Mark Adler    madler@alumni.caltech.edu

//% BEGIN CODE DERIVED FROM puff.{c,h}

#define MAXBITS 15
#define MAXLCODES 286
#define MAXDCODES 30
#define MAXCODES (MAXLCODES + MAXDCODES)
#define FIXLCODES 288

struct puff_state {
  unsigned char* out;
  unsigned long outlen;
  unsigned long outcnt;
  const unsigned char* in;
  unsigned long inlen;
  unsigned long incnt;
  int bitbuf;
  int bitcnt;
  jmp_buf env;
};
static int puff_bits(struct puff_state* s, int need)
{
  long val = s->bitbuf;
  while (s->bitcnt < need) {
    if (s->incnt == s->inlen)
      longjmp(s->env, 1);
    val |= (long)(s->in[s->incnt++]) << s->bitcnt;
    s->bitcnt += 8;
  }
  s->bitbuf = (int)(val >> need);
  s->bitcnt -= need;
  return (int)(val & ((1L << need) - 1));
}
static int puff_stored(struct puff_state* s)
{
  s->bitbuf = 0;
  s->bitcnt = 0;
  if (s->incnt + 4 > s->inlen)
    return 2;
  unsigned len = s->in[s->incnt++];
  len |= s->in[s->incnt++] << 8;
  if (s->in[s->incnt++] != (~len & 0xff) ||
      s->in[s->incnt++] != ((~len >> 8) & 0xff))
    return -2;
  if (s->incnt + len > s->inlen)
    return 2;
  if (s->outcnt + len > s->outlen)
    return 1;
  for (; len--; s->outcnt++, s->incnt++) {
    if (s->in[s->incnt])
      s->out[s->outcnt] = s->in[s->incnt];
  }
  return 0;
}
struct puff_huffman {
  short* count;
  short* symbol;
};
static int puff_decode(struct puff_state* s, const struct puff_huffman* h)
{
  int first = 0;
  int index = 0;
  int bitbuf = s->bitbuf;
  int left = s->bitcnt;
  int code = first = index = 0;
  int len = 1;
  short* next = h->count + 1;
  while (1) {
    while (left--) {
      code |= bitbuf & 1;
      bitbuf >>= 1;
      int count = *next++;
      if (code - count < first) {
        s->bitbuf = bitbuf;
        s->bitcnt = (s->bitcnt - len) & 7;
        return h->symbol[index + (code - first)];
      }
      index += count;
      first += count;
      first <<= 1;
      code <<= 1;
      len++;
    }
    left = (MAXBITS + 1) - len;
    if (left == 0)
      break;
    if (s->incnt == s->inlen)
      longjmp(s->env, 1);
    bitbuf = s->in[s->incnt++];
    if (left > 8)
      left = 8;
  }
  return -10;
}
static int puff_construct(struct puff_huffman* h, const short* length, int n)
{
  int len;
  for (len = 0; len <= MAXBITS; len++)
    h->count[len] = 0;
  int symbol;
  for (symbol = 0; symbol < n; symbol++)
    (h->count[length[symbol]])++;
  if (h->count[0] == n)
    return 0;
  int left = 1;
  for (len = 1; len <= MAXBITS; len++) {
    left <<= 1;
    left -= h->count[len];
    if (left < 0)
      return left;
  }
  short offs[MAXBITS + 1];
  offs[1] = 0;
  for (len = 1; len < MAXBITS; len++)
    offs[len + 1] = offs[len] + h->count[len];
  for (symbol = 0; symbol < n; symbol++)
    if (length[symbol] != 0)
      h->symbol[offs[length[symbol]]++] = symbol;
  return left;
}
static int puff_codes(struct puff_state* s, const struct puff_huffman* lencode,
                      const struct puff_huffman* distcode)
{
  static const short lens[29] = {3,  4,  5,  6,   7,   8,   9,   10,  11, 13,
                                 15, 17, 19, 23,  27,  31,  35,  43,  51, 59,
                                 67, 83, 99, 115, 131, 163, 195, 227, 258};
  static const short lext[29] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2,
                                 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0};
  static const short dists[30] = {
      1,    2,    3,    4,    5,    7,    9,    13,    17,    25,
      33,   49,   65,   97,   129,  193,  257,  385,   513,   769,
      1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577};
  static const short dext[30] = {0, 0, 0,  0,  1,  1,  2,  2,  3,  3,
                                 4, 4, 5,  5,  6,  6,  7,  7,  8,  8,
                                 9, 9, 10, 10, 11, 11, 12, 12, 13, 13};
  int symbol;
  do {
    symbol = puff_decode(s, lencode);
    if (symbol < 0)
      return symbol;
    if (symbol < 256) {
      if (s->outcnt == s->outlen)
        return 1;
      if (symbol)
        s->out[s->outcnt] = symbol;
      s->outcnt++;
    } else if (symbol > 256) {
      symbol -= 257;
      if (symbol >= 29)
        return -10;
      int len = lens[symbol] + puff_bits(s, lext[symbol]);
      symbol = puff_decode(s, distcode);
      if (symbol < 0)
        return symbol;
      unsigned dist = dists[symbol] + puff_bits(s, dext[symbol]);
      if (dist > s->outcnt)
        return -11;
      if (s->outcnt + len > s->outlen)
        return 1;
      while (len--) {
        if (dist <= s->outcnt && s->out[s->outcnt - dist])
          s->out[s->outcnt] = s->out[s->outcnt - dist];
        s->outcnt++;
      }
    }
  } while (symbol != 256);
  return 0;
}
static int puff_fixed(struct puff_state* s)
{
  static int virgin = 1;
  static short lencnt[MAXBITS + 1], lensym[FIXLCODES];
  static short distcnt[MAXBITS + 1], distsym[MAXDCODES];
  static struct puff_huffman lencode, distcode;
  if (virgin) {
    lencode.count = lencnt;
    lencode.symbol = lensym;
    distcode.count = distcnt;
    distcode.symbol = distsym;
    short lengths[FIXLCODES];
    int symbol;
    for (symbol = 0; symbol < 144; symbol++)
      lengths[symbol] = 8;
    for (; symbol < 256; symbol++)
      lengths[symbol] = 9;
    for (; symbol < 280; symbol++)
      lengths[symbol] = 7;
    for (; symbol < FIXLCODES; symbol++)
      lengths[symbol] = 8;
    puff_construct(&lencode, lengths, FIXLCODES);
    for (symbol = 0; symbol < MAXDCODES; symbol++)
      lengths[symbol] = 5;
    puff_construct(&distcode, lengths, MAXDCODES);
    virgin = 0;
  }
  return puff_codes(s, &lencode, &distcode);
}
static int puff_dynamic(struct puff_state* s)
{
  static const short order[19] = {16, 17, 18, 0, 8,  7, 9,  6, 10, 5,
                                  11, 4,  12, 3, 13, 2, 14, 1, 15};
  int nlen = puff_bits(s, 5) + 257;
  int ndist = puff_bits(s, 5) + 1;
  int ncode = puff_bits(s, 4) + 4;
  if (nlen > MAXLCODES || ndist > MAXDCODES)
    return -3;
  short lengths[MAXCODES];
  int index;
  for (index = 0; index < ncode; index++)
    lengths[order[index]] = puff_bits(s, 3);
  for (; index < 19; index++)
    lengths[order[index]] = 0;
  short lencnt[MAXBITS + 1], lensym[MAXLCODES];
  struct puff_huffman lencode = {lencnt, lensym};
  int err = puff_construct(&lencode, lengths, 19);
  if (err != 0)
    return -4;
  index = 0;
  while (index < nlen + ndist) {
    int symbol;
    int len;
    symbol = puff_decode(s, &lencode);
    if (symbol < 0)
      return symbol;
    if (symbol < 16)
      lengths[index++] = symbol;
    else {
      len = 0;
      if (symbol == 16) {
        if (index == 0)
          return -5;
        len = lengths[index - 1];
        symbol = 3 + puff_bits(s, 2);
      } else if (symbol == 17)
        symbol = 3 + puff_bits(s, 3);
      else
        symbol = 11 + puff_bits(s, 7);
      if (index + symbol > nlen + ndist)
        return -6;
      while (symbol--)
        lengths[index++] = len;
    }
  }
  if (lengths[256] == 0)
    return -9;
  err = puff_construct(&lencode, lengths, nlen);
  if (err && (err < 0 || nlen != lencode.count[0] + lencode.count[1]))
    return -7;
  short distcnt[MAXBITS + 1], distsym[MAXDCODES];
  struct puff_huffman distcode = {distcnt, distsym};
  err = puff_construct(&distcode, lengths + nlen, ndist);
  if (err && (err < 0 || ndist != distcode.count[0] + distcode.count[1]))
    return -8;
  return puff_codes(s, &lencode, &distcode);
}
static int puff(unsigned char* dest, unsigned long* destlen,
                const unsigned char* source, unsigned long sourcelen)
{
  struct puff_state s = {
      .out = dest,
      .outlen = *destlen,
      .outcnt = 0,
      .in = source,
      .inlen = sourcelen,
      .incnt = 0,
      .bitbuf = 0,
      .bitcnt = 0,
  };
  int err;
  if (setjmp(s.env) != 0)
    err = 2;
  else {
    int last;
    do {
      last = puff_bits(&s, 1);
      int type = puff_bits(&s, 2);
      err = type == 0 ? puff_stored(&s)
                      : (type == 1 ? puff_fixed(&s)
                                   : (type == 2 ? puff_dynamic(&s) : -1));
      if (err != 0)
        break;
    } while (!last);
  }
  *destlen = s.outcnt;
  return err;
}

//% END CODE DERIVED FROM puff.{c,h}

#define ZLIB_HEADER_WIDTH 2

static int puff_zlib_to_file(const unsigned char* source,
                             unsigned long sourcelen, int dest_fd)
{
  if (sourcelen < ZLIB_HEADER_WIDTH)
    return 0;
  source += ZLIB_HEADER_WIDTH;
  sourcelen -= ZLIB_HEADER_WIDTH;
  const unsigned long max_destlen = 132 << 20;
  void* ret = mmap(0, max_destlen, PROT_WRITE | PROT_READ,
                   MAP_PRIVATE | MAP_ANON, -1, 0);
  if (ret == MAP_FAILED)
    return -1;
  unsigned char* dest = (unsigned char*)ret;
  unsigned long destlen = max_destlen;
  int err = puff(dest, &destlen, source, sourcelen);
  if (err) {
    munmap(dest, max_destlen);
    errno = -err;
    return -1;
  }
  if (write(dest_fd, dest, destlen) != (ssize_t)destlen) {
    munmap(dest, max_destlen);
    return -1;
  }
  return munmap(dest, max_destlen);
}

static int setup_loop_device(unsigned char* data, unsigned long size,
                             const char* loopname, int* loopfd_p)
{
  int err = 0, loopfd = -1;
  int memfd = syscall(__NR_memfd_create, "syzkaller", 0);
  if (memfd == -1) {
    err = errno;
    goto error;
  }
  if (puff_zlib_to_file(data, size, memfd)) {
    err = errno;
    goto error_close_memfd;
  }
  loopfd = open(loopname, O_RDWR);
  if (loopfd == -1) {
    err = errno;
    goto error_close_memfd;
  }
  if (ioctl(loopfd, LOOP_SET_FD, memfd)) {
    if (errno != EBUSY) {
      err = errno;
      goto error_close_loop;
    }
    ioctl(loopfd, LOOP_CLR_FD, 0);
    usleep(1000);
    if (ioctl(loopfd, LOOP_SET_FD, memfd)) {
      err = errno;
      goto error_close_loop;
    }
  }
  close(memfd);
  *loopfd_p = loopfd;
  return 0;

error_close_loop:
  close(loopfd);
error_close_memfd:
  close(memfd);
error:
  errno = err;
  return -1;
}

static void reset_loop_device(const char* loopname)
{
  int loopfd = open(loopname, O_RDWR);
  if (loopfd == -1) {
    return;
  }
  if (ioctl(loopfd, LOOP_CLR_FD, 0)) {
  }
  close(loopfd);
}

static long syz_mount_image(volatile long fsarg, volatile long dir,
                            volatile long flags, volatile long optsarg,
                            volatile long change_dir,
                            volatile unsigned long size, volatile long image)
{
  unsigned char* data = (unsigned char*)image;
  int res = -1, err = 0, need_loop_device = !!size;
  char* mount_opts = (char*)optsarg;
  char* target = (char*)dir;
  char* fs = (char*)fsarg;
  char* source = NULL;
  char loopname[64];
  if (need_loop_device) {
    int loopfd;
    memset(loopname, 0, sizeof(loopname));
    snprintf(loopname, sizeof(loopname), "/dev/loop%llu", procid);
    if (setup_loop_device(data, size, loopname, &loopfd) == -1)
      return -1;
    close(loopfd);
    source = loopname;
  }
  mkdir(target, 0777);
  char opts[256];
  memset(opts, 0, sizeof(opts));
  if (strlen(mount_opts) > (sizeof(opts) - 32)) {
  }
  strncpy(opts, mount_opts, sizeof(opts) - 32);
  if (strcmp(fs, "iso9660") == 0) {
    flags |= MS_RDONLY;
  } else if (strncmp(fs, "ext", 3) == 0) {
    bool has_remount_ro = false;
    char* remount_ro_start = strstr(opts, "errors=remount-ro");
    if (remount_ro_start != NULL) {
      char after = *(remount_ro_start + strlen("errors=remount-ro"));
      char before = remount_ro_start == opts ? '\0' : *(remount_ro_start - 1);
      has_remount_ro = ((before == '\0' || before == ',') &&
                        (after == '\0' || after == ','));
    }
    if (strstr(opts, "errors=panic") || !has_remount_ro)
      strcat(opts, ",errors=continue");
  } else if (strcmp(fs, "xfs") == 0) {
    strcat(opts, ",nouuid");
  }
  res = mount(source, target, fs, flags, opts);
  if (res == -1) {
    err = errno;
    goto error_clear_loop;
  }
  res = open(target, O_RDONLY | O_DIRECTORY);
  if (res == -1) {
    err = errno;
    goto error_clear_loop;
  }
  if (change_dir) {
    res = chdir(target);
    if (res == -1) {
      err = errno;
    }
  }

error_clear_loop:
  if (need_loop_device)
    reset_loop_device(loopname);
  errno = err;
  return res;
}

static void kill_and_wait(int pid, int* status)
{
  kill(-pid, SIGKILL);
  kill(pid, SIGKILL);
  for (int i = 0; i < 100; i++) {
    if (waitpid(-1, status, WNOHANG | __WALL) == pid)
      return;
    usleep(1000);
  }
  DIR* dir = opendir("/sys/fs/fuse/connections");
  if (dir) {
    for (;;) {
      struct dirent* ent = readdir(dir);
      if (!ent)
        break;
      if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0)
        continue;
      char abort[300];
      snprintf(abort, sizeof(abort), "/sys/fs/fuse/connections/%s/abort",
               ent->d_name);
      int fd = open(abort, O_WRONLY);
      if (fd == -1) {
        continue;
      }
      if (write(fd, abort, 1) < 0) {
      }
      close(fd);
    }
    closedir(dir);
  } else {
  }
  while (waitpid(-1, status, __WALL) != pid) {
  }
}

static void reset_loop()
{
  char buf[64];
  snprintf(buf, sizeof(buf), "/dev/loop%llu", procid);
  int loopfd = open(buf, O_RDWR);
  if (loopfd != -1) {
    ioctl(loopfd, LOOP_CLR_FD, 0);
    close(loopfd);
  }
}

static void setup_test()
{
  prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0);
  setpgrp();
  write_file("/proc/self/oom_score_adj", "1000");
}

static void execute_one(void);

#define WAIT_FLAGS __WALL

static void loop(void)
{
  int iter = 0;
  for (;; iter++) {
    reset_loop();
    int pid = fork();
    if (pid < 0)
      exit(1);
    if (pid == 0) {
      setup_test();
      execute_one();
      exit(0);
    }
    int status = 0;
    uint64_t start = current_time_ms();
    for (;;) {
      if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid)
        break;
      sleep_ms(1);
      if (current_time_ms() - start < 5000)
        continue;
      kill_and_wait(pid, &status);
      break;
    }
  }
}

uint64_t r[1] = {0xffffffffffffffff};

void execute_one(void)
{
  intptr_t res = 0;
  syz_init_net_socket(/*domain=*/0x10, /*type=*/3, /*proto=*/0x10);
  memcpy((void*)0x20000140, "ext4\000", 5);
  memcpy((void*)0x200005c0, "./bus\000", 6);
  memcpy((void*)0x200002c0, "test_dummy_encryption", 21);
  *(uint8_t*)0x200002d5 = 0x2c;
  memcpy((void*)0x200002d6, "debug_want_extra_isize", 22);
  *(uint8_t*)0x200002ec = 0x3d;
  sprintf((char*)0x200002ed, "0x%016llx", (long long)0x84);
  *(uint8_t*)0x200002ff = 0x2c;
  memcpy((void*)0x20000300, "stripe", 6);
  *(uint8_t*)0x20000306 = 0x3d;
  sprintf((char*)0x20000307, "0x%016llx", (long long)7);
  *(uint8_t*)0x20000319 = 0x2c;
  memcpy((void*)0x2000031a, "commit", 6);
  *(uint8_t*)0x20000320 = 0x3d;
  sprintf((char*)0x20000321, "0x%016llx", (long long)5);
  *(uint8_t*)0x20000333 = 0x2c;
  memcpy((void*)0x20000334, "nombcache", 9);
  *(uint8_t*)0x2000033d = 0x2c;
  memcpy((void*)0x2000033e, "bsddf", 5);
  *(uint8_t*)0x20000343 = 0x2c;
  memcpy((void*)0x20000344, "max_batch_time", 14);
  *(uint8_t*)0x20000352 = 0x3d;
  sprintf((char*)0x20000353, "0x%016llx", (long long)0);
  *(uint8_t*)0x20000365 = 0x2c;
  memcpy((void*)0x20000366, "data_err=abort", 14);
  *(uint8_t*)0x20000374 = 0x2c;
  *(uint8_t*)0x20000375 = 0;
  memcpy(
      (void*)0x20000c00,
      "\x78\x9c\xec\xdd\xcf\x6f\x14\x55\x1c\x00\xf0\xef\x6c\x7f\xd0\x52\xb4\x85"
      "\x18\x15\x0f\xd2\xc4\x18\x48\x94\x96\x16\x30\xc4\x78\x80\xab\x21\x0d\xfe"
      "\x88\x17\x2f\x56\x5a\x10\x29\xd0\xd0\x1a\x2d\x9a\x50\x12\xbc\x98\x18\x2f"
      "\xc6\x98\x78\xf2\x20\xfe\x17\x4a\xe4\xca\x49\x4f\x1e\xbc\x78\x32\x24\x44"
      "\x0d\x47\x13\xd7\xcc\x76\xa6\x74\xdb\xd9\x96\x2e\x6d\xa7\x32\x9f\x4f\xb2"
      "\xf4\xcd\x7b\x3b\xbc\x37\xdd\x7e\xfb\xde\xbe\xbe\x37\x1b\x40\x65\x0d\xa6"
      "\xff\xd4\x22\xf6\x46\xc4\x74\x12\xd1\x9f\xcc\x2f\x96\x75\x46\x56\x38\xb8"
      "\xf0\xbc\x7b\x7f\x7f\x72\x3a\x7d\x24\x51\xaf\xbf\xf1\x67\x12\x49\x96\x97"
      "\x3f\x3f\xc9\xbe\xf6\x65\x27\xf7\x44\xc4\xcf\x3f\x25\xb1\xa7\x63\x65\xbd"
      "\x33\x73\x57\xce\x8f\x4f\x4d\x4d\x5e\xce\x8e\x87\x67\x2f\x4c\x0f\xcf\xcc"
      "\x5d\x39\x78\xee\xc2\xf8\xd9\xc9\xb3\x93\x17\x47\x5f\x1a\x3d\x76\xf4\xc8"
      "\xd1\x63\x23\x87\xda\xba\xae\xab\x05\x79\x27\xaf\xbf\xff\x61\xff\x67\x63"
      "\x6f\x7f\xf7\xcd\x3f\xc9\xc8\xf7\xbf\x8d\x25\x71\x3c\x5e\xcd\x9e\xb8\xf4"
      "\x3a\x36\xca\x60\x0c\x36\xbe\x27\xc9\xca\xa2\xbe\x63\x1b\x5d\x59\x49\x3a"
      "\xb2\x9f\x93\xa5\x2f\x71\xd2\x59\x62\x83\x58\x97\xfc\xf5\xeb\x8a\x88\xa7"
      "\xa2\x3f\x3a\xe2\xfe\x8b\xd7\x1f\x9f\xbe\x56\x6a\xe3\x80\x4d\x55\x4f\x22"
      "\xea\x40\x45\x25\xe2\x1f\x2a\x2a\x1f\x07\xe4\xef\xed\x97\xbf\x0f\xae\x95"
      "\x32\x2a\x01\xb6\xc2\xdd\x13\x0b\x13\x00\x2b\xe3\xbf\x73\x61\x6e\x30\x7a"
      "\x1a\x73\x03\x3b\xef\x25\xb1\x74\x5a\x27\x89\x88\xf6\x66\xe6\x9a\xed\x8a"
      "\x88\xdb\xb7\xc6\xae\x9f\xb9\x35\x76\x3d\x36\x69\x1e\x0e\x28\x36\x7f\x2d"
      "\x22\x9e\x2e\x8a\xff\xa4\x11\xff\x03\xd1\x13\x03\x8d\xf8\xaf\x35\xc5\x7f"
      "\x3a\x2e\x38\x95\x7d\x4d\xf3\x5f\x6f\xb3\xfe\xe5\x53\xc5\xe2\x1f\xb6\xce"
      "\x42\xfc\xf7\xac\x1a\xff\xd1\x22\xfe\xdf\x59\x12\xff\xef\xb6\x59\xff\xe0"
      "\xfd\xe4\x7b\xbd\x4d\xf1\xdf\xdb\xee\x25\x01\x00\x00\x00\x00\x00\x40\x65"
      "\xdd\x3c\x11\x11\x2f\x16\xfd\xfd\xbf\xb6\xb8\xfe\x27\x0a\xd6\xff\xf4\x45"
      "\xc4\xf1\x0d\xa8\x7f\x70\xd9\xf1\xca\xbf\xff\xd7\xee\x6c\x40\x35\x40\x81"
      "\xbb\x27\x22\x5e\x29\x5c\xff\x5b\xcb\x57\xff\x0e\x74\x64\xa9\xc7\x1a\xeb"
      "\x01\xba\x92\x33\xe7\xa6\x26\x0f\x45\xc4\xe3\x11\x71\x20\xba\x76\xa4\xc7"
      "\x23\xab\xd4\x71\xf0\xf3\x3d\x5f\xb7\x2a\x1b\xcc\xd6\xff\xe5\x8f\xb4\xfe"
      "\xdb\xd9\x5a\xc0\xac\x1d\x77\x3a\x77\x34\x9f\x33\x31\x3e\x3b\xfe\xb0\xd7"
      "\x0d\x44\xdc\xbd\x16\xf1\x4c\xe1\xfa\xdf\x64\xb1\xff\x4f\x0a\xfa\xff\xf4"
      "\xf7\xc1\xf4\x03\xd6\xb1\xe7\xf9\x1b\xa7\x5a\x95\xad\x1d\xff\xc0\x66\xa9"
      "\x7f\x1b\xb1\xbf\xb0\xff\xbf\x7f\xd7\x8a\x64\xf5\xfb\x73\x0c\x37\xc6\x03"
      "\xc3\xf9\xa8\x60\xa5\x67\x3f\xfe\xe2\x87\x56\xf5\xb7\x1b\xff\x6e\x31\x01"
      "\x0f\x2f\xed\xff\x77\xae\x1e\xff\x03\xc9\xd2\xfb\xf5\xcc\xac\xbf\x8e\xc3"
      "\x73\x9d\xf5\x56\x65\xed\x8e\xff\xbb\x93\x37\x1b\xb7\x9c\xe9\xce\xf2\x3e"
      "\x1a\x9f\x9d\xbd\x3c\x12\xd1\x9d\x9c\xec\x48\x73\x9b\xf2\x47\xd7\xdf\x66"
      "\x78\x14\xe5\xf1\x90\xc7\x4b\x1a\xff\x07\x9e\x5b\x7d\xfe\xaf\x68\xfc\xdf"
      "\x1b\x11\xf3\xcb\xfe\xef\xe4\xaf\xe6\x3d\xc5\xb9\x27\xff\xed\xfb\xbd\x55"
      "\x7b\x8c\xff\xa1\x3c\x69\xfc\x4f\xac\xab\xff\x5f\x7f\x62\xf4\xc6\xc0\x8f"
      "\xad\xea\x7f\xb0\xfe\xff\x48\xa3\xaf\x3f\x90\xe5\x98\xff\x83\x05\x5f\xe5"
      "\x61\xda\xdd\x9c\x5f\x10\x8e\x9d\x45\x45\x5b\xdd\x5e\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x78\x14\xd4\x22\x62\x57\x24\xb5\xa1\xc5\x74\xad\x36\x34\x14\xd1"
      "\x17\x11\x4f\xc4\xce\xda\xd4\xa5\x99\xd9\x17\xce\x5c\xfa\xe0\xe2\x44\x5a"
      "\xd6\xf8\xfc\xff\x5a\xfe\x49\xbf\xfd\x0b\xc7\x49\xfe\xf9\xff\x03\x4b\x8e"
      "\x47\x97\x1d\x1f\x8e\x88\xdd\x11\xf1\x65\x47\x6f\xe3\x78\xe8\xf4\xa5\xa9"
      "\x89\xb2\x2f\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\xb6\x89\xbe\x16\xfb\xff\x53\x7f\x74\x94\xdd\x3a\x60\xd3\x75\x96\xdd"
      "\x00\xa0\x34\x05\xf1\xff\x4b\x19\xed\x00\xb6\x9e\xfe\x1f\xaa\x4b\xfc\x43"
      "\x75\x89\x7f\xa8\x2e\xf1\x0f\xd5\x25\xfe\xa1\xba\xc4\x3f\x54\x97\xf8\x87"
      "\xea\x12\xff\x00\x00\x00\x00\x00\xf0\x48\xd9\xbd\xef\xe6\xaf\x49\x44\xcc"
      "\xbf\xdc\xdb\x78\xa4\xba\xb3\xb2\xae\x52\x5b\x06\x6c\xb6\x5a\xd9\x0d\x00"
      "\x4a\xe3\x16\x3f\x50\x5d\x96\xfe\x40\x75\x79\x8f\x0f\x24\x6b\x94\xf7\xb4"
      "\x3c\x69\xad\x33\x57\x33\x7d\xfa\x21\x4e\x06\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x80\xca\xd9\xbf\xd7\xfe\x7f\xa8\x2a\xfb\xff\xa1\xba\xec\xff\x87"
      "\xea\xca\xf7\xff\xef\x2b\xb9\x1d\xc0\xd6\xf3\x1e\x1f\x88\x35\x76\xf2\x17"
      "\xee\xff\x5f\xf3\x2c\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x60\x23\xcd"
      "\xcc\x5d\x39\x3f\x3e\x35\x35\x79\x59\xe2\xad\xed\xd1\x8c\xad\x4c\xd4\xeb"
      "\xf5\xab\xe9\x4f\xc1\x76\x69\xcf\xff\x3c\x91\x2f\x85\xdf\x2e\xed\x59\x96"
      "\xc8\xf7\xfa\x3d\xd8\x59\xe5\xfd\x4e\x02\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x9a\xfd\x17\x00\x00\xff\xff\x16\x12"
      "\x24\xc5",
      1496);
  syz_mount_image(/*fs=*/0x20000140, /*dir=*/0x200005c0,
                  /*flags=MS_REC*/ 0x4000, /*opts=*/0x200002c0, /*chdir=*/0xd,
                  /*size=*/0x5d8, /*img=*/0x20000c00);
  syscall(__NR_mlock, /*addr=*/0x207d8000ul, /*size=*/0x800000ul);
  memcpy((void*)0x20000180, "./bus\000", 6);
  res =
      syscall(__NR_open, /*file=*/0x20000180ul,
              /*flags=O_TRUNC|O_SYNC|O_NOATIME|O_LARGEFILE|O_CREAT|O_RDWR|0x3c*/
              0x14927eul, /*mode=*/0ul);
  if (res != -1)
    r[0] = res;
  syscall(__NR_fallocate, /*fd=*/r[0], /*mode=*/0ul, /*off=*/0ul,
          /*len=*/0x1000f4ul);
  syscall(__NR_write, /*fd=*/r[0], /*data=*/0x200004c0ul, /*size=*/0x5dul);
}
int main(void)
{
  syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000ul, /*prot=*/0ul,
          /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1,
          /*offset=*/0ul);
  syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000ul,
          /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/ 7ul,
          /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1,
          /*offset=*/0ul);
  syscall(__NR_mmap, /*addr=*/0x21000000ul, /*len=*/0x1000ul, /*prot=*/0ul,
          /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/-1,
          /*offset=*/0ul);
  loop();
  return 0;
}