// https://syzkaller.appspot.com/bug?id=706b943a0b26e4dada264aafdee297f3de937d81
// 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;
}

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