// https://syzkaller.appspot.com/bug?id=9e0fa26250194542214251d5b9117dcb56603bba // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #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 bool write_file(const char* file, const char* what, ...) { char buf[1024]; va_list args; va_start(args, what); vsnprintf(buf, sizeof(buf), what, args); va_end(args); buf[sizeof(buf) - 1] = 0; int len = strlen(buf); int fd = open(file, O_WRONLY | O_CLOEXEC); if (fd == -1) return false; if (write(fd, buf, len) != len) { int err = errno; close(fd); errno = err; return false; } close(fd); return true; } static long syz_open_dev(volatile long a0, volatile long a1, volatile long a2) { if (a0 == 0xc || a0 == 0xb) { char buf[128]; sprintf(buf, "/dev/%s/%d:%d", a0 == 0xc ? "char" : "block", (uint8_t)a1, (uint8_t)a2); return open(buf, O_RDWR, 0); } else { unsigned long nb = a1; char buf[1024]; char* hash; strncpy(buf, (char*)a0, sizeof(buf) - 1); buf[sizeof(buf) - 1] = 0; while ((hash = strchr(buf, '#'))) { *hash = '0' + (char)(nb % 10); nb /= 10; } return open(buf, a2 & ~O_CREAT, 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 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; } static void kill_and_wait(int pid, int* status) { kill(-pid, SIGKILL); kill(pid, SIGKILL); for (int i = 0; i < 100; i++) { if (waitpid(-1, status, WNOHANG | __WALL) == pid) return; usleep(1000); } DIR* dir = opendir("/sys/fs/fuse/connections"); if (dir) { for (;;) { struct dirent* ent = readdir(dir); if (!ent) break; if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) continue; char abort[300]; snprintf(abort, sizeof(abort), "/sys/fs/fuse/connections/%s/abort", ent->d_name); int fd = open(abort, O_WRONLY); if (fd == -1) { continue; } if (write(fd, abort, 1) < 0) { } close(fd); } closedir(dir); } else { } while (waitpid(-1, status, __WALL) != pid) { } } static void reset_loop() { char buf[64]; snprintf(buf, sizeof(buf), "/dev/loop%llu", procid); int loopfd = open(buf, O_RDWR); if (loopfd != -1) { ioctl(loopfd, LOOP_CLR_FD, 0); close(loopfd); } } static void setup_test() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setpgrp(); write_file("/proc/self/oom_score_adj", "1000"); } static void execute_one(void); #define WAIT_FLAGS __WALL static void loop(void) { int iter = 0; for (;; iter++) { reset_loop(); int pid = fork(); if (pid < 0) exit(1); if (pid == 0) { setup_test(); execute_one(); exit(0); } int status = 0; uint64_t start = current_time_ms(); for (;;) { sleep_ms(10); if (waitpid(-1, &status, WNOHANG | WAIT_FLAGS) == pid) break; if (current_time_ms() - start < 5000) continue; kill_and_wait(pid, &status); break; } } } uint64_t r[8] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0x0, 0x0, 0x0, 0x0, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // socket$inet_udp arguments: [ // domain: const = 0x2 (8 bytes) // type: const = 0x2 (8 bytes) // proto: const = 0x0 (4 bytes) // ] // returns sock_udp res = syscall(__NR_socket, /*domain=*/2ul, /*type=*/2ul, /*proto=*/0); if (res != -1) r[0] = res; // syz_open_dev$dri arguments: [ // dev: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 64 72 69 2f 63 61 72 64 23 00} (length 0xf) // } // id: intptr = 0x1ff (8 bytes) // flags: open_flags = 0x0 (8 bytes) // ] // returns fd_dri memcpy((void*)0x2000000000c0, "/dev/dri/card#\000", 15); res = -1; res = syz_open_dev(/*dev=*/0x2000000000c0, /*id=*/0x1ff, /*flags=*/0); if (res != -1) r[1] = res; // syz_open_dev$dri arguments: [ // dev: ptr[in, buffer] { // buffer: {2f 64 65 76 2f 64 72 69 2f 63 61 72 64 23 00} (length 0xf) // } // id: intptr = 0x40100001 (8 bytes) // flags: open_flags = 0x0 (8 bytes) // ] // returns fd_dri memcpy((void*)0x200000000080, "/dev/dri/card#\000", 15); res = -1; res = syz_open_dev(/*dev=*/0x200000000080, /*id=*/0x40100001, /*flags=*/0); if (res != -1) r[2] = res; // ioctl$DRM_IOCTL_SET_CLIENT_CAP arguments: [ // fd: fd_dri (resource) // cmd: const = 0x4010640d (4 bytes) // arg: ptr[in, drm_get_cap] { // drm_get_cap { // cap: drm_cap = 0x3 (8 bytes) // val: const = 0x2 (8 bytes) // } // } // ] *(uint64_t*)0x200000000000 = 3; *(uint64_t*)0x200000000008 = 2; syscall(__NR_ioctl, /*fd=*/r[2], /*cmd=*/0x4010640d, /*arg=*/0x200000000000ul); // ioctl$DRM_IOCTL_MODE_GETPLANERESOURCES arguments: [ // fd: fd_dri (resource) // cmd: const = 0xc01064b5 (4 bytes) // arg: ptr[inout, drm_mode_get_plane_res] { // drm_mode_get_plane_res { // ids: ptr[out, array[drm_plane_id]] { // array[drm_plane_id] { // drm_plane_id (resource) // } // } // cnt: len = 0x1 (4 bytes) // pad = 0x0 (4 bytes) // } // } // ] *(uint64_t*)0x200000000140 = 0x200000000100; *(uint32_t*)0x200000000148 = 1; res = syscall(__NR_ioctl, /*fd=*/r[2], /*cmd=*/0xc01064b5, /*arg=*/0x200000000140ul); if (res != -1) r[3] = *(uint32_t*)0x200000000100; // ioctl$DRM_IOCTL_MODE_GETPLANE arguments: [ // fd: fd_dri (resource) // cmd: const = 0xc02064b6 (4 bytes) // arg: ptr[inout, drm_mode_get_plane] { // drm_mode_get_plane { // plane_id: drm_plane_id (resource) // crtc_id: drm_crtc_id (resource) // fb_id: drm_fb_id (resource) // possible_crtcs: const = 0x0 (4 bytes) // gamma_size: const = 0x0 (4 bytes) // count_format_types: len = 0x0 (4 bytes) // format_type_ptr: nil // } // } // ] *(uint32_t*)0x2000000002c0 = r[3]; *(uint32_t*)0x2000000002c4 = 0; *(uint32_t*)0x2000000002c8 = 0; *(uint32_t*)0x2000000002cc = 0; *(uint32_t*)0x2000000002d0 = 0; *(uint32_t*)0x2000000002d4 = 0; *(uint64_t*)0x2000000002d8 = 0; res = syscall(__NR_ioctl, /*fd=*/r[1], /*cmd=*/0xc02064b6, /*arg=*/0x2000000002c0ul); if (res != -1) { r[4] = *(uint32_t*)0x2000000002c4; r[5] = *(uint32_t*)0x2000000002c8; } // ioctl$DRM_IOCTL_MODE_GETRESOURCES arguments: [ // fd: fd_dri (resource) // cmd: const = 0xc04064a0 (4 bytes) // arg: ptr[inout, drm_mode_card_res] { // drm_mode_card_res { // fbid: nil // crtcid: nil // connid: ptr[out, array[drm_connector_id]] { // array[drm_connector_id] { // drm_connector_id (resource) // } // } // encid: nil // nfbid: len = 0x0 (4 bytes) // ncrtcid: len = 0x0 (4 bytes) // nconnid: len = 0x1 (4 bytes) // nencid: len = 0x0 (4 bytes) // maxw: const = 0x0 (4 bytes) // maxh: const = 0x0 (4 bytes) // minw: const = 0x0 (4 bytes) // minh: const = 0x0 (4 bytes) // } // } // ] *(uint64_t*)0x2000000006c0 = 0; *(uint64_t*)0x2000000006c8 = 0; *(uint64_t*)0x2000000006d0 = 0x200000000640; *(uint64_t*)0x2000000006d8 = 0; *(uint32_t*)0x2000000006e0 = 0; *(uint32_t*)0x2000000006e4 = 0; *(uint32_t*)0x2000000006e8 = 1; *(uint32_t*)0x2000000006ec = 0; *(uint32_t*)0x2000000006f0 = 0; *(uint32_t*)0x2000000006f4 = 0; *(uint32_t*)0x2000000006f8 = 0; *(uint32_t*)0x2000000006fc = 0; res = syscall(__NR_ioctl, /*fd=*/r[2], /*cmd=*/0xc04064a0, /*arg=*/0x2000000006c0ul); if (res != -1) r[6] = *(uint32_t*)0x200000000640; // ioctl$DRM_IOCTL_MODE_SETCRTC arguments: [ // fd: fd_dri (resource) // cmd: const = 0xc06864a2 (4 bytes) // arg: ptr[in, drm_mode_crtc$DRM_IOCTL_MODE_SETCRTC] { // drm_mode_crtc$DRM_IOCTL_MODE_SETCRTC { // set_connectors_ptr: ptr[in, array[drm_connector_id]] { // array[drm_connector_id] { // drm_connector_id (resource) // } // } // count_connectors: len = 0x1 (4 bytes) // crtc_id: drm_crtc_id (resource) // fb_id: drm_fb_id (resource) // x: int32 = 0x3 (4 bytes) // y: int32 = 0x0 (4 bytes) // gamma_size: int32 = 0x2 (4 bytes) // mode_valid: int32 = 0x802 (4 bytes) // mode: drm_mode_modeinfo { // clock: int32 = 0xac7c (4 bytes) // hdisplay: int16 = 0x1 (2 bytes) // hsync_start: int16 = 0x7 (2 bytes) // hsync_end: int16 = 0x69 (2 bytes) // htotal: int16 = 0xf4b (2 bytes) // hskew: int16 = 0x2 (2 bytes) // vdisplay: int16 = 0x2 (2 bytes) // vsync_start: int16 = 0x45 (2 bytes) // vsync_end: int16 = 0x412f (2 bytes) // vtotal: int16 = 0xe150 (2 bytes) // vscan: int16 = 0x1000 (2 bytes) // vrefresh: int32 = 0x7 (4 bytes) // flags: int32 = 0xb2bf (4 bytes) // type: int32 = 0x3 (4 bytes) // name: buffer: {fe 1d 00 00 34 13 00 00 00 00 00 00 00 0c aa 00 00 // 00 09 00 00 00 00 00 00 00 04 b4 27 18 00 10} (length 0x20) // } // } // } // ] *(uint64_t*)0x2000000011c0 = 0x200000001180; *(uint32_t*)0x200000001180 = r[6]; *(uint32_t*)0x2000000011c8 = 1; *(uint32_t*)0x2000000011cc = r[4]; *(uint32_t*)0x2000000011d0 = r[5]; *(uint32_t*)0x2000000011d4 = 3; *(uint32_t*)0x2000000011d8 = 0; *(uint32_t*)0x2000000011dc = 2; *(uint32_t*)0x2000000011e0 = 0x802; *(uint32_t*)0x2000000011e4 = 0xac7c; *(uint16_t*)0x2000000011e8 = 1; *(uint16_t*)0x2000000011ea = 7; *(uint16_t*)0x2000000011ec = 0x69; *(uint16_t*)0x2000000011ee = 0xf4b; *(uint16_t*)0x2000000011f0 = 2; *(uint16_t*)0x2000000011f2 = 2; *(uint16_t*)0x2000000011f4 = 0x45; *(uint16_t*)0x2000000011f6 = 0x412f; *(uint16_t*)0x2000000011f8 = 0xe150; *(uint16_t*)0x2000000011fa = 0x1000; *(uint32_t*)0x2000000011fc = 7; *(uint32_t*)0x200000001200 = 0xb2bf; *(uint32_t*)0x200000001204 = 3; memcpy((void*)0x200000001208, "\xfe\x1d\x00\x00\x34\x13\x00\x00\x00\x00\x00\x00\x00\x0c\xaa\x00\x00" "\x00\x09\x00\x00\x00\x00\x00\x00\x00\x04\xb4\x27\x18\x00\x10", 32); syscall(__NR_ioctl, /*fd=*/r[1], /*cmd=*/0xc06864a2, /*arg=*/0x2000000011c0ul); // ioctl$DRM_IOCTL_WAIT_VBLANK arguments: [ // fd: fd_dri (resource) // cmd: const = 0xc018643a (4 bytes) // arg: nil // ] syscall(__NR_ioctl, /*fd=*/r[1], /*cmd=*/0xc018643a, /*arg=*/0ul); // openat$fuse arguments: [ // fd: const = 0xffffffffffffff9c (8 bytes) // file: nil // flags: const = 0x2 (4 bytes) // mode: const = 0x0 (2 bytes) // ] // returns fd_fuse res = syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0ul, /*flags=*/2, /*mode=*/0); if (res != -1) r[7] = res; // mount$fuse arguments: [ // src: const = 0x0 (8 bytes) // dst: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 30 00} (length 0x8) // } // type: nil // flags: mount_flags = 0x80 (8 bytes) // opts: ptr[in, fuse_options] { // fuse_options { // fd: fs_opt["fd", fmt[hex, fd_fuse]] { // name: buffer: {66 64} (length 0x2) // eq: const = 0x3d (1 bytes) // val: fd_fuse (resource) // } // comma0: const = 0x2c (1 bytes) // rootmode: fs_opt["rootmode", fmt[oct, flags[fuse_mode]]] { // name: buffer: {72 6f 6f 74 6d 6f 64 65} (length 0x8) // eq: const = 0x3d (1 bytes) // val: fuse_mode = 0x4000 (23 bytes) // } // comma1: const = 0x2c (1 bytes) // user_id: fs_opt["user_id", fmt[dec, uid]] { // name: buffer: {75 73 65 72 5f 69 64} (length 0x7) // eq: const = 0x3d (1 bytes) // val: uid (resource) // } // comma2: const = 0x2c (1 bytes) // group_id: fs_opt["group_id", fmt[dec, gid]] { // name: buffer: {67 72 6f 75 70 5f 69 64} (length 0x8) // eq: const = 0x3d (1 bytes) // val: gid (resource) // } // comma3: const = 0x2c (1 bytes) // opts: fs_options[fuse_opts] { // elems: array[fs_opt_elem[fuse_opts]] { // } // common: array[fs_opt_elem[fs_options_common]] { // } // null: const = 0x0 (1 bytes) // } // } // } // ] memcpy((void*)0x2000000001c0, "./file0\000", 8); memcpy((void*)0x2000000002c0, "fd", 2); *(uint8_t*)0x2000000002c2 = 0x3d; sprintf((char*)0x2000000002c3, "0x%016llx", (long long)r[7]); *(uint8_t*)0x2000000002d5 = 0x2c; memcpy((void*)0x2000000002d6, "rootmode", 8); *(uint8_t*)0x2000000002de = 0x3d; sprintf((char*)0x2000000002df, "%023llo", (long long)0x4000); *(uint8_t*)0x2000000002f6 = 0x2c; memcpy((void*)0x2000000002f7, "user_id", 7); *(uint8_t*)0x2000000002fe = 0x3d; sprintf((char*)0x2000000002ff, "%020llu", (long long)0); *(uint8_t*)0x200000000313 = 0x2c; memcpy((void*)0x200000000314, "group_id", 8); *(uint8_t*)0x20000000031c = 0x3d; sprintf((char*)0x20000000031d, "%020llu", (long long)0); *(uint8_t*)0x200000000331 = 0x2c; *(uint8_t*)0x200000000332 = 0; syscall(__NR_mount, /*src=*/0ul, /*dst=*/0x2000000001c0ul, /*type=*/0ul, /*flags=MS_DIRSYNC*/ 0x80ul, /*opts=*/0x2000000002c0ul); // syz_mount_image$ext4 arguments: [ // fs: ptr[in, buffer] { // buffer: {65 78 74 34 00} (length 0x5) // } // dir: ptr[in, buffer] { // buffer: {2e 2f 66 69 6c 65 31 2f 66 69 6c 65 30 00} (length 0xe) // } // flags: mount_flags = 0x408e (8 bytes) // opts: ptr[in, fs_options[ext4_options]] { // fs_options[ext4_options] { // elems: array[fs_opt_elem[ext4_options]] { // } // common: array[fs_opt_elem[fs_options_common]] { // fs_opt_elem[fs_options_common] { // elem: union fs_options_common { // smackfsfloor: fs_opt["smackfsfloor", stringnoz] { // name: buffer: {73 6d 61 63 6b 66 73 66 6c 6f 6f 72} (length // 0xc) eq: const = 0x3d (1 bytes) val: buffer: {} (length 0x0) // } // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[fs_options_common] { // elem: union fs_options_common { // euid_eq: fs_opt["euid", fmt[dec, uid]] { // name: buffer: {65 75 69 64} (length 0x4) // eq: const = 0x3d (1 bytes) // val: uid (resource) // } // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[fs_options_common] { // elem: union fs_options_common { // euid_eq: fs_opt["euid", fmt[dec, uid]] { // name: buffer: {65 75 69 64} (length 0x4) // eq: const = 0x3d (1 bytes) // val: uid (resource) // } // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[fs_options_common] { // elem: union fs_options_common { // euid_eq: fs_opt["euid", fmt[dec, uid]] { // name: buffer: {65 75 69 64} (length 0x4) // eq: const = 0x3d (1 bytes) // val: uid (resource) // } // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[fs_options_common] { // elem: union fs_options_common { // subj_type: fs_opt["subj_type", stringnoz] { // name: buffer: {73 75 62 6a 5f 74 79 70 65} (length 0x9) // eq: const = 0x3d (1 bytes) // val: buffer: {65 78 74 34 00} (length 0x5) // } // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[fs_options_common] { // elem: union fs_options_common { // smackfstransmute: fs_opt["smackfstransmute", stringnoz] { // name: buffer: {73 6d 61 63 6b 66 73 74 72 61 6e 73 6d 75 74 // 65} (length 0x10) eq: const = 0x3d (1 bytes) val: buffer: // {25 7b} (length 0x2) // } // } // comma: const = 0x2c (1 bytes) // } // fs_opt_elem[fs_options_common] { // elem: union fs_options_common { // fowner_gt: fs_opt_nodelim["fowner>", fmt[dec, uid]] { // name: buffer: {66 6f 77 6e 65 72 3e} (length 0x7) // val: uid (resource) // } // } // comma: const = 0x2c (1 bytes) // } // } // null: const = 0x0 (1 bytes) // } // } // chdir: int8 = 0x3 (1 bytes) // size: len = 0x43a (8 bytes) // img: ptr[in, buffer] { // buffer: (compressed buffer with length 0x43a) // } // ] // returns fd_dir memcpy((void*)0x200000000040, "ext4\000", 5); memcpy((void*)0x200000000300, "./file1/file0\000", 14); memcpy((void*)0x2000000007c0, "smackfsfloor", 12); *(uint8_t*)0x2000000007cc = 0x3d; *(uint8_t*)0x2000000007cd = 0x2c; memcpy((void*)0x2000000007ce, "euid", 4); *(uint8_t*)0x2000000007d2 = 0x3d; sprintf((char*)0x2000000007d3, "%020llu", (long long)0); *(uint8_t*)0x2000000007e7 = 0x2c; memcpy((void*)0x2000000007e8, "euid", 4); *(uint8_t*)0x2000000007ec = 0x3d; sprintf((char*)0x2000000007ed, "%020llu", (long long)0); *(uint8_t*)0x200000000801 = 0x2c; memcpy((void*)0x200000000802, "euid", 4); *(uint8_t*)0x200000000806 = 0x3d; sprintf((char*)0x200000000807, "%020llu", (long long)0); *(uint8_t*)0x20000000081b = 0x2c; memcpy((void*)0x20000000081c, "subj_type", 9); *(uint8_t*)0x200000000825 = 0x3d; memcpy((void*)0x200000000826, "ext4\000", 5); *(uint8_t*)0x20000000082b = 0x2c; memcpy((void*)0x20000000082c, "smackfstransmute", 16); *(uint8_t*)0x20000000083c = 0x3d; memcpy((void*)0x20000000083d, "%{", 2); *(uint8_t*)0x20000000083f = 0x2c; memcpy((void*)0x200000000840, "fowner>", 7); sprintf((char*)0x200000000847, "%020llu", (long long)0); *(uint8_t*)0x20000000085b = 0x2c; *(uint8_t*)0x20000000085c = 0; memcpy( (void*)0x200000000340, "\x78\x9c\xec\xdb\xcb\x6f\x1b\x45\x18\x00\xf0\x6f\xd7\x71\x4a\x5f\x24\x94" "\xf2\xe8\x03\x08\x14\x44\xc4\x23\x69\xd2\x02\x3d\x70\x01\x81\xc4\x01\x24" "\x24\x38\x94\x63\x48\xd2\xaa\xd4\x6d\x50\x13\x24\x5a\x55\x10\x10\x2a\x47" "\x54\x89\x3b\xe2\x88\xc4\x5f\xc0\x09\x2e\x08\x38\x21\x71\x85\x3b\xaa\x54" "\xa1\x5c\x5a\x38\x19\xad\xbd\x9b\x38\x8e\x9d\x26\xc1\x8e\x4b\xfd\xfb\x49" "\x9b\xcc\xec\x8e\x33\xf3\x79\x76\xec\xd9\x9d\x6c\x00\x7d\x6b\x24\xfb\x91" "\x44\xec\x89\x88\xdf\x23\x62\xa8\x9e\x5d\x5d\x60\xa4\xfe\xeb\xe6\xd2\xe5" "\xe9\xbf\x97\x2e\x4f\x27\x51\xad\xbe\xf5\x57\x52\x2b\x77\x63\xe9\xf2\x74" "\x51\xb4\x78\xdd\xee\x3c\x33\x9a\x46\xa4\x9f\x25\x71\xa8\x45\xbd\xf3\x17" "\x2f\x9d\x9d\xaa\x54\x66\x2f\xe4\xf9\xf1\x85\x73\xef\x8f\xcf\x5f\xbc\xf4" "\xec\x99\x73\x53\xa7\x67\x4f\xcf\x9e\x9f\x3c\x71\xe2\xf8\xb1\x89\x17\x9e" "\x9f\x7c\xae\x23\x71\x66\x6d\xba\x71\xf0\xa3\xb9\xc3\x07\x5e\x7b\xe7\xea" "\x1b\xd3\x27\xaf\xbe\xfb\xf3\xb7\x49\x11\x7f\x53\x1c\x1d\x32\xb2\xde\xc1" "\x27\xaa\xd5\x0e\x57\xd7\x5b\x7b\x1b\xd2\xc9\x40\x0f\x1b\xc2\xa6\x94\x22" "\x22\xeb\xae\x72\x6d\xfc\x0f\x45\x29\x56\x3a\x6f\x28\x5e\xfd\xb4\xa7\x8d" "\x03\xba\xaa\x5a\xad\x56\x77\xb7\x3f\xbc\x58\x05\xee\x60\x49\x6c\xb4\xe4" "\xd9\xfc\xf3\x02\xb8\x33\x14\x5f\xf4\xd9\xf5\x6f\xb1\x6d\xd3\xd4\xe3\xb6" "\x70\xfd\xa5\xfa\x05\x50\x16\xf7\xcd\x7c\xab\x1f\x19\x88\x34\x2f\x53\x6e" "\xba\xbe\xed\xa4\x91\x88\x38\xb9\xf8\xcf\x57\xd9\x16\xdd\xb9\x0f\x01\x00" "\xb0\xca\xf7\xd9\xfc\xe7\x99\x56\xf3\xbf\x34\xee\x6f\x28\x77\x77\xbe\x36" "\x34\x1c\x11\xf7\x44\xc4\xbe\x88\xb8\x37\x22\xf6\x47\xc4\x7d\x11\xb5\xb2" "\x0f\x44\xc4\x83\x9b\xac\xbf\x79\x91\x64\xed\xfc\x27\xbd\xb6\xa5\xc0\x36" "\x28\x9b\xff\xbd\x98\xaf\x6d\xad\x9e\xff\x15\xb3\xbf\x18\x2e\xe5\xb9\xbd" "\xb5\xf8\xcb\xc9\xa9\x33\x95\xd9\xa3\xf9\x7b\x32\x1a\xe5\x1d\x59\x7e\x62" "\x9d\x3a\x7e\x78\xe5\xb7\x2f\xda\x1d\x6b\x9c\xff\x65\x5b\x56\x7f\x31\x17" "\xcc\xdb\x71\x6d\x60\xc7\xea\xd7\xcc\x4c\x2d\x4c\xfd\x97\x98\x1b\x5d\xff" "\x24\xe2\xe0\x40\xab\xf8\x93\xe5\x95\x80\x24\x22\x0e\x44\xc4\xc1\x2d\xd6" "\x71\xe6\xa9\x6f\x0e\xb7\x3b\xd6\x2e\xfe\xf2\x46\xfe\x70\x07\xd6\x99\xaa" "\x5f\x47\x3c\x59\xef\xff\xc5\x68\x8a\xbf\x90\xac\xbf\x3e\x39\x7e\x57\x54" "\x66\x8f\x8e\x17\x67\xc5\x5a\xbf\xfc\x7a\xe5\xcd\x76\xf5\xdf\xba\xff\xbb" "\x2b\xeb\xff\x5d\x2d\xcf\xff\xe5\xf8\x87\x93\xc6\xf5\xda\xf9\xcd\xd7\x71" "\xe5\x8f\xcf\xdb\x5e\xd3\x6c\xf5\xfc\x1f\x4c\xde\xae\xa5\x07\xf3\x7d\x1f" "\x4e\x2d\x2c\x5c\x98\x88\x18\x4c\x5e\xaf\x37\xba\x71\xff\xe4\xca\x6b\x8b" "\x7c\x51\x3e\x8b\x7f\xf4\x48\xeb\xf1\xbf\x2f\x56\xde\x89\x43\x11\x91\x9d" "\xc4\x0f\x45\xc4\xc3\x11\xf1\x48\xde\xf6\x47\x23\xe2\xb1\x88\x38\xb2\x4e" "\xfc\x3f\xbd\xfc\xf8\x7b\x5b\x8f\xbf\xbb\xb2\xf8\x67\x36\xd5\xff\x2b\x89" "\xc1\x68\xde\xd3\x3a\x51\x3a\xfb\xe3\x77\xab\x2a\x1d\xde\x4c\xfc\x59\xff" "\x1f\xaf\xa5\x46\xf3\x3d\x1b\xf9\xfc\xdb\x48\xbb\xb6\x76\x36\x03\x00\x00" "\xc0\xff\x4f\x1a\x11\x7b\x22\x49\xc7\x96\xd3\x69\x3a\x36\x56\xff\x7f\xf9" "\xfd\xb1\x2b\xad\xcc\xcd\x2f\x3c\x7d\x6a\xee\x83\xf3\x33\xf5\x67\x04\x86" "\xa3\x9c\x16\x77\xba\x86\x1a\xee\x87\x4e\xe4\x97\xf5\x45\x7e\xb2\x29\x7f" "\x2c\xbf\x6f\xfc\x65\x69\x67\x2d\x3f\x36\x3d\x57\x99\xe9\x75\xf0\xd0\xe7" "\x76\xb7\x19\xff\x99\x3f\x4b\xbd\x6e\x1d\xd0\x75\x9e\xd7\x82\xfe\x65\xfc" "\x43\xff\x32\xfe\xa1\x7f\x19\xff\xd0\xbf\x5a\x8c\xff\x9d\xbd\x68\x07\xb0" "\xfd\x5a\x7d\xff\x7f\xdc\x83\x76\x00\xdb\xaf\x69\xfc\x5b\xf6\x83\x3e\xe2" "\xfa\x1f\xfa\x97\xf1\x0f\xfd\xcb\xf8\x87\xbe\x34\xbf\x33\x6e\xfd\x90\xbc" "\x84\xc4\x9a\x44\xa4\xb7\x45\x33\x24\xba\x94\xe8\xf5\x27\x13\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x40\x67\xfc\x1b\x00\x00\xff\xff\xd1\x3d" "\xe3\x43", 1082); syz_mount_image(/*fs=*/0x200000000040, /*dir=*/0x200000000300, /*flags=MS_REC|MS_NOSUID|MS_NOEXEC|MS_NODEV|0x80*/ 0x408e, /*opts=*/0x2000000007c0, /*chdir=*/3, /*size=*/0x43a, /*img=*/0x200000000340); // sendmmsg arguments: [ // fd: sock (resource) // mmsg: nil // vlen: len = 0x0 (8 bytes) // f: send_flags = 0x300 (8 bytes) // ] syscall(__NR_sendmmsg, /*fd=*/r[0], /*mmsg=*/0ul, /*vlen=*/0ul, /*f=*/0x300ul); } 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; for (procid = 0; procid < 5; procid++) { if (fork() == 0) { loop(); } } sleep(1000000); return 0; }