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

#define _GNU_SOURCE

#include <endian.h>
#include <errno.h>
#include <fcntl.h>
#include <setjmp.h>
#include <signal.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_mkdirat
#define __NR_mkdirat 34
#endif
#ifndef __NR_mmap
#define __NR_mmap 222
#endif
#ifndef __NR_openat
#define __NR_openat 56
#endif
#ifndef __NR_write
#define __NR_write 64
#endif

static unsigned long long procid;

static __thread int clone_ongoing;
static __thread int skip_segv;
static __thread jmp_buf segv_env;

static void segv_handler(int sig, siginfo_t* info, void* ctx)
{
  if (__atomic_load_n(&clone_ongoing, __ATOMIC_RELAXED) != 0) {
    exit(sig);
  }
  uintptr_t addr = (uintptr_t)info->si_addr;
  const uintptr_t prog_start = 1 << 20;
  const uintptr_t prog_end = 100 << 20;
  int skip = __atomic_load_n(&skip_segv, __ATOMIC_RELAXED) != 0;
  int valid = addr < prog_start || addr > prog_end;
  if (skip && valid) {
    _longjmp(segv_env, 1);
  }
  exit(sig);
}

static void install_segv_handler(void)
{
  struct sigaction sa;
  memset(&sa, 0, sizeof(sa));
  sa.sa_handler = SIG_IGN;
  syscall(SYS_rt_sigaction, 0x20, &sa, NULL, 8);
  syscall(SYS_rt_sigaction, 0x21, &sa, NULL, 8);
  memset(&sa, 0, sizeof(sa));
  sa.sa_sigaction = segv_handler;
  sa.sa_flags = SA_NODEFER | SA_SIGINFO;
  sigaction(SIGSEGV, &sa, NULL);
  sigaction(SIGBUS, &sa, NULL);
}

#define NONFAILING(...)                                                        \
  ({                                                                           \
    int ok = 1;                                                                \
    __atomic_fetch_add(&skip_segv, 1, __ATOMIC_SEQ_CST);                       \
    if (_setjmp(segv_env) == 0) {                                              \
      __VA_ARGS__;                                                             \
    } else                                                                     \
      ok = 0;                                                                  \
    __atomic_fetch_sub(&skip_segv, 1, __ATOMIC_SEQ_CST);                       \
    ok;                                                                        \
  })

//% 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);
  install_segv_handler();
  intptr_t res = 0;
  NONFAILING(memcpy((void*)0x20000180, "hfs\000", 4));
  NONFAILING(memcpy((void*)0x20000040, "./file0\000", 8));
  NONFAILING(memcpy(
      (void*)0x200003c0,
      "codepage=koi8-r,part=0x0000000000000006,quiet,iocharset=cp857,uid=",
      66));
  NONFAILING(sprintf((char*)0x20000402, "0x%016llx", (long long)0));
  NONFAILING(memcpy((void*)0x20000414,
                    "\x2c\x00\x38\xff\x4a\xb2\x2a\xc1\x12\x6a\x33\x19\xae\xa6"
                    "\x72\x9c\x1f\xb7\x7e\x25\x0a\xa3\xf3\xf3\xa5\x14\x01\x3d"
                    "\xf5\x39\xdf\xc3\xec\x70\xb4\x0b\xf2\xcd\x93\x42\xfd\x15"
                    "\x77\x1e\xe8\x18\x82\xb0\x37\x59\xa2\x44\x4d\x86\x00",
                    55));
  NONFAILING(memcpy(
      (void*)0x20000900,
      "\x78\x9c\xec\xdd\x3d\x6f\x13\x49\x1c\xc7\xf1\xdf\xac\xed\xc4\x79\x50\x6e"
      "\x2f\xc9\xe9\xa4\x6b\x0e\x05\x22\x41\x13\x11\xa0\x40\x34\x46\xc8\x2d\x3d"
      "\x15\x02\x62\x47\x8a\xb0\x82\x48\x82\x04\x34\x04\x44\x89\x78\x01\xf4\xbc"
      "\x05\x5e\x04\x0d\x88\x37\x00\x15\x15\x35\x4a\xb7\x68\x66\xc7\x9b\x5d\x7b"
      "\xbd\x8e\x03\xb6\xe3\xe4\xfb\x91\x6c\xad\x67\x67\x76\xfe\xc3\xcc\x78\x67"
      "\x56\x22\x16\x80\x33\xeb\x56\xfd\xeb\xfb\xab\xdf\xed\xcb\x48\x25\x95\x24"
      "\xdd\x90\x02\x49\x55\xa9\x2c\xe9\x1f\xfd\x5b\x7d\xb2\xbd\xb7\xb5\xd7\x6a"
      "\x36\x8a\x2e\x54\x72\x25\xec\xcb\x28\x2e\x69\xba\xf2\x6c\x6c\x37\xf3\x8a"
      "\xda\x72\xae\x84\x17\xda\x4f\x65\xcd\xa7\xd3\x30\x1c\x51\x14\xdd\xfc\x36"
      "\xee\x20\x30\x76\x6e\xf6\xe7\x08\xa4\x69\x3f\x0f\xdd\xf9\xea\x88\xe3\x1a"
      "\x96\x7d\xe9\xff\x71\xc7\x30\x6a\xe9\x0e\x36\x07\x3a\xd0\x53\x2d\x8c\x31"
      "\x1c\x00\xc0\x09\xe0\xef\xff\x81\xbf\x4d\xcc\xbb\x24\xa3\x20\x90\x56\xfd"
      "\x6d\xff\xb4\xdc\xff\xbb\xf7\x25\x93\xef\x5a\xab\x2b\x29\x2a\x2c\x90\xba"
      "\xff\xbb\xd5\x5d\x64\x6c\xff\xfe\xe5\x4e\x1d\xee\xf7\xdc\x3f\x95\x3d\x1f"
      "\xb4\x77\x89\x47\x09\xa6\xd2\xf1\x79\x4a\xf1\xc8\xca\x2c\x30\x4d\xbf\x5d"
      "\xa5\x8b\x25\x98\xd9\xdc\x2a\x6b\x6d\xe3\xa5\x1a\x81\x5e\xa9\xe6\xa5\xb2"
      "\x2d\xbb\xf7\x46\x3c\x74\xdb\xfa\x44\xbb\x32\xd8\x18\xe8\x7d\xb5\x8a\x6e"
      "\xcf\xc6\xad\x71\x2b\xca\x4e\xed\x90\x36\xb7\x5a\xcd\x69\x7b\x50\xab\xd5"
      "\x7e\x56\xb2\xf1\x2f\x0d\x56\xe3\xef\x33\x1f\xcd\x67\x73\xd7\x84\x7a\xa7"
      "\x46\xb2\xfe\x2b\x47\xc6\x76\x93\xeb\xa9\xb0\xa3\xa7\x82\x8a\x8d\xff\x72"
      "\xef\x2b\xce\xb9\x52\x36\x97\xfc\xf4\xaa\xd5\x6a\x41\x26\xcb\xdf\xae\x92"
      "\xff\x7c\x0d\x5e\x9f\x56\x56\xf3\x77\x24\xe9\x6b\xb6\x1f\x10\xec\x27\x11"
      "\x14\xc5\xe9\xea\x5e\x54\xf6\xb1\x42\xdc\xba\xf5\x3e\xa5\x96\xf2\x4a\x85"
      "\xc9\xa7\x1e\xa5\x96\x33\xa5\x4a\x7e\x24\xac\x6d\x3c\x6a\x15\x3e\x4a\x19"
      "\x8e\x76\x13\xcd\x5b\x73\xc7\xac\xe8\x87\x3e\xa8\x9e\x5a\xff\x07\x36\xbe"
      "\x55\xa5\x66\x66\xc7\x57\x7d\x7a\xd0\xca\xb8\x9c\x7e\x64\xc4\xed\x99\xca"
      "\xaf\xb6\xec\x72\x86\x5d\x77\x8e\xc3\xe9\x72\x2e\x89\xc0\x9b\x3e\x56\xfb"
      "\xce\xbc\xc1\x9e\x96\xbd\xd1\x03\x5d\xd7\xc2\xee\xb3\xe7\x0f\x4b\xad\x56"
      "\x73\xc7\x1e\xdc\xcf\x39\x78\x3c\xbf\x63\x7c\x4a\xe5\xb5\x94\x9b\x67\xf8"
      "\x07\x25\x15\xe4\xd1\xfe\x61\x4a\x64\xbd\x88\xa2\xa3\x5e\x39\xf2\x07\xcb"
      "\x73\x43\x08\xfe\xd2\x1f\xbd\xa0\xfd\xfe\x48\x52\xec\xf4\xc9\xcb\x6c\x67"
      "\x59\x92\x12\x8c\xba\x9b\xce\xca\x41\xfd\x93\x8a\x06\xe4\xe4\x1c\x44\x91"
      "\xd4\xe3\xd4\xd0\xbe\xa7\x70\x82\xec\x9a\x76\xa7\xfb\x84\x99\x31\x07\x84"
      "\x51\xb3\xeb\x2e\x13\xef\xff\xdc\x4a\xde\xaf\xea\xdc\x16\xc9\xbe\x85\x05"
      "\xeb\xf4\xe2\x4d\xa6\x32\x57\x5c\x4f\x76\x70\xd9\xa5\xe0\xa2\x7b\x9f\x1d"
      "\x68\x07\x37\xd7\x7b\x07\x97\xaa\xf1\x4a\x8f\x3d\xa3\xdb\x73\x9d\xbf\x28"
      "\x5d\x48\x25\x1a\x15\xd6\x18\xfa\x38\x4f\x09\x53\xd7\x17\xdd\xe3\xf9\x3f"
      "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xc0\xa4\x19\xc5"
      "\xff\x34\x18\x77\x1b\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
      "\x00\x00\x00\x00\x98\x74\xc7\xfa\xfd\xdf\xbc\xbf\x11\xef\x7e\xff\x37\xe4"
      "\xf7\x7f\x81\x09\xf2\x2b\x00\x00\xff\xff\x67\x2e\x77\xdf",
      734));
  NONFAILING(syz_mount_image(/*fs=*/0x20000180, /*dir=*/0x20000040, /*flags=*/0,
                             /*opts=*/0x200003c0, /*chdir=*/1, /*size=*/0x2de,
                             /*img=*/0x20000900));
  NONFAILING(memcpy((void*)0x200001c0, "blkio.bfq.time\000", 15));
  res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x200001c0ul,
                /*flags=*/0x275aul, /*mode=*/0ul);
  if (res != -1)
    r[0] = res;
  NONFAILING(
      memcpy((void*)0x20000200,
             "\x8d\x6b\xa9\x66\x96\x49\x52\x3c\x80\x09\xd0\x45\x26\x80\x82\xc7"
             "\x9d\x8a\x45\x72\x2e\xb9\xb2\x8f\xe3\x38\x3a\x02\xbc\xbb\xe7",
             31));
  syscall(__NR_write, /*fd=*/r[0], /*data=*/0x20000200ul, /*len=*/0x10ful);
  syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0x400000ul,
          /*prot=PROT_GROWSUP|PROT_READ|PROT_EXEC*/ 0x2000005ul,
          /*flags=MAP_NONBLOCK|MAP_FIXED|MAP_PRIVATE*/ 0x10012ul, /*fd=*/r[0],
          /*offset=*/0ul);
  NONFAILING(memcpy((void*)0x20000000, "./file0\000", 8));
  syscall(__NR_mkdirat, /*fd=*/0xffffff9c, /*path=*/0x20000000ul, /*mode=*/0ul);
  return 0;
}