Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // autogenerated by syzkaller (https://github.com/google/syzkaller)
- #define _GNU_SOURCE
- #include <endian.h>
- #include <errno.h>
- #include <fcntl.h>
- #include <pthread.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 <time.h>
- #include <unistd.h>
- #include <linux/futex.h>
- #include <linux/loop.h>
- #ifndef __NR_memfd_create
- #define __NR_memfd_create 319
- #endif
- static unsigned long long procid;
- static void sleep_ms(uint64_t ms)
- {
- usleep(ms * 1000);
- }
- static uint64_t current_time_ms(void)
- {
- struct timespec ts;
- if (clock_gettime(CLOCK_MONOTONIC, &ts))
- exit(1);
- return (uint64_t)ts.tv_sec * 1000 + (uint64_t)ts.tv_nsec / 1000000;
- }
- static void thread_start(void* (*fn)(void*), void* arg)
- {
- pthread_t th;
- pthread_attr_t attr;
- pthread_attr_init(&attr);
- pthread_attr_setstacksize(&attr, 128 << 10);
- int i = 0;
- for (; i < 100; i++) {
- if (pthread_create(&th, &attr, fn, arg) == 0) {
- pthread_attr_destroy(&attr);
- return;
- }
- if (errno == EAGAIN) {
- usleep(50);
- continue;
- }
- break;
- }
- exit(1);
- }
- typedef struct {
- int state;
- } event_t;
- static void event_init(event_t* ev)
- {
- ev->state = 0;
- }
- static void event_reset(event_t* ev)
- {
- ev->state = 0;
- }
- static void event_set(event_t* ev)
- {
- if (ev->state)
- exit(1);
- __atomic_store_n(&ev->state, 1, __ATOMIC_RELEASE);
- syscall(SYS_futex, &ev->state, FUTEX_WAKE | FUTEX_PRIVATE_FLAG, 1000000);
- }
- static void event_wait(event_t* ev)
- {
- while (!__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE))
- syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, 0);
- }
- static int event_isset(event_t* ev)
- {
- return __atomic_load_n(&ev->state, __ATOMIC_ACQUIRE);
- }
- static int event_timedwait(event_t* ev, uint64_t timeout)
- {
- uint64_t start = current_time_ms();
- uint64_t now = start;
- for (;;) {
- uint64_t remain = timeout - (now - start);
- struct timespec ts;
- ts.tv_sec = remain / 1000;
- ts.tv_nsec = (remain % 1000) * 1000 * 1000;
- syscall(SYS_futex, &ev->state, FUTEX_WAIT | FUTEX_PRIVATE_FLAG, 0, &ts);
- if (__atomic_load_n(&ev->state, __ATOMIC_ACQUIRE))
- return 1;
- now = current_time_ms();
- if (now - start > timeout)
- return 0;
- }
- }
- //% 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 [email protected]
- //% 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;
- }
- struct thread_t {
- int created, call;
- event_t ready, done;
- };
- static struct thread_t threads[16];
- static void execute_call(int call);
- static int running;
- static void* thr(void* arg)
- {
- struct thread_t* th = (struct thread_t*)arg;
- for (;;) {
- event_wait(&th->ready);
- event_reset(&th->ready);
- execute_call(th->call);
- __atomic_fetch_sub(&running, 1, __ATOMIC_RELAXED);
- event_set(&th->done);
- }
- return 0;
- }
- static void loop(void)
- {
- if (write(1, "executing program\n", sizeof("executing program\n") - 1)) {
- }
- int i, call, thread;
- for (call = 0; call < 2; call++) {
- for (thread = 0; thread < (int)(sizeof(threads) / sizeof(threads[0]));
- thread++) {
- struct thread_t* th = &threads[thread];
- if (!th->created) {
- th->created = 1;
- event_init(&th->ready);
- event_init(&th->done);
- event_set(&th->done);
- thread_start(thr, th);
- }
- if (!event_isset(&th->done))
- continue;
- event_reset(&th->done);
- th->call = call;
- __atomic_fetch_add(&running, 1, __ATOMIC_RELAXED);
- event_set(&th->ready);
- if (call == 0)
- break;
- event_timedwait(&th->done, 50 + (call == 0 ? 4000 : 0));
- break;
- }
- }
- for (i = 0; i < 100 && __atomic_load_n(&running, __ATOMIC_RELAXED); i++)
- sleep_ms(1);
- }
- void execute_call(int call)
- {
- switch (call) {
- case 0:
- // syz_mount_image$ext4 arguments: [
- // fs: ptr[in, buffer] {
- // buffer: {65 78 74 34 00} (length 0x5)
- // }
- // dir: ptr[in, buffer] {
- // buffer: {2e 2f 62 75 73 00} (length 0x6)
- // }
- // flags: mount_flags = 0x400547 (8 bytes)
- // opts: ptr[in, fs_options[ext4_options]] {
- // fs_options[ext4_options] {
- // elems: array[fs_opt_elem[ext4_options]] {
- // fs_opt_elem[ext4_options] {
- // elem: union ext4_options {
- // nobarrier: buffer: {6e 6f 62 61 72 72 69 65 72} (length 0x9)
- // }
- // comma: const = 0x2c (1 bytes)
- // }
- // fs_opt_elem[ext4_options] {
- // elem: union ext4_options {
- // data_err_ignore: buffer: {64 61 74 61 5f 65 72 72 3d 69 67
- // 6e 6f 72 65} (length 0xf)
- // }
- // comma: const = 0x2c (1 bytes)
- // }
- // fs_opt_elem[ext4_options] {
- // elem: union ext4_options {
- // sb: fs_opt["sb", fmt[hex, int32]] {
- // name: buffer: {73 62} (length 0x2)
- // eq: const = 0x3d (1 bytes)
- // val: int32 = 0x1 (18 bytes)
- // }
- // }
- // comma: const = 0x2c (1 bytes)
- // }
- // fs_opt_elem[ext4_options] {
- // elem: union ext4_options {
- // barrier_val: fs_opt["barrier", fmt[hex, int32]] {
- // name: buffer: {62 61 72 72 69 65 72} (length 0x7)
- // eq: const = 0x3d (1 bytes)
- // val: int32 = 0x3 (18 bytes)
- // }
- // }
- // comma: const = 0x2c (1 bytes)
- // }
- // fs_opt_elem[ext4_options] {
- // elem: union ext4_options {
- // dioread_lock: buffer: {64 69 6f 72 65 61 64 5f 6c 6f 63 6b}
- // (length 0xc)
- // }
- // comma: const = 0x2c (1 bytes)
- // }
- // fs_opt_elem[ext4_options] {
- // elem: union ext4_options {
- // resgid: fs_opt["resgid", fmt[hex, gid]] {
- // name: buffer: {72 65 73 67 69 64} (length 0x6)
- // eq: const = 0x3d (1 bytes)
- // val: gid (resource)
- // }
- // }
- // comma: const = 0x2c (1 bytes)
- // }
- // fs_opt_elem[ext4_options] {
- // elem: union ext4_options {
- // errors_remount: buffer: {65 72 72 6f 72 73 3d 72 65 6d 6f 75
- // 6e 74 2d 72 6f} (length 0x11)
- // }
- // comma: const = 0x2c (1 bytes)
- // }
- // fs_opt_elem[ext4_options] {
- // elem: union ext4_options {
- // sysvgroups: buffer: {73 79 73 76 67 72 6f 75 70 73} (length
- // 0xa)
- // }
- // comma: const = 0x2c (1 bytes)
- // }
- // fs_opt_elem[ext4_options] {
- // elem: union ext4_options {
- // journal_dev: fs_opt["journal_dev", fmt[hex, int32]] {
- // name: buffer: {6a 6f 75 72 6e 61 6c 5f 64 65 76} (length
- // 0xb) eq: const = 0x3d (1 bytes) val: int32 =
- // 0x800000000003 (18 bytes)
- // }
- // }
- // comma: const = 0x32 (1 bytes)
- // }
- // }
- // common: array[fs_opt_elem[fs_options_common]] {
- // }
- // null: const = 0x0 (1 bytes)
- // }
- // }
- // chdir: int8 = 0x1e (1 bytes)
- // size: len = 0x500 (8 bytes)
- // img: ptr[in, buffer] {
- // buffer: (compressed buffer with length 0x500)
- // }
- // ]
- // returns fd_dir
- memcpy((void*)0x200000000040, "ext4\000", 5);
- memcpy((void*)0x200000000500, "./bus\000", 6);
- memcpy((void*)0x200000000140, "nobarrier", 9);
- *(uint8_t*)0x200000000149 = 0x2c;
- memcpy((void*)0x20000000014a, "data_err=ignore", 15);
- *(uint8_t*)0x200000000159 = 0x2c;
- memcpy((void*)0x20000000015a, "sb", 2);
- *(uint8_t*)0x20000000015c = 0x3d;
- sprintf((char*)0x20000000015d, "0x%016llx", (long long)1);
- *(uint8_t*)0x20000000016f = 0x2c;
- memcpy((void*)0x200000000170, "barrier", 7);
- *(uint8_t*)0x200000000177 = 0x3d;
- sprintf((char*)0x200000000178, "0x%016llx", (long long)3);
- *(uint8_t*)0x20000000018a = 0x2c;
- memcpy((void*)0x20000000018b, "dioread_lock", 12);
- *(uint8_t*)0x200000000197 = 0x2c;
- memcpy((void*)0x200000000198, "resgid", 6);
- *(uint8_t*)0x20000000019e = 0x3d;
- sprintf((char*)0x20000000019f, "0x%016llx", (long long)0xee01);
- *(uint8_t*)0x2000000001b1 = 0x2c;
- memcpy((void*)0x2000000001b2, "errors=remount-ro", 17);
- *(uint8_t*)0x2000000001c3 = 0x2c;
- memcpy((void*)0x2000000001c4, "sysvgroups", 10);
- *(uint8_t*)0x2000000001ce = 0x2c;
- memcpy((void*)0x2000000001cf, "journal_dev", 11);
- *(uint8_t*)0x2000000001da = 0x3d;
- sprintf((char*)0x2000000001db, "0x%016llx", (long long)0x800000000003);
- *(uint8_t*)0x2000000001ed = 0x32;
- *(uint8_t*)0x2000000001ee = 0;
- memcpy(
- (void*)0x200000000540,
- "\x78\x9c\xec\xdd\x41\x6f\x1b\x59\x1d\x00\xf0\xff\x4c\xe2\xdd\xa4\xcd"
- "\x92\xac\xe0\xb0\xac\xc4\x6e\x45\x17\x25\x2b\xa8\x9d\x34\x6c\x37\xe2"
- "\x50\x40\x42\x70\xaa\x04\x94\x7b\x09\x89\x13\x45\x71\xe2\x28\x76\xda"
- "\x26\xaa\x68\x2a\x3e\x00\x12\x42\x80\xc4\x89\x13\x17\x24\x3e\x00\x12"
- "\xea\x47\x40\x48\x95\xe0\x8e\x00\x81\x10\xb4\x70\xe0\x00\x35\xf2\xd8"
- "\x0e\x69\x62\x3b\x2e\x71\xe2\xe2\xfc\x7e\xd2\xd4\xef\xcd\x3c\xcf\xff"
- "\xfd\xdd\x78\x3c\xef\x79\xe4\x09\xe0\xc2\xba\x12\x11\xd7\x23\xe2\x79"
- "\xad\x56\xab\xd7\x27\x9b\xeb\xd3\xe6\x12\x49\x44\xec\x37\xda\x3d\x7b"
- "\xfa\x60\xa9\xbe\x24\x51\xab\xdd\xfe\x6b\x92\x6d\xaa\xd7\xeb\xcd\x66"
- "\x0e\xed\xf3\x72\xe3\x29\x31\x16\x11\x5f\xff\x4a\xc4\xb7\x92\xe3\x71"
- "\x2b\xbb\x7b\xeb\x8b\xa5\x52\x71\xbb\x59\x2f\x54\x37\xb6\x0a\x95\xdd"
- "\xbd\x6b\x6b\x1b\x8b\xab\xc5\xd5\xe2\xe6\xfc\xfc\xdc\x8d\x85\x0f\x17"
- "\x3e\x58\x98\xed\x4b\x9e\x13\x11\x71\xf3\x4b\x7f\xfc\xc1\x77\x7f\xfa"
- "\xe5\x9b\xbf\xfc\xcc\xbd\xdf\xdd\xf9\xf3\xcc\xb7\xeb\xdd\xba\xda\xdc"
- "\xde\xca\xa3\xdf\x1a\xa9\xe7\xb2\xd7\xa2\x65\x34\x22\xb6\xcf\x22\xd8"
- "\x00\x8c\x34\xf3\xc9\x0d\xba\x23\x00\x00\xf4\xa4\x75\x9e\xff\xc9\x88"
- "\x78\x3f\x26\x63\x24\x3b\x9b\x03\x00\x00\x00\x86\x49\xed\xf3\x13\xf1"
- "\xaf\x24\xa2\x76\xcc\x78\xab\x45\x57\xaf\x77\xdf\x0c\x00\x00\x00\xbc"
- "\x02\xd2\xec\xda\xd8\x24\xcd\x37\xaf\x03\x98\x88\x34\xcd\xe7\x1b\xd7"
- "\xf0\x7e\x2c\x2e\xa5\xa5\x72\xa5\xfa\xe9\x95\xf2\xce\xe6\x72\xe3\x1a"
- "\xda\xa9\xc8\xa5\x2b\x6b\xa5\xe2\x6c\xf3\x5a\xe1\xa9\xc8\x25\xf5\xfa"
- "\x5c\x56\xfe\x6f\xfd\xfa\x91\xfa\x7c\x44\xbc\x19\x11\xdf\x9f\x1c\xcf"
- "\xea\xf9\xa5\x72\x69\x79\xc0\x73\x1f\x00\x00\x00\x70\x51\x5c\x3e\x32"
- "\xfe\xff\xc7\x64\x63\xfc\x0f\x00\x00\x00\x0c\x99\xa9\x41\x77\x00\x00"
- "\x00\x00\x38\x73\xc6\xff\x00\x00\x00\x30\xfc\x8c\xff\x01\x00\x00\x60"
- "\xa8\x7d\xf5\xd6\xad\xfa\x52\x6b\xdd\xff\x7a\xf9\xee\xee\xce\x7a\xf9"
- "\xee\xb5\xe5\x62\x65\x3d\xbf\xb1\xb3\x94\x5f\x2a\x6f\x6f\x3d\x8c\x72"
- "\x79\x35\xfb\xcd\xbe\x8d\x93\xf6\x57\x2a\x97\xb7\x3e\x1b\x9b\x3b\xf7"
- "\x0b\xd5\x62\xa5\x5a\xa8\xec\xee\xdd\xd9\x28\xef\x6c\x56\xef\xac\xbd"
- "\x70\x0b\x6c\x00\x00\x00\xe0\x1c\xbd\xf9\xee\xe3\xdf\x26\x11\xb1\xff"
- "\xb9\xf1\x6c\xa9\x7b\x6d\xd0\x9d\x02\xce\xc5\xe8\xb1\x35\x49\xe7\xc6"
- "\x7f\x38\xdb\xbe\x00\xe7\x6b\x64\xd0\x1d\x00\x06\xe6\xf8\xe7\x3f\x70"
- "\x51\xe4\x7a\x68\xe3\x1c\x01\x86\x5b\x97\x51\x7f\xa6\xe3\xc5\x3b\xbf"
- "\xea\x7f\x5f\x00\x00\x80\xb3\x31\xfd\xf1\xf6\xdf\xff\x27\x27\xce\x0d"
- "\xec\xa7\xe7\xd4\x45\xe0\x8c\xf4\x32\xff\x07\x0c\x27\x73\xfb\x70\x71"
- "\xf9\xfe\x1f\x2e\xae\x5c\x8c\x84\x81\x3c\x5c\x6c\xff\xc3\xf7\xff\x2f"
- "\x39\x75\x50\xab\xbd\x5c\x7b\x00\x00\xa0\xdf\x26\xb2\x25\x49\xf3\x11"
- "\xd9\x3c\xc0\x44\xa4\x69\x3e\x1f\xf1\x46\x76\x5b\x80\x5c\xb2\xb2\x56"
- "\x2a\xce\x46\xc4\x47\x22\xe2\x37\x93\xb9\xd7\xeb\xf5\xb9\xec\x99\xc9"
- "\x89\x63\x06\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\xa0\xa1\x56\x4b\xa2\x06\x00\x00\x00\x0c\xb5\x88"
- "\xf4\x4f\x49\xf3\xfe\x5f\xd3\x93\xef\x4d\x1c\x9d\x1f\x78\x2d\xf9\xe7"
- "\x64\xf6\x18\x11\xf7\x7e\x7c\xfb\x87\xf7\x17\xab\xd5\xed\xb9\xfa\xfa"
- "\xbf\x1d\xac\xaf\xfe\xa8\xb9\xfe\xfa\x20\x66\x30\x00\x00\x00\x80\xa3"
- "\x5a\xe3\xf4\xd6\x38\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xfa\xe9\xd9\xd3\x07\x4b\xad"
- "\xe5\x3c\xe3\xfe\xe5\x8b\x11\x31\xd5\x2e\xfe\x68\x8c\x65\x8f\x63\x91"
- "\x8b\x88\x4b\x7f\x4f\x62\xf4\xd0\xf3\x92\x88\x18\xe9\x43\xfc\xfd\x47"
- "\x11\xf1\x56\xfb\xfc\xa7\xb2\xa5\xd1\x8b\x76\xf1\xc7\xfb\x1b\xbf\xb5"
- "\x6a\xa9\x15\xa1\x5b\xfc\x34\x22\x2e\xf7\x21\x3e\x5c\x64\x8f\xeb\xc7"
- "\x9f\x2f\xb4\x7b\xff\xa7\x71\x25\x7b\x6c\xff\xfe\xbb\x91\x1d\xa1\x4e"
- "\xaf\xe3\xf1\x2f\x69\xb5\x18\xcb\x8e\x73\xed\x8e\x3f\x6f\xf4\x18\xe3"
- "\xed\x27\x3f\x2f\x74\x8c\xff\x28\xe2\xed\xd1\x76\xf9\x27\x07\xc7\xdf"
- "\xa4\x43\xfc\xab\x3d\xc6\xff\xe6\x37\xf6\xf6\x3a\x6d\xab\xfd\x24\x62"
- "\xba\xed\xe7\x4f\xf2\x42\xac\x42\x75\x63\xab\x50\xd9\xdd\xbb\xb6\xb6"
- "\xb1\xb8\x5a\x5c\x2d\x6e\xce\xcf\xcf\xdd\x58\xf8\x70\xe1\x83\x85\xd9"
- "\xc2\xca\x5a\xa9\xd8\xfc\xf7\xd0\x21\xf9\xca\x41\xe9\x7b\x9f\xf8\xc5"
- "\xf3\x6e\xf9\x5f\xea\x10\x7f\xea\x84\xfc\xdf\xeb\x31\xff\x7f\x3f\xb9"
- "\xff\xf4\xa3\x8d\x62\xae\x5d\xfc\x99\xab\xed\xff\xfe\xde\xea\x10\x3f"
- "\x6d\x7e\xf6\x7d\xaa\x59\xae\x6f\x99\x6e\x95\xf7\xe3\xa0\xdc\xf2\xce"
- "\xcf\x7e\xfd\x4e\xb7\xfc\x97\x1b\xf9\x8f\xbe\xec\xff\xff\x4c\x8f\xf9"
- "\xbf\xff\xb5\xef\xfc\xbe\xc7\xa6\x00\xc0\x39\xa8\xec\xee\xad\x2f\x96"
- "\x4a\xc5\xed\xff\xbb\x42\xeb\x0c\xb1\x6b\xe3\xfd\xde\x76\x78\xaa\x57"
- "\xa3\x7e\x5a\x34\xf0\x57\xe3\x14\x85\x34\x5e\x89\x6e\x0c\xa2\xf0\xf0"
- "\xac\xf6\xdc\x1c\x3b\xc4\xa0\x13\x3c\xd5\xfb\x0b\x00\x00\x18\x2e\xc7"
- "\xc7\xc0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\xc0\x79\x3b\xf4\xa3\x5f\xef\x9e\xd5\xcf\x89\x1d\x8d\xb9\x3f\x98\x54"
- "\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xba\xfa\x4f\x00\x00\x00\xff"
- "\xff\xee\x38\xbc\x97",
- 1280);
- syz_mount_image(
- /*fs=*/0x200000000040, /*dir=*/0x200000000500,
- /*flags=MS_RDONLY|MS_NOSUID|MS_NODEV|MS_NOATIME|0x400140*/ 0x400547,
- /*opts=*/0x200000000140, /*chdir=*/0x1e, /*size=*/0x500,
- /*img=*/0x200000000540);
- break;
- case 1:
- // sendmsg arguments: [
- // fd: sock (resource)
- // msg: ptr[in, send_msghdr] {
- // send_msghdr {
- // msg_name: nil
- // msg_namelen: len = 0x0 (4 bytes)
- // pad = 0x0 (4 bytes)
- // msg_iov: nil
- // msg_iovlen: len = 0x0 (8 bytes)
- // msg_control: ptr[inout, array[ANYUNION]] {
- // array[ANYUNION] {
- // union ANYUNION {
- // ANYBLOB: buffer: {18 00 00 00 00 00 00 00 01 00 00 00 01 00
- // 00 00 06 00 00 00 03 00 00 00 ee 4e 24 a4 33 ba f6 8a a9 18
- // a3 8c 38 89 8d a0 3d b1 41 d5 9c b7 68 11 f1 86 c6 ef bb b9
- // de 0d eb 32 0e ae f9 6c 1c 43 29 d8 bb 3d e7 94 82 58 37 c3
- // 2a d7 96 92 43 04 43 54 db 02 97 ab 8d 01 15 ef b5 f9 d8 26
- // 9c d8 cf ce 9e 86 d2 be cf db ba 29 c3 49 01 ef 01 01 e4 d5
- // ba 7d 84 fd fb 3c 44 37 11 cd 68 eb c1 a1 21 52 ee 02 f1 0c
- // 37 0c 82 f6 49 73 80 89 a9 3e 27 9d 82 43 7b 64 57 8b bd dc
- // b0 ae cb d5 3b 09 be b0 21 e1 35 57 24 52 ee 17 2f c4 db c8
- // 48 1e 9d 6b 99 66 d0 be 57 96 3d 23 03 02 52 c6 94 96 a1 47
- // 13 65 e0 3f bf 57 ae 9b 28 5d 55 4c 2c 5e 0f 3a 38 02 98 09
- // b8 3b 9b e4 12 c7 fe 73 e1 3c 93 ef ff fe 3b 55 2d 3b 36 19
- // af 7c 80 5d 0e 77 b4 6d ba 7a cb f0 21 6c a9 3e 09 0f 6a 0b
- // e1 53 af 86 9f ff 17 71 c2 9f 5e fd 6a 99 64 83 36 f2 0f 80
- // 5a 84 dd 74 e3 3b f6 4b 1b 99 b5 9e 74 a2 b8 ab c4 fe 0c fe
- // a0 09 42 52 dd 50 0d a7 e6 d4 42 ea 77 1a f1 2b a9 26 74 a1
- // 6c 75 1d 6f 40 63 1f d5 b3 ec 54 73 c4 2e 01 76} (length
- // 0x14a)
- // }
- // }
- // }
- // msg_controllen: bytesize = 0x18 (8 bytes)
- // msg_flags: const = 0x0 (4 bytes)
- // pad = 0x0 (4 bytes)
- // }
- // }
- // f: send_flags = 0x0 (8 bytes)
- // ]
- *(uint64_t*)0x200000000340 = 0;
- *(uint32_t*)0x200000000348 = 0;
- *(uint64_t*)0x200000000350 = 0;
- *(uint64_t*)0x200000000358 = 0;
- *(uint64_t*)0x200000000360 = 0x2000000004c0;
- memcpy(
- (void*)0x2000000004c0,
- "\x18\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x06"
- "\x00\x00\x00\x03\x00\x00\x00\xee\x4e\x24\xa4\x33\xba\xf6\x8a\xa9\x18"
- "\xa3\x8c\x38\x89\x8d\xa0\x3d\xb1\x41\xd5\x9c\xb7\x68\x11\xf1\x86\xc6"
- "\xef\xbb\xb9\xde\x0d\xeb\x32\x0e\xae\xf9\x6c\x1c\x43\x29\xd8\xbb\x3d"
- "\xe7\x94\x82\x58\x37\xc3\x2a\xd7\x96\x92\x43\x04\x43\x54\xdb\x02\x97"
- "\xab\x8d\x01\x15\xef\xb5\xf9\xd8\x26\x9c\xd8\xcf\xce\x9e\x86\xd2\xbe"
- "\xcf\xdb\xba\x29\xc3\x49\x01\xef\x01\x01\xe4\xd5\xba\x7d\x84\xfd\xfb"
- "\x3c\x44\x37\x11\xcd\x68\xeb\xc1\xa1\x21\x52\xee\x02\xf1\x0c\x37\x0c"
- "\x82\xf6\x49\x73\x80\x89\xa9\x3e\x27\x9d\x82\x43\x7b\x64\x57\x8b\xbd"
- "\xdc\xb0\xae\xcb\xd5\x3b\x09\xbe\xb0\x21\xe1\x35\x57\x24\x52\xee\x17"
- "\x2f\xc4\xdb\xc8\x48\x1e\x9d\x6b\x99\x66\xd0\xbe\x57\x96\x3d\x23\x03"
- "\x02\x52\xc6\x94\x96\xa1\x47\x13\x65\xe0\x3f\xbf\x57\xae\x9b\x28\x5d"
- "\x55\x4c\x2c\x5e\x0f\x3a\x38\x02\x98\x09\xb8\x3b\x9b\xe4\x12\xc7\xfe"
- "\x73\xe1\x3c\x93\xef\xff\xfe\x3b\x55\x2d\x3b\x36\x19\xaf\x7c\x80\x5d"
- "\x0e\x77\xb4\x6d\xba\x7a\xcb\xf0\x21\x6c\xa9\x3e\x09\x0f\x6a\x0b\xe1"
- "\x53\xaf\x86\x9f\xff\x17\x71\xc2\x9f\x5e\xfd\x6a\x99\x64\x83\x36\xf2"
- "\x0f\x80\x5a\x84\xdd\x74\xe3\x3b\xf6\x4b\x1b\x99\xb5\x9e\x74\xa2\xb8"
- "\xab\xc4\xfe\x0c\xfe\xa0\x09\x42\x52\xdd\x50\x0d\xa7\xe6\xd4\x42\xea"
- "\x77\x1a\xf1\x2b\xa9\x26\x74\xa1\x6c\x75\x1d\x6f\x40\x63\x1f\xd5\xb3"
- "\xec\x54\x73\xc4\x2e\x01\x76",
- 330);
- *(uint64_t*)0x200000000368 = 0x18;
- *(uint32_t*)0x200000000370 = 0;
- syscall(__NR_sendmsg, /*fd=*/(intptr_t)-1, /*msg=*/0x200000000340ul,
- /*f=*/0ul);
- break;
- }
- }
- 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;
- loop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment