// https://syzkaller.appspot.com/bug?id=20c4a7b5a6f4c32158f2b8ea3dd461bc1e9e9a4e
// 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 279
#endif
#ifndef __NR_mmap
#define __NR_mmap 222
#endif
#ifndef __NR_openat
#define __NR_openat 56
#endif
#ifndef __NR_pwritev2
#define __NR_pwritev2 287
#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;
}

uint64_t r[1] = {0xffffffffffffffff};

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