// https://syzkaller.appspot.com/bug?id=8a78b195ac2457a889b34d63ff834ec3fb5f8fe0 // 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 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 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 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++) { 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[4] = {0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // mmap arguments: [ // addr: VMA[0x95c000] // len: len = 0x95c000 (8 bytes) // prot: mmap_prot = 0x200000b (8 bytes) // flags: mmap_flags = 0x8c4b815a5465c2b2 (8 bytes) // fd: fd (resource) // offset: intptr = 0x0 (8 bytes) // ] syscall( __NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x95c000ul, /*prot=PROT_GROWSUP|PROT_SEM|PROT_WRITE|PROT_READ*/ 0x200000bul, /*flags=MAP_UNINITIALIZED|MAP_POPULATE|MAP_NORESERVE|MAP_NONBLOCK|MAP_HUGETLB|0x8c4b815a506002b2*/ 0x8c4b815a5465c2b2ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); // socket$alg arguments: [ // domain: const = 0x26 (8 bytes) // type: const = 0x5 (8 bytes) // proto: const = 0x0 (4 bytes) // ] // returns sock_alg res = syscall(__NR_socket, /*domain=*/0x26ul, /*type=*/5ul, /*proto=*/0); if (res != -1) r[0] = res; // bind$alg arguments: [ // fd: sock_alg (resource) // addr: ptr[in, sockaddr_alg] { // sockaddr_alg { // family: const = 0x26 (2 bytes) // type: buffer: {68 61 73 68 00 00 00 00 00 00 00 00 00 00} (length // 0xe) feat: af_alg_type = 0x0 (4 bytes) mask: af_alg_type = 0x0 (4 // bytes) name: buffer: {73 68 61 35 31 32 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00} (length 0x40) // } // } // addrlen: len = 0x58 (8 bytes) // ] *(uint16_t*)0x200000000000 = 0x26; memcpy((void*)0x200000000002, "hash\000\000\000\000\000\000\000\000\000\000", 14); *(uint32_t*)0x200000000010 = 0; *(uint32_t*)0x200000000014 = 0; memcpy((void*)0x200000000018, "sha512\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000", 64); syscall(__NR_bind, /*fd=*/r[0], /*addr=*/0x200000000000ul, /*addrlen=*/0x58ul); // accept4 arguments: [ // fd: sock (resource) // peer: nil // peerlen: nil // flags: accept_flags = 0x800 (8 bytes) // ] // returns sock res = syscall(__NR_accept4, /*fd=*/r[0], /*peer=*/0ul, /*peerlen=*/0ul, /*flags=SOCK_NONBLOCK*/ 0x800ul); if (res != -1) r[1] = res; // sendmmsg$alg arguments: [ // fd: sock_algconn (resource) // mmsg: ptr[in, array[msghdr_alg]] { // array[msghdr_alg] { // msghdr_alg { // addr: const = 0x0 (8 bytes) // addrlen: const = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // vec: ptr[in, array[iovec[in, array[int8]]]] { // array[iovec[in, array[int8]]] { // iovec[in, array[int8]] { // addr: ptr[in, buffer] { // buffer: {b5 75 23 cb 1a 2c 90 d8 ac ad 2e 2d 98 df c9 ea // 7a 58 43 c3 b6 3b 68 3c ed 2b 32 66 17 55 99 b7 79 61 7e // 66 e6 b3 e1 5c 04 2b e9 06 35 a2 d3 61 60 bb f9 a2 ed ca // cc 0b be 01 5b 84 15 0a 19 28 de 94 39 78 94 ff 36 aa 43 // 0f c2 a0 81 4b a6 34 30 8d 6d 08 37 25 0d fd 1e ca 53 83 // f9 d1 51 44 97 43 b1 a0 c4 ff c5 12 42 a2 29 c5 d6 d0 6f // 14 7a 61 d7 97 ea 7f fe da 95 b7 6f 56 23} (length 0x7d) // } // len: len = 0x7d (8 bytes) // } // iovec[in, array[int8]] { // addr: ptr[in, buffer] { // buffer: {66 f7} (length 0x2) // } // len: len = 0x3 (8 bytes) // } // iovec[in, array[int8]] { // addr: ptr[in, buffer] { // buffer: {6c 33} (length 0x2) // } // len: len = 0x7fffef80 (8 bytes) // } // } // } // vlen: len = 0x3 (8 bytes) // ctrl: nil // ctrllen: bytesize = 0x0 (8 bytes) // f: send_flags = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // } // } // } // vlen: len = 0x1 (8 bytes) // f: send_flags = 0x0 (8 bytes) // ] *(uint64_t*)0x200000000640 = 0; *(uint32_t*)0x200000000648 = 0; *(uint64_t*)0x200000000650 = 0x200000000380; *(uint64_t*)0x200000000380 = 0x200000000140; memcpy( (void*)0x200000000140, "\xb5\x75\x23\xcb\x1a\x2c\x90\xd8\xac\xad\x2e\x2d\x98\xdf\xc9\xea\x7a\x58" "\x43\xc3\xb6\x3b\x68\x3c\xed\x2b\x32\x66\x17\x55\x99\xb7\x79\x61\x7e\x66" "\xe6\xb3\xe1\x5c\x04\x2b\xe9\x06\x35\xa2\xd3\x61\x60\xbb\xf9\xa2\xed\xca" "\xcc\x0b\xbe\x01\x5b\x84\x15\x0a\x19\x28\xde\x94\x39\x78\x94\xff\x36\xaa" "\x43\x0f\xc2\xa0\x81\x4b\xa6\x34\x30\x8d\x6d\x08\x37\x25\x0d\xfd\x1e\xca" "\x53\x83\xf9\xd1\x51\x44\x97\x43\xb1\xa0\xc4\xff\xc5\x12\x42\xa2\x29\xc5" "\xd6\xd0\x6f\x14\x7a\x61\xd7\x97\xea\x7f\xfe\xda\x95\xb7\x6f\x56\x23", 125); *(uint64_t*)0x200000000388 = 0x7d; *(uint64_t*)0x200000000390 = 0x2000000001c0; memcpy((void*)0x2000000001c0, "\x66\xf7", 2); *(uint64_t*)0x200000000398 = 3; *(uint64_t*)0x2000000003a0 = 0x200000000300; memcpy((void*)0x200000000300, "l3", 2); *(uint64_t*)0x2000000003a8 = 0x7fffef80; *(uint64_t*)0x200000000658 = 3; *(uint64_t*)0x200000000660 = 0; *(uint64_t*)0x200000000668 = 0; *(uint32_t*)0x200000000670 = 0; syscall(__NR_sendmmsg, /*fd=*/r[1], /*mmsg=*/0x200000000640ul, /*vlen=*/1ul, /*f=*/0ul); // socket$alg arguments: [ // domain: const = 0x26 (8 bytes) // type: const = 0x5 (8 bytes) // proto: const = 0x0 (4 bytes) // ] // returns sock_alg res = syscall(__NR_socket, /*domain=*/0x26ul, /*type=*/5ul, /*proto=*/0); if (res != -1) r[2] = res; // bind$alg arguments: [ // fd: sock_alg (resource) // addr: ptr[in, sockaddr_alg] { // sockaddr_alg { // family: const = 0x26 (2 bytes) // type: buffer: {68 61 73 68 00 00 00 00 00 00 00 00 00 00} (length // 0xe) feat: af_alg_type = 0x0 (4 bytes) mask: af_alg_type = 0x0 (4 // bytes) name: buffer: {6e 68 70 6f 6c 79 31 33 30 35 2d 73 73 65 32 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00} (length 0x40) // } // } // addrlen: len = 0x58 (8 bytes) // ] *(uint16_t*)0x200000000480 = 0x26; memcpy((void*)0x200000000482, "hash\000\000\000\000\000\000\000\000\000\000", 14); *(uint32_t*)0x200000000490 = 0; *(uint32_t*)0x200000000494 = 0; memcpy((void*)0x200000000498, "nhpoly1305-" "sse2\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000" "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000", 64); syscall(__NR_bind, /*fd=*/r[2], /*addr=*/0x200000000480ul, /*addrlen=*/0x58ul); // setsockopt$ALG_SET_KEY arguments: [ // fd: sock_alg (resource) // level: const = 0x117 (4 bytes) // opt: const = 0x1 (4 bytes) // key: ptr[in, buffer] { // buffer: {8a} (length 0x1) // } // keylen: len = 0x440 (8 bytes) // ] memset((void*)0x200000000000, 138, 1); syscall(__NR_setsockopt, /*fd=*/r[2], /*level=*/0x117, /*opt=*/1, /*key=*/0x200000000000ul, /*keylen=*/0x440ul); // accept4 arguments: [ // fd: sock (resource) // peer: nil // peerlen: nil // flags: accept_flags = 0x0 (8 bytes) // ] // returns sock res = syscall(__NR_accept4, /*fd=*/r[2], /*peer=*/0ul, /*peerlen=*/0ul, /*flags=*/0ul); if (res != -1) r[3] = res; // sendmmsg$alg arguments: [ // fd: sock_algconn (resource) // mmsg: ptr[in, array[msghdr_alg]] { // array[msghdr_alg] { // msghdr_alg { // addr: const = 0x0 (8 bytes) // addrlen: const = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // vec: ptr[in, array[iovec[in, array[int8]]]] { // array[iovec[in, array[int8]]] { // iovec[in, array[int8]] { // addr: ptr[in, buffer] { // buffer: {14} (length 0x1) // } // len: len = 0x1 (8 bytes) // } // iovec[in, array[int8]] { // addr: ptr[in, buffer] { // buffer: {3b 94 2c df 3d bb 4d 70 84 46 20 9c 8a 7a 98 93 // c7 11 16 7b 6a ee 1a c4 a8 cc 59 d9 2a 39 4f 46 0b 20 f2 // 1b 9a dd 9e 84 d2 db a9 e6 df 80 34 c4 49 e6 41 38 a4 ae // a2 a8 df 6d 35 03 1b d3 26 3f} (length 0x40) // } // len: len = 0x7fffefff (8 bytes) // } // } // } // vlen: len = 0x2 (8 bytes) // ctrl: nil // ctrllen: bytesize = 0x0 (8 bytes) // f: send_flags = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // } // } // } // vlen: len = 0x1 (8 bytes) // f: send_flags = 0x0 (8 bytes) // ] *(uint64_t*)0x200000004140 = 0; *(uint32_t*)0x200000004148 = 0; *(uint64_t*)0x200000004150 = 0x200000000600; *(uint64_t*)0x200000000600 = 0x2000000001c0; memset((void*)0x2000000001c0, 20, 1); *(uint64_t*)0x200000000608 = 1; *(uint64_t*)0x200000000610 = 0x200000000280; memcpy((void*)0x200000000280, "\x3b\x94\x2c\xdf\x3d\xbb\x4d\x70\x84\x46\x20\x9c\x8a\x7a\x98\x93\xc7" "\x11\x16\x7b\x6a\xee\x1a\xc4\xa8\xcc\x59\xd9\x2a\x39\x4f\x46\x0b\x20" "\xf2\x1b\x9a\xdd\x9e\x84\xd2\xdb\xa9\xe6\xdf\x80\x34\xc4\x49\xe6\x41" "\x38\xa4\xae\xa2\xa8\xdf\x6d\x35\x03\x1b\xd3\x26\x3f", 64); *(uint64_t*)0x200000000618 = 0x7fffefff; *(uint64_t*)0x200000004158 = 2; *(uint64_t*)0x200000004160 = 0; *(uint64_t*)0x200000004168 = 0; *(uint32_t*)0x200000004170 = 0; syscall(__NR_sendmmsg, /*fd=*/r[3], /*mmsg=*/0x200000004140ul, /*vlen=*/1ul, /*f=*/0ul); } 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; }