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

#define _GNU_SOURCE

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

#include <linux/loop.h>

#ifndef __NR_memfd_create
#define __NR_memfd_create 319
#endif

static unsigned long long procid;

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

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

  memcpy((void*)0x20000540, "hfsplus\000", 8);
  memcpy((void*)0x200000c0,
         "\023\023w\305\3745\324\024T\325\324\035)\255\032`)"
         "Y\201F\346\276\026nA\255\r\275@T\003<\2373\273\332\202$"
         "\242\363\327r\347cnH\263<\277p\203r\350\361\271\223>"
         "\305\022wC\276\"\006 \236\360-\371\313\362\366\350\200\3238/\000",
         78);
  memcpy((void*)0x20000140, "force", 5);
  *(uint8_t*)0x20000145 = 0x2c;
  memcpy((void*)0x20000146, "nls", 3);
  *(uint8_t*)0x20000149 = 0x3d;
  memcpy((void*)0x2000014a, "maccyrillic", 11);
  *(uint8_t*)0x20000155 = 0x2c;
  memcpy((void*)0x20000156, "nodecompose", 11);
  *(uint8_t*)0x20000161 = 0x2c;
  memcpy((void*)0x20000162, "part", 4);
  *(uint8_t*)0x20000166 = 0x3d;
  sprintf((char*)0x20000167, "0x%016llx", (long long)3);
  *(uint8_t*)0x20000179 = 0x2c;
  memcpy((void*)0x2000017a, "barrier", 7);
  *(uint8_t*)0x20000181 = 0x2c;
  memcpy((void*)0x20000182, "part", 4);
  *(uint8_t*)0x20000186 = 0x3d;
  sprintf((char*)0x20000187, "0x%016llx", (long long)0xff);
  *(uint8_t*)0x20000199 = 0x2c;
  memcpy((void*)0x2000019a, "uid", 3);
  *(uint8_t*)0x2000019d = 0x3d;
  sprintf((char*)0x2000019e, "0x%016llx", (long long)0xee01);
  *(uint8_t*)0x200001b0 = 0x2c;
  *(uint8_t*)0x200001b1 = 0;
  memcpy(
      (void*)0x20001400,
      "\x78\x9c\xec\xdd\x4b\x68\x1c\xe7\x1d\x00\xf0\xff\xcc\xae\x56\x5a\x17\x1c"
      "\x39\xf1\xab\x25\x10\x11\x43\x5a\x2a\x6a\x4b\x16\x4a\xab\x5e\xea\x96\x52"
      "\x74\x08\x25\xa4\x87\x5e\xbb\xd8\x72\x2c\xbc\x96\x83\xa4\x14\x25\x94\x5a"
      "\xee\xe3\x5a\x7a\xc8\xa9\xa7\xf4\xa0\x5b\x4e\x25\xbd\x1b\xd2\x73\x43\xa1"
      "\xe4\xaa\x63\xa0\x90\x4b\x4e\xba\xa9\xcc\xec\xec\x4b\x1a\xed\xae\xa2\xe8"
      "\x15\xff\x7e\x66\x76\xbe\x99\xef\x31\xdf\xfc\xe7\xa5\xdd\xc1\x7c\x01\x3c"
      "\xb7\x16\xa7\xa3\xfa\x2c\x92\x58\x9c\x7e\x63\x23\x5b\xde\xde\x9a\x6b\x6e"
      "\x6f\xcd\x8d\x17\xd9\xcd\x88\xa8\x45\x44\x1a\x51\x6d\xcd\x22\x59\x89\x48"
      "\x3e\x89\xb8\xf3\x97\x6a\xab\xcc\xb7\xb3\x95\x45\xf9\xe4\xa0\xed\x7c\xb0"
      "\xbc\xf0\xd6\x67\x5f\x6e\x7f\xde\x5a\xaa\x16\x53\x5e\x3e\x1d\x54\xaf\x44"
      "\x6d\xff\xaa\xcd\x62\x8a\xa9\x88\xa8\x14\xf3\xfd\xc6\x0e\x68\xf1\xe3\xbd"
      "\x9b\xef\x6b\xef\xee\x81\xed\x8d\x2a\xe9\xec\xe1\x9d\x88\xb8\x51\xcc\x23"
      "\xfe\x76\xa4\x56\xe1\xc8\x76\xf7\xd9\xec\xe4\x7d\xf4\xdf\xa1\xd5\x0f\x73"
      "\xdd\x02\x67\x54\xd2\x7a\x6e\xee\x33\x19\x71\x21\x22\x26\x22\x22\xff\x9b"
      "\xa0\xb8\x3b\xa4\x27\xdb\xbb\xaf\xdf\xe6\x69\x77\x00\x00\x00\x00\x0e\xab"
      "\x7e\xf8\x1f\xe2\x5e\xd8\x89\x9d\xd8\x88\x8b\xc7\xd4\x23\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\xf8\x46\x2a\xc6\xff\x4f\x8a\x29\x6d\xa7\xa7\x22\x69"
      "\x8f\xff\x5f\x8b\xee\x30\x83\x59\x3a\x9e\x9c\x6e\x97\xf7\xa9\x8c\x50\xe6"
      "\x3f\xe3\xd9\xe7\xd3\x78\x76\xfc\xdd\x01\x00\x00\x00\x00\x00\x00\x80\x43"
      "\x19\xe5\xbd\xf7\x5e\xaf\xec\xc4\x4e\x6c\xc4\xc5\xf6\xf2\x6e\x92\xbf\xf3"
      "\x7f\xb5\xe7\x1d\xff\xb7\xe2\xdd\x58\x8b\xa5\x58\x8d\x9b\xb1\x11\x8d\x58"
      "\x8f\xf5\x58\x8d\xd9\x88\x98\xec\x69\xa8\xb6\xd1\x58\x5f\x5f\x9d\xcd\x6b"
      "\x46\x5c\x1e\x50\xf3\x76\x7c\x5a\x52\xf3\xf6\xc1\x7d\xbc\xf3\x15\xf6\x0b"
      "\x00\x00\x00\x00\x00\x00\x00\xce\xb1\x89\x21\xf9\x0f\xc7\xf6\xaf\xfb\x43"
      "\x2c\x76\xdf\xff\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\xc0\x59\x90"
      "\x44\x54\x5a\xb3\x7c\xba\xdc\x4e\x4f\x46\x5a\x8d\x88\x89\x88\xa8\x65\xe5"
      "\x36\x23\x3e\x6d\xa7\xcf\x89\xa4\x6c\xe5\xb3\x93\xef\x07\x00\x00\x00\x1c"
      "\xc9\xc4\xc0\xe5\xb4\xb4\xce\x0b\x4f\x62\x27\x36\xe2\x62\x7b\x79\x37\xc9"
      "\xbf\xf3\x5f\xcd\xbf\x2f\x4f\xc4\xbb\xb1\x12\xeb\xb1\x1c\xeb\xd1\x8c\xa5"
      "\xb8\x57\x7c\x87\xce\xbe\xf5\xa7\xdb\x5b\x73\xcd\xed\xad\xb9\x47\xd9\xf4"
      "\x9b\x56\xdd\x9e\x76\x7f\xfa\xc5\xa1\xba\x5e\x2b\x3a\x58\xc9\x97\xca\xb6"
      "\x7c\x3d\x2f\x51\x8f\xfb\xb1\x9c\xaf\xb9\x19\x77\xe3\x71\x34\xe3\x5e\xa4"
      "\x9d\x5d\xbb\xbe\xbd\x35\x97\xcd\x1f\xb5\xfb\xd5\xbf\x91\xa7\x59\x9f\x92"
      "\x9f\x14\x06\xf4\xa6\xd2\x93\xbe\x97\x7d\x5c\xfb\x38\x4f\xff\xb5\xf8\x15"
      "\xa1\x72\xa8\x7d\x3b\x9a\xf2\xc3\x96\x99\xcc\x73\xc7\x3a\x11\x99\x29\x8e"
      "\x4e\x56\xe3\x52\x3b\x02\xe5\x91\x18\x7a\x74\xaa\x03\xb7\x34\x1b\x69\xe7"
      "\x97\x9f\xcb\xa5\x5b\xda\x2d\x1c\x10\xf3\xa7\xdd\xb6\xf7\x9e\xb4\x99\x0b"
      "\x7b\x4a\x95\xfe\x72\x73\x72\x76\xbb\xc7\x7b\x6f\x24\x6e\xf7\x9c\x7d\x57"
      "\x07\xc7\x3c\xe2\xbb\xff\xfc\xe8\xd7\x0f\x9a\x2b\x0f\x1f\xdc\x5f\x9b\x3e"
      "\xe5\x5d\x1a\xe6\xc9\xd0\x12\x7b\x23\x31\xd7\x13\x89\x6b\xa3\x46\x22\x89"
      "\x33\x19\x89\xdd\x43\x95\x9e\xc9\x23\x71\xa5\xb3\xbc\x18\xbf\x88\x5f\xc5"
      "\x74\x7c\x31\xfe\x66\xac\xc6\x72\xfc\x36\x1a\xb1\x1e\x4b\x9d\x56\x1b\xc5"
      "\xf9\x9c\x7d\x4e\x0e\x8a\xd4\xde\xdb\xcc\x9b\xc3\x7a\x52\x2b\x8e\x4b\xab"
      "\x62\x59\x9f\xa6\xa2\xbf\x4f\x53\xf1\xf3\x3c\xd5\x88\x57\xf3\xba\x17\x63"
      "\x39\x92\x78\x1c\x11\x4b\xf1\x7a\xfe\xef\x76\xcc\x76\xee\x06\xdd\x23\x7c"
      "\x65\xf0\x11\xce\xaf\xfa\x74\x84\x3b\x6d\x8f\x1b\xdf\xcb\x67\x53\x9d\x15"
      "\xf5\xd1\xea\x1d\x9b\x6e\xbf\xb3\xb8\x5e\xea\x89\x6b\xe7\xac\xef\x1c\xa1"
      "\xde\xbb\x70\x37\x4a\x2f\x96\x46\xa9\xfd\xac\x1b\xfd\x79\xd4\xa3\xfa\x9d"
      "\x22\x91\xb5\xf0\xc7\x81\xcf\x87\x93\x36\x99\x47\xa9\xff\x29\xd1\xee\xdd"
      "\x4b\x83\xcf\x97\xbf\xe7\xd7\xc6\x5a\x73\xe5\xe1\xea\x83\xc6\x3b\x23\x6e"
      "\xef\xb5\x62\x9e\x5d\x47\x7f\x2e\x79\x4a\x9c\xde\xbb\x89\x6c\xcb\x2f\xc6"
      "\x44\x71\xbe\x5c\xea\x3b\x3b\xb2\xbc\x97\x3a\x4f\xd8\xfe\x78\xd5\x8a\x37"
      "\x2e\x2d\xe9\xbe\xbc\x2b\x9d\x7a\xad\x2b\xf5\x97\xf1\x38\xee\xf5\x5d\xa9"
      "\x3f\x8c\xf9\x98\x8f\x85\xbc\xf4\xd5\xbc\xf4\xd8\xbe\x27\x56\x96\x77\xad"
      "\xd3\x52\xff\x3d\x3c\xcb\xbb\xde\x93\x57\xf6\xf7\x16\x00\x67\xde\x85\xef"
      "\x5f\xa8\xd5\xff\x57\xff\x77\xfd\xc3\xfa\x9f\xea\x0f\xea\x6f\x4c\xfc\x6c"
      "\xfc\x47\xe3\x2f\xd7\x62\xec\x5f\x63\x3f\xae\xce\x54\x5e\x4b\x5f\x4e\xfe"
      "\x11\x1f\xc6\xef\xbb\xdf\xff\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\xaf\x6e\xed\xbd\xf7"
      "\x1f\x36\x9a\xcd\xa5\xd5\xf2\x44\x5a\x9e\x95\x0c\xae\xd5\x68\xee\x16\x03"
      "\x89\x0d\x2a\xd3\x97\x48\x8a\x81\x7c\x46\x28\x9c\x8c\xd4\xe0\xb9\x49\xb4"
      "\x07\xc2\x1b\x5e\x78\xea\x18\xbb\x91\x6c\x16\x07\xec\x30\xb5\xda\xa3\x3c"
      "\x0d\x28\x93\x1e\x78\x4c\xb3\x9c\x13\x0d\xf8\xd0\x93\xf6\x2c\x27\xc6\x8b"
      "\x50\x1f\xa5\x9d\xce\xc8\x6a\x7d\x59\x95\x88\x28\xab\x35\xe4\xc6\x71\x92"
      "\x63\x61\x02\xc7\xe2\xd6\xfa\xa3\x77\x6e\xad\xbd\xf7\xfe\x0f\x96\x1f\x35"
      "\xde\x5e\x7a\x7b\x69\x65\x6c\x7e\x7e\x61\x66\x61\xfe\xf5\xb9\x5b\xf7\x97"
      "\x9b\x4b\x33\xad\xcf\x9e\x0a\x3d\x23\xc4\x96\x0d\xe1\x0a\x9c\x1f\xdd\x87"
      "\x7e\xef\xda\x34\xe2\x95\xe1\x75\x4f\x7b\xa0\x56\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x78\x5e\x9d\xc4\xff\x61\x38\xed\x7d\x04\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xce\xb7"
      "\xc5\xe9\xa8\x3e\x8b\x24\x66\x67\x6e\xce\x64\xcb\xdb\x5b\x73\xcd\x6c\x6a"
      "\xa7\xbb\x25\xab\x11\x91\x46\x44\xf2\xbb\x88\xe4\x93\x88\x3b\xd1\x9a\x62"
      "\xb2\xc8\xcc\x24\x07\x6d\xe7\x83\xe5\x85\xb7\x3e\xfb\x72\xfb\xf3\x6e\x5b"
      "\xd5\x76\xf9\x34\x62\xf3\xc0\x7a\xa3\xd9\x2c\xa6\x98\x8a\x88\x4a\x31\xff"
      "\xba\xda\xbb\x3b\xbc\xbd\x5a\x37\x39\x5e\x92\x9d\x74\x22\x93\x05\xec\x46"
      "\x3b\x70\x70\xda\xfe\x1f\x00\x00\xff\xff\x6d\xc5\xff\x4e",
      1760);
  syz_mount_image(
      /*fs=*/0x20000540, /*dir=*/0x200000c0,
      /*flags=MS_STRICTATIME|MS_SILENT|MS_RELATIME|MS_RDONLY|0x848*/ 0x1208849,
      /*opts=*/0x20000140, /*chdir=*/1, /*size=*/0x6e0, /*img=*/0x20001400);
  memcpy((void*)0x20000180, "msdos\000", 6);
  memcpy((void*)0x20000100, ".\000", 2);
  memcpy(
      (void*)0x20000580,
      "\x14\x27\x0e\x2d\x25\xcc\xcf\xf0\x78\xb9\x14\x0e\x8a\x1e\x19\xf3\xb4\xc3"
      "\xbd\x09\x96\x8d\xd1\x91\x1a\xce\xf2\x43\x21\xd7\x64\xd9\xe1\x17\xda\x79"
      "\x06\x3a\x62\xe3\xa5\x92\xfb\x42\xf7\xd9\xdd\xb2\x68\x2b\x4c\x2f\xf5\x80"
      "\xe2\x5f\xa8\xef\xfb\xd5\x3a\xcf\xb0\xf8\x70\xbc\x1e\x49\xd0\x1a\x5b\x7f"
      "\xf5\x51\x50\xd2\xbf\x3b\x04\x28\x58\xc5\x32\x5c\x2b\x56\x9b\x32\x0c\xd4"
      "\x4e\x49\xe2\x46\xcc\x1e\x41\xf0\x4d\x2e\x49\x4a\xdd\xed\x5a\xa4\x75\x0b"
      "\x7c\xf2\x6f\x85\x6b\xf2\x3c\xb3\x79\x53\x1e\xba\xe1\x77\x4a\xf8\xa4\x95"
      "\x09\x2c\x89\x04\x20\x5d\xb1\x90\x36\x68\x75\xaa\x90\xaf\xf0\xd1\x1b\xf4"
      "\x4f\x06\x4c\x23\x39\x0e\x88\x56\x2d\x04\x1e\x50\x53\x62\xf5\xbf\xb0\x66"
      "\x5c\x3f\xaf\xda\x90\x9f\x59\xad\x28\x6e\xe9\xbd\x87\xd5\xaa\x09\x8d\xc5"
      "\xb8\x1e\xe3\x4c\xbf\x59\xbf\xa7\x65\xc1\xc9\x6e\x7f\xb5\x57\xcb\x14\x43"
      "\xf3\xdc\xee\xa4\x4c\x96\x3e\x0c\x93\x47\x54\x5e\x4f\xf3\x53\xbf\x8b\x90"
      "\x23\xcf\x81\xd7\x86\x73\xa0\xf6\x36\x3e\x5c\xc2\xb0\xd5\x24\xd2\x91\xe2"
      "\x8f\xc2\x8a\x27\x67\xae\x80\x4a\x98\xb3\x4b\x64\x8f\x0b\xa6\xed\xf5\x10"
      "\xda\x09\x03\x4a\x27\x0f\x6b\x3a\x29\x4a\x4f\x49\xd5\xed\x57\x1d\xb0\xe0"
      "\xd8\x30\x7c\x99\xa9\x53\xa8\x17\x5c\x2e\x11\x51\xa0\x65\xa9\xdd\x6f\x26"
      "\x2d\xf3\x82\x34\xa5\xa0\xe4\x88\x86\x28\xfe\x12\x4e\x56\xfa\xe3\xb1\xc2"
      "\xab\xbf\x83\xfc\xb6\x31\xbc\x0d\xc7\x08\xd1\x5d\x92\x52\xb9\xef\xe2\x66"
      "\xf9\xbf\xe1\xa9\x2f\x40\x41\x40\x77\xe9\xb6\x85\x18\x15\x49\x1e\xa6\x4e"
      "\xc4\x81\x7e\x4f\x74\xd5\xca\xa1\x79\x4d\x94\x83\x8e\xe8\xdc\xfe\x64\xc7"
      "\xda\xf9\x86\xe6\x06\xda\xab\x96\x61\xf7\xd6\x78\x98\x19\x8d\xc5\xb2\xdb"
      "\x3c\x9a\xf1\x29\x79\x4d\x1e\x11\x84\xb6\x5a\x7d\x44\x6a\x60\x17\x2f\x81"
      "\xb8\x15\xc8\xf4\x9c\xb6\x78\x0c\xff\xb3\x36\xf9\xaf\x74\xe4\xca\x46\x44"
      "\x34\x6c\xb3\x51\xb8\x7c\x31\xa5\x3d\x00\xd2\x18\xd8\x5a\xe8\xc0\x75\x4a"
      "\x1a\xdc\xd2\x68\xb7\xf8\xda\xd2\x16\x56\xab\x6d\x08\xdb\xbb\xa3\x9f\x45"
      "\xdf\xac\x26\xde\x1e\xbd\xd4\xb3\xb1\xfb\xf2\x3c\x38\xbc\x24\xbd\x5a\x63"
      "\x87\x80\x7e\x0d\x97\x26\x12\x92\xb7\x8f\xe3\x91\x71\x50\x4e\xe7\x1d\x59"
      "\xd4\xd0\x0c\x20\xbe\x45\x13\x29\xc5\x83\x04\x0e\xc3\x8a\x8b\xa2\x8e\x65"
      "\x4c\x8e\xc0\xb1\x8b\x6b\x9c\x69\x9e\xdb\x04\x0d\xe2\x22\x42\xd0\x38\xe3"
      "\x63\xd6\x24\xce\x07\x6a\xbe\x17\xba\xcf\x35\xd8\x49\x75\x03\x5c\x06\x3a"
      "\x89\x58\xc4\x7b\xb9\x00\x88\x74\x51\xe4\x93\x2f\x7a\x39\x1a\x8f\xee\xa3"
      "\x19\x57\x7a\x68\xf2\x65\x31\x9c\xcf\xca\xde\x5e\x7d\xc5\x6a\xde\x83\x12"
      "\xef\xb5\x97\xe8\x85\xd4\xd1\xb4\x1d\x27\xdc\x26\x57\xbb\x34\x49\x41\xd4"
      "\x2e\x68\xce\x72\xe0\x6d\x82\x64\x3a\x61\x57\x1d\x02\x5c\xe9\x07\xb7\x80"
      "\x70\x71\x57\x98\x42\x85\xff\x2b\xa1\x8a\x9f\x70\xd5\x34\xa1\x9b\xb6\x83"
      "\x57\x25\xd6\x53\x8e\x03\xf7\xe7\x77\x01\xbe\x36\x26\x17\x2f\x3d\xe7\x54"
      "\x5c\x9c\xd1\x3f\x12\x87\xa2\x61\x38\x0e\x79\x7c\x0b\x8b\x89\xa1\xdf\x32"
      "\xbc\x6d\x83\x7e\x5a\x05\x6f\xd2\xde\x70\xb2\x50\x2d\x51\x83\x54\xf6\x9f"
      "\x82\xb3\x8d\x72\x95\x9d\x86\x63\x5c\x26\x79\xd1\x31\xe0\x07\xbb\xac\x42"
      "\x5b\x8b\x59\xf4\xd5\xb2\x7e\xdf\x6f\x62\x03\xcf\xaa\x59\xba\x01\xc4\xb5"
      "\x89\xb0\xce\xd7\xf9\x25\x62\xb5\x4d\x17\x35\xda\xc9\x72\xa1\x38\x87\xc0"
      "\xa5\xa4\x34\x2e\x27\xa3\x1f\xe1\xec\x3c\x90\x19\xec\x71\x14\x4b\xcf\xca"
      "\x22\x20\x3e\x89\x1a\x1f\x2c\x24\x30\x05\x4d\xdb\xdd\x27\x8e\x04\xe4\x15"
      "\x03\x88\xf3\xdc\x6b\x99\x62\x7c\xb2\x4d\xc0\xe5\x80\x59\xc5\xa4\x12\x6b"
      "\x6f\x47\xb2\xf8\x7c\x1f\x57\x88\xee\xaa\x4e\x80\x2d\x46\x8d\x9a\x51\xa2"
      "\x4a\x59\x85\xaf\x12\x57\x3d\xce\x3a\xc5\x6c\xe8\x53\x9a\x75\x13\x0c\xbf"
      "\xc4\xc1\x8a\xad\x51\x4d\xd2\xc1\xe9\xd0\xb0\xef\x24\x36\xe9\x95\x39\x06"
      "\x1e\x84\xf8\x3d\x1c\xb3\x9d\xcc\x8a\x77\x6a\xc8\xbc\xcf\x22\xd3\x49\x04"
      "\x2a\x87\xf3\x2c\x48\x54\x68\x4c\x7a\x6b\x4c\x36\xd5\x8f\xda\xd7\x59\xc4"
      "\x66\xe7\xcc\x65\xe2\x1f\x10\xf1\x03\x39\xa9\x95\x0d\x7b\xf1\x19\x4f\x8f"
      "\xee\xc5\x80\x48\x2d\x7b\xf5\x03\x36\xd0\xdf\x94\xb3\x19\x3d\x6d\x4a\xe1"
      "\x75\xcc\xdc\x22\x17\x7e\x89\xdb\x74\x62\xbf\x17\xaa\x9c\x75\x4f\x1e\xce"
      "\x6a\x3a\xdc\x6b\x21\xc1\x6b\x7e\xfb\x7d\x95\xdf\x58",
      949);
  *(uint8_t*)0x20000935 = -1;
  sprintf((char*)0x20000936, "0x%016llx", (long long)-1);
  *(uint64_t*)0x20000948 = -1;
  sprintf((char*)0x20000950, "%023llo", (long long)-1);
  sprintf((char*)0x20000967, "0x%016llx", (long long)-1);
  sprintf((char*)0x20000979, "0x%016llx", (long long)-1);
  sprintf((char*)0x2000098b, "%023llo", (long long)-1);
  memcpy(
      (void*)0x200009a2,
      "\x6c\x58\x7b\x81\x89\x6b\x23\x50\x36\x9e\xe8\xd8\x3f\x97\x7b\x69\x67\x03"
      "\x52\x77\x59\xa6\x74\xc6\xd6\x1c\xd9\x29\xeb\xc6\xe5\x00\x4d\x4c\x47\xf0"
      "\x14\x4e\xd8\xa5\x32\xc6\xb3\xcb\x87\x7b\xdf\xee\x3e\x2d\x4e\x5c\xe1\xf0"
      "\xdd\x5b\x52\x39\xd7\xed\xeb\x45\x7c\x84\x19\xb1\xe2\x29\x74\xea\xfe\x8e"
      "\x72\x7b\x9a\x24\x45\xa3\x70\x73\x42\x09\xa6\xe4\xa8\x44\x5f\xa3\x48\xb9"
      "\xdd\x7f\xf9\x70\x6a\x25\x36\xdf\x37\x1f\xa6\xb2\x63\x53\x3b\xf0\x21\xbb"
      "\x17\x95\x09\xa9\x10\x96\x6d\x44\x74\x21\x8e\x87\x4d\xba\x3b\x22\xff\x70"
      "\xde\xda\x30\x8f\x59\x03\xf8\x5b\x1e\xab\x3e\xc4\xe5\x39\xdc\x3b\x71\x46"
      "\x2b\x66\x78\x5e\xc2\xcd\x88\xd2\x15\x0c\x44\x5c\xb1\x96\x89\x39\x21\x9a"
      "\x3d\xce\xea\x5f\xdf\xb2\x22\x11\x47\x69\x46\x87\x21\xf2\x1f\xd9\xe7\xe1"
      "\xde\x2a\xf8\x0a\xdd\x07\x00\x00\x00\x52\xa6\x39\x30\x41\xd5\x1d\x23\x9b"
      "\xe0\xfd\x1e\x17\x61\x50\xe5\x21\x39\xd4\x82\x37\x06\xe8\x63\x9b\x45\x7c"
      "\xac\x96\x12\x16\x85\xc2\x2f\x84\x3f\xce\x08\x73\x65\xec\x1b\xfc\xda\xfe"
      "\x63\x1d\xc7\x03\x1f\xdb\x56\xb9\x75\xb0\xc5\xe9\xe7\xc6\x28\x17\xf7\x38"
      "\x73\x69\xfc\x27\x19\xa3\xc6\x53\x29\x4e\x29\x10\x00\xf9\xd4\xc3\x70\x28"
      "\x5b\x31\xed\x27\x08\xd5\xac\x06\x9a\x21",
      280);
  *(uint64_t*)0x20000aba = -1;
  syz_mount_image(
      /*fs=*/0x20000180, /*dir=*/0x20000100,
      /*flags=MS_I_VERSION|MS_PRIVATE|MS_STRICTATIME|MS_REMOUNT|MS_RELATIME|0x48c*/
      0x1a404ac, /*opts=*/0x20000580, /*chdir=*/0xfe, /*size=*/0,
      /*img=*/0x20000000);
  memcpy((void*)0x20000040, "./bus\000", 6);
  syscall(__NR_creat, /*file=*/0x20000040ul, /*mode=*/0ul);
  memcpy((void*)0x200000c0, "./bus\000", 6);
  syscall(__NR_unlink, /*path=*/0x200000c0ul);
  return 0;
}