// https://syzkaller.appspot.com/bug?id=0b210638616bb68109e9642158d4c0072770ae1c // 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 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[1] = {0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // openat$smackfs_ambient arguments: [ // fd: const = 0xffffffffffffff9c (8 bytes) // file: ptr[in, buffer] { // buffer: {2f 73 79 73 2f 66 73 2f 73 6d 61 63 6b 66 73 2f 61 6d 62 69 // 65 6e 74 00} (length 0x18) // } // flags: const = 0x2 (4 bytes) // mode: const = 0x0 (2 bytes) // ] // returns fd_smackfs_label memcpy((void*)0x200000000240, "/sys/fs/smackfs/ambient\000", 24); res = syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0x200000000240ul, /*flags=*/2, /*mode=*/0); if (res != -1) r[0] = res; // write$smackfs_label arguments: [ // fd: fd_smackfs_label (resource) // buf: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {62 61 74 64 85 30 09 2b b1 fb bf 47 99 90 12 f1 // e0 fe 24 41 c9 2b 4b 65 64 76 00 56 d7 a6 41 bb dd 8a 62 f9 06 00 // 1d 39 79 46 5d dd 6c 8f fd f9 d0 50 95 f6 b0 db 7d cc 6a f8 44 79 // 92 a1 dd fa c1 a4 10 ea 91 a7 13 26 bd e7 ab 64 67 83 3d 09 00 00 // 00 00 00 00 00 ae 65 96 3a 6c 3a 72 5d 37 c1 bb 39 01 00 00 04 00 // 00 00 00 b9 71 d9 f7 5f 7d fb 06 c6 8f 1c 7f fd 15 4e 8c bf 52 7c // e5 08 04 9e ab 94 ed 0b 6f 60 b1 98 eb 61 d7 0c 8a e2 21 62 c9 b0 // e5 bf 29 2e f5 13 1c ee e6 e1 70 72 05 e2 18 51 d3 20 75 d6 8a 0e // a2 c2 45 f0 00 25 e0 33 f0 b8 31 94 87 9c 8f 96 76 7b a5 87 a5 53 // a8 f7 4b c9 ef 43 3d 9f b7 8d c1 ba 72 ef 24 3f 0a 4a 1e 8f 60 81 // d5 47 91 8f 62 06 28 d4 a5 b9 84 7a 64 dd d6 ca 35 ff 05 88 c8 3e // 6c 37 e3 8a 40 86 10 fc b6 72 48 a5 d8 09 af 57 1a 51 7c 71 52 a8 // c1 4d db 3a e4 c7 52 39 c9 d9 f9 de fe 3a e4 11 f3 9a 65 91 2d 3a // 5d 90 49 a7 d8 8f 12 ed e1 cd b4 7a 09 34 a2 b6 b3 13 32 33 49 74 // c6 7d 40 07 e6 a0 ee b2 3d e5 51 d5 15 fb 88 5e 3b f1 f7 7b 8b 92 // d0 42 07 3b 99 c7 c6 17 94 69 f9 f2 8e 08 89 ad 26 4a 52 5b 42 03 // 5b 17} (length 0x15c) // } // } // } // count: len = 0x2 (8 bytes) // ] memcpy( (void*)0x2000000005c0, "\x62\x61\x74\x64\x85\x30\x09\x2b\xb1\xfb\xbf\x47\x99\x90\x12\xf1\xe0\xfe" "\x24\x41\xc9\x2b\x4b\x65\x64\x76\x00\x56\xd7\xa6\x41\xbb\xdd\x8a\x62\xf9" "\x06\x00\x1d\x39\x79\x46\x5d\xdd\x6c\x8f\xfd\xf9\xd0\x50\x95\xf6\xb0\xdb" "\x7d\xcc\x6a\xf8\x44\x79\x92\xa1\xdd\xfa\xc1\xa4\x10\xea\x91\xa7\x13\x26" "\xbd\xe7\xab\x64\x67\x83\x3d\x09\x00\x00\x00\x00\x00\x00\x00\xae\x65\x96" "\x3a\x6c\x3a\x72\x5d\x37\xc1\xbb\x39\x01\x00\x00\x04\x00\x00\x00\x00\xb9" "\x71\xd9\xf7\x5f\x7d\xfb\x06\xc6\x8f\x1c\x7f\xfd\x15\x4e\x8c\xbf\x52\x7c" "\xe5\x08\x04\x9e\xab\x94\xed\x0b\x6f\x60\xb1\x98\xeb\x61\xd7\x0c\x8a\xe2" "\x21\x62\xc9\xb0\xe5\xbf\x29\x2e\xf5\x13\x1c\xee\xe6\xe1\x70\x72\x05\xe2" "\x18\x51\xd3\x20\x75\xd6\x8a\x0e\xa2\xc2\x45\xf0\x00\x25\xe0\x33\xf0\xb8" "\x31\x94\x87\x9c\x8f\x96\x76\x7b\xa5\x87\xa5\x53\xa8\xf7\x4b\xc9\xef\x43" "\x3d\x9f\xb7\x8d\xc1\xba\x72\xef\x24\x3f\x0a\x4a\x1e\x8f\x60\x81\xd5\x47" "\x91\x8f\x62\x06\x28\xd4\xa5\xb9\x84\x7a\x64\xdd\xd6\xca\x35\xff\x05\x88" "\xc8\x3e\x6c\x37\xe3\x8a\x40\x86\x10\xfc\xb6\x72\x48\xa5\xd8\x09\xaf\x57" "\x1a\x51\x7c\x71\x52\xa8\xc1\x4d\xdb\x3a\xe4\xc7\x52\x39\xc9\xd9\xf9\xde" "\xfe\x3a\xe4\x11\xf3\x9a\x65\x91\x2d\x3a\x5d\x90\x49\xa7\xd8\x8f\x12\xed" "\xe1\xcd\xb4\x7a\x09\x34\xa2\xb6\xb3\x13\x32\x33\x49\x74\xc6\x7d\x40\x07" "\xe6\xa0\xee\xb2\x3d\xe5\x51\xd5\x15\xfb\x88\x5e\x3b\xf1\xf7\x7b\x8b\x92" "\xd0\x42\x07\x3b\x99\xc7\xc6\x17\x94\x69\xf9\xf2\x8e\x08\x89\xad\x26\x4a" "\x52\x5b\x42\x03\x5b\x17", 348); syscall(__NR_write, /*fd=*/r[0], /*buf=*/0x2000000005c0ul, /*count=*/2ul); } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffffffff000ul, /*len=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x200000000000ul, /*len=*/0x1000000, /*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=*/0x1000, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); const char* reason; (void)reason; loop(); return 0; }