map[SimplifiedCRepro:// 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
#ifndef __NR_renameat2
#define __NR_renameat2 316
#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");
} else if (strncmp(fs, "gfs2", 4) == 0 && (strstr(opts, "errors=panic") || strstr(opts, "debug"))) {
strcat(opts, ",errors=withdraw");
}
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[2] = {0xffffffffffffffff, 0xffffffffffffffff};
int main(void)
{
syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000ul, /*prot=PROT_WRITE|PROT_READ|PROT_EXEC*/7ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
syscall(__NR_mmap, /*addr=*/0x200001000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul);
const char* reason;
(void)reason;
intptr_t res = 0;
if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {}
// syz_mount_image$hfsplus arguments: [
// fs: ptr[in, buffer] {
// buffer: {68 66 73 70 6c 75 73 00} (length 0x8)
// }
// dir: ptr[in, buffer] {
// buffer: {2e 2f 66 69 6c 65 32 00} (length 0x8)
// }
// flags: mount_flags = 0x10108d4 (8 bytes)
// opts: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// }
// }
// chdir: int8 = 0x1 (1 bytes)
// size: len = 0x65f (8 bytes)
// img: ptr[in, buffer] {
// buffer: (compressed buffer with length 0x65f)
// }
// ]
// returns fd_dir
memcpy((void*)0x200000000240, "hfsplus\000", 8);
memcpy((void*)0x200000000200, "./file2\000", 8);
memcpy((void*)0x200000000d00, "... [truncated large byte array] ...", 1631);
syz_mount_image(/*fs=*/0x200000000240, /*dir=*/0x200000000200, /*flags=MS_POSIXACL|MS_SYNCHRONOUS|MS_STRICTATIME|MS_NODIRATIME|MS_NODEV|0xc0*/0x10108d4, /*opts=*/0x2000000000c0, /*chdir=*/1, /*size=*/0x65f, /*img=*/0x200000000d00);
// symlink arguments: [
// old: ptr[in, buffer] {
// buffer: {2e 2f 66 69 6c 65 32 00} (length 0x8)
// }
// new: ptr[in, buffer] {
// buffer: {2e 2f 66 69 6c 65 30 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 00} (length 0xfa)
// }
// ]
memcpy((void*)0x200000000280, "./file2\000", 8);
memcpy((void*)0x200000000000, "... [truncated large byte array] ...", 250);
syscall(__NR_symlink, /*old=*/0x200000000280ul, /*new=*/0x200000000000ul);
// syz_mount_image$hfsplus arguments: [
// fs: ptr[in, buffer] {
// buffer: {68 66 73 70 6c 75 73 00} (length 0x8)
// }
// dir: ptr[in, buffer] {
// buffer: {2e 2f 62 75 73 00} (length 0x6)
// }
// flags: mount_flags = 0x3a00014 (8 bytes)
// opts: ptr[inout, array[ANYUNION]] {
// array[ANYUNION] {
// union ANYUNION {
// ANYBLOB: buffer: {66 6f 72 63 65 00 00 69 61 e3 8c 80 00 00 00 00 00 00 00 30 30 35 30 30 30 07 3f 41 10 36 b0 30 c3 e5 c5 19 49 ce c5 46 39 2c 63 72 65 61 36 d9 bb 3d 25 f4 ea 83 21 f0 0c ad c2 4c f9 13 02 00 6f 72 71 24 02 bd c8 02 3a 1c eb 6c ff 75 72 4a cd c6 bf 74 17 01 00 53 45 d3 03 00 7f b7 82 97 50 34 06 44 60 8b a8 72 92 d3 e1 82 1a 70 4e 46 58 4f b9 46 cf 3b 27 7b 74 f3 d9 4d 7f 3f 3b 27 b1 b9 53 c9 28 a6 3d 77 86 e2 3b 2d cf 98 f4 bb b4 90 3a 06 ab 8c 62 7b 7b b9 32 95 be 12 b8 2c 45 8f 84 c3 ae 25 bc f2 d8 53 e9 8b 87 25 d8 ae ba bb 35 96 57 99 7a 19 39 b7 9f 37 ab 02 81 0b de 52 e8 c3 d1 e3 a0 66 b8 f2 50 09 b6 91 ec a2 0d a6 e0 03 90 f1 c7 37 91 ba d7 84 7f 51 16 b5 44 b9 f3 72 66 39 13 ff a7 89 b2 10 26 0b e4 78 0c 06 1f df ed 19 1d f0 7d 52 d6 8d b9 29 63 ef 8f 96 e4 62 af 51 1b be 85 11 ae 0c e4 ab ce b6 51 6b 98 73 78 78 83 ad 79 74 db ec b6 45 be 4a 0f 56 66 75 ca 9e 56 f4 cc cc 8d e7 8f 7c a8 03 d7 c0 f2 66 c3 b5 ce 9b 12 0d d6 e9 26 a5 b8 cc 43 53 31 a9 a7 5b b9 f9 ca 0f 4d 00 56 a1 14 da eb 4c 5e 31 71 de 79 f9 04 f8 01 c5 c2 4d 06 17 a0 95 c5 a5 de a5 ff 7e 54 5d 1f 7d 0e 91 27 d8 fd d8 30 51 db b6 fc b2 5b 8d 09 96 72 93 85 5e 13 c0 d4 bb 8e ec 9b f8 1b 53 f9 ff ff ff ed 05 b5 b6 0c b8 cd f1 58 f1 8d ed e7 22 4c 46 55 e9 01 0c 60 31 5b 96 45 a7 87 67 a5 ca 8e bf d7 d2 d4 e6 ae 97 06 f0 0a e9 d5 97 e9 00 00 62 89 7e 9a 38 9d 91 43 e6 eb 06 9e 03 7c 29 b9 75 68 c5 90 65 c2 93 a5 13 bc d7 fe 78 80 f6 67 54 64 cb aa 3b 7d 66 0c ff ff ff ff ff ff ff ff 72 b6 fa 8a 57 92 21 c6 77 6c c0 15 b2 6e 66 f6 15 51 06 9b 4b 16 df dc 1f 6e 72 5b c7 5a a9 87 0b f6 c8 5a 78 17 95 18 c6 f1 ec 9a 1f bb a7 b1 1c be 38 58 59 97 2f 41 ba 4c 2d d6 30 3f db 36 d9 82 9c 00 7c ba 31 a1 50 c0 f0 5d 0a a8 3f af 53 36 e0 0b 07 00 00 00 00 00 00 00 5e 5f 99 12 fa 11 39 4a 7d 34 01 00 00 00 00 d4 23 28 e0 75 d2 2c a6 e0 f2 f1 de 32 6c 5b 96 86 93 c4 43 20 06 7b 81 ae 9c 93 cf 2f 99 22 09 56 5d 76 aa a1 44 7c 34 3e 11 38 7d 69 19 03 f3 41 0a 3c 31 e4 f1 3f ca f3 f0 b9 57 f8 d7 2b ea 2c 76 c7 04 1b 06 2a bd 8c b3 8a 98 6e 3d 51 d5 00 51 80 76 2e 4f f3 e7 3f 25 5e 9b 2c a5 f6 b7 6b 38 c6 c8 e1 f1 de aa 0e 5a fc 20 1d 59 6f 66 f4 b2 38 c7 9f 77 b6 e3 b7 d1 63 41 1c 5e 5d b8 15 aa e6 f3 77 be 1f d0 b8 65 48 a8 38 36 3b 56 1c 08 e1 39 76 5c 52 bf 05 90 b0 83 98 26 6c 8a 41 4d 56 69 f3 00 07 5c 87 e9 d3 f9 fa b6 bf bd 59 b1 2a 2e 0c 0d e4 4b 19 c1 0e eb 9d 96 0e a1 4e 4d 28 5c 61 0f db 6c 58 98 c0 7d 43 fb 97 32 af 8e 7a a1 96 5b 1b 7d cd 1b d3 ec 59 fe 27 af 9e fa 7a f3 55 fd e1 69 5d be 95 91 8d c9 13 ce f6 01 01 d4 5c cb 6e e5 af 09 f8 57 c0 68 1b e5 4b b1 cf 9f 96 3c ec 8b 93 13 e3 4f 72 a0 b1 9c d5 04 21 5c 97 77 f5 a7 a7 bd 3e 9a 5c c3 e1 aa 33 8d ea 66 23 5b a6 7e 5c f3 1e 27 b1 3e a0 6f 3e 3e a4 3b 9e 49 e9 b0 14 af e1 74 00 50 46 ac 5d b7 58 fc 17 fd f7 9f 10 18 24 bd 7b 45 5e 7d 99 0e 83 1f ce b0 37 15 7f fe 84 b9 b7 b3 29 68 cc 4b 73 0b f2 8d 5b 5b e3 2b e1 7d ac b7 c6 27 3e c1 ac ef 44 c9 cd 81 2c 81 41 6d f9 0a 84 bd cc f4 1f d6 c9 cc 69 93 87 b1 44 0a b1 84 7b e5 71 35 49 b6 09 26 50 8d 00 00 00 00 00 00 84 be b7 f2 45 e2 43 14 6d 9a 31 39 8b 76 f4 e9 c0 32 c0 d8 da 00 a1 d3 03 8c 3b ae e7 1f 78 30 8e f8 35 f0 0b 41 72 20 5f ca 3f da 47 82 bf af 55 e9 79 42 f7 fd 39 32 44 ce da 1f 95 62 7e 07 59 41 47 04 88 06 69 05 b9 6b eb 0e dd 6b d2 cf 01 55 d1 62 91 0a 03 df 05 90 9b 50 31 1a 60 58 e8 40 9d} (length 0x459)
// }
// union ANYUNION {
// ANYRES32: ANYRES32 (resource)
// }
// union ANYUNION {
// ANYRES8: ANYRES8 (resource)
// }
// }
// }
// chdir: int8 = 0x3 (1 bytes)
// size: len = 0x5e7 (8 bytes)
// img: ptr[in, buffer] {
// buffer: (compressed buffer with length 0x5e7)
// }
// ]
// returns fd_dir
memcpy((void*)0x200000000600, "hfsplus\000", 8);
memcpy((void*)0x200000000140, "./bus\000", 6);
memcpy((void*)0x200000000dc0, "... [truncated large byte array] ...", 1113);
*(uint32_t*)0x200000001219 = -1;
*(uint8_t*)0x20000000121d = -1;
memcpy((void*)0x200000000640, "... [truncated large byte array] ...", 1511);
syz_mount_image(/*fs=*/0x200000000600, /*dir=*/0x200000000140, /*flags=MS_LAZYTIME|MS_I_VERSION|MS_SYNCHRONOUS|MS_STRICTATIME|MS_RELATIME|MS_NODEV*/0x3a00014, /*opts=*/0x200000000dc0, /*chdir=*/3, /*size=*/0x5e7, /*img=*/0x200000000640);
// openat arguments: [
// fd: fd_dir (resource)
// file: ptr[in, buffer] {
// buffer: {2e 00} (length 0x2)
// }
// flags: open_flags = 0x0 (4 bytes)
// mode: open_mode = 0x0 (2 bytes)
// ]
// returns fd
memcpy((void*)0x200000000040, ".\000", 2);
res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x200000000040ul, /*flags=*/0, /*mode=*/0);
if (res != -1)
r[0] = res;
// openat arguments: [
// fd: fd_dir (resource)
// file: ptr[in, buffer] {
// buffer: {2e 00} (length 0x2)
// }
// flags: open_flags = 0x0 (4 bytes)
// mode: open_mode = 0x0 (2 bytes)
// ]
// returns fd
memcpy((void*)0x200000000040, ".\000", 2);
res = syscall(__NR_openat, /*fd=*/0xffffff9c, /*file=*/0x200000000040ul, /*flags=*/0, /*mode=*/0);
if (res != -1)
r[1] = res;
// renameat2 arguments: [
// oldfd: fd_dir (resource)
// old: ptr[in, buffer] {
// buffer: {2e 2f 66 69 6c 65 32 00} (length 0x8)
// }
// newfd: fd_dir (resource)
// new: ptr[in, buffer] {
// buffer: {2e 2f 66 69 6c 65 31 00} (length 0x8)
// }
// flags: renameat2_flags = 0x0 (8 bytes)
// ]
memcpy((void*)0x2000000000c0, "./file2\000", 8);
memcpy((void*)0x200000000180, "./file1\000", 8);
syscall(__NR_renameat2, /*oldfd=*/r[1], /*old=*/0x2000000000c0ul, /*newfd=*/r[0], /*new=*/0x200000000180ul, /*flags=*/0ul);
// renameat2 arguments: [
// oldfd: fd_dir (resource)
// old: nil
// newfd: fd_dir (resource)
// new: nil
// flags: renameat2_flags = 0x5 (8 bytes)
// ]
syscall(__NR_renameat2, /*oldfd=*/r[0], /*old=*/0ul, /*newfd=*/r[1], /*new=*/0ul, /*flags=RENAME_WHITEOUT|RENAME_NOREPLACE*/5ul);
return 0;
}
]