// https://syzkaller.appspot.com/bug?id=9d5401918f3bee146505d56912b0c57dbc0743d9 // 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 #ifndef __NR_bpf #define __NR_bpf 321 #endif 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; } } } void execute_one(void) { if (write(1, "executing program\n", sizeof("executing program\n") - 1)) { } // bpf$BPF_PROG_RAW_TRACEPOINT_LOAD arguments: [ // cmd: const = 0x5 (8 bytes) // arg: ptr[in, bpf_prog_t[flags[bpf_raw_tracepoint_prog_types, int32], // const[0, int32], const[0, int32], const[0, int32]]] { // bpf_prog_t[flags[bpf_raw_tracepoint_prog_types, int32], const[0, // int32], const[0, int32], const[0, int32]] { // type: bpf_raw_tracepoint_prog_types = 0x11 (4 bytes) // ninsn: bytesize8 = 0x12 (4 bytes) // insns: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {18 08 00 00 d0 ff 00 00 00 00 00 00 00 85 10 // 00 01 06 00 00 00 18 00 00 00 00 00 00 cb f3 b7 d3 ef 96 fc ee // f0 4c 03 20 99 79 7d 6a c9 c5 8b 72 64 c9 0f 17 d8 f8 5e c1 ed // 05 60 84 44 8b 5a 0f a4 0a ea 79 30 89 22 64 db 85 d1 7b 01 73 // 11 fd af d2 23 82 65 e0 fe 4c 40 5f 47 ee 8d 43 0a 29 13 bf d7 // 59 13 aa d4 ed 1d 82 3a 99 4c 87 3d 10 ce cd 22 8c 42 05 53 e2 // 29 66 ab b7 92 ab a9 25 3d 26 68 5b 99 32 0c 0a 73 19 44 72 a1 // 78 f8 43 dc 1f a0 92 36 de d9 7b 32 20 81 71 81 06 24 14 64 b2 // ff af 6a ca 02 6d 00 00 00 00 00 e9 b8 fa 25 6b 2d c8 a1 5e 26 // 32 48 cc ce f5 7e f1 0d c7 47 62 5e e3 21 92 fd a0 2b f6 6f ff // bb 1d d9 03 00 28 97 23 d4 a5 5e ea c2 d7 dd 3f d6 40 f3 a5 d5 // 2a a1 08 52 92 9b 4b 0d 1b 48 7c d4 22 a2 5a f7 60 94 18 b1 ad // c2 d9 28 cd 9c a7 e2 3c b5 c6 ee a4 34 69 65 e8 f8 4f bc 8d bf // 0d 35 88 0b bc 8f a7 23 cd c6 87 64 7d 7d 6f 22 14 17 ae 92 0b // 02 54 15 7b 55 6e b8 20 69 87 de c7 58 13 e0 e4} (length // 0x130) // } // union ANYUNION { // ANYRES32: ANYRES32 (resource) // } // union ANYUNION { // ANYBLOB: buffer: {} (length 0x0) // } // } // } // license: ptr[in, buffer] { // buffer: {47 50 4c 00} (length 0x4) // } // loglev: int32 = 0x2 (4 bytes) // logsize: len = 0x0 (4 bytes) // log: nil // kern_version: bpf_kern_version = 0x0 (4 bytes) // flags: bpf_prog_load_flags = 0xc (4 bytes) // prog_name: buffer: {00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00} // (length 0x10) prog_ifindex: ifindex (resource) expected_attach_type: // const = 0x0 (4 bytes) btf_fd: fd_btf (resource) func_info_rec_size: // const = 0x8 (4 bytes) func_info: nil func_info_cnt: len = 0x0 (4 // bytes) line_info_rec_size: const = 0x10 (4 bytes) line_info: nil // line_info_cnt: len = 0x0 (4 bytes) // attach_btf_id: const = 0x0 (4 bytes) // attach_prog_fd: const = 0x0 (4 bytes) // core_relo_cnt: len = 0x0 (4 bytes) // fd_array: nil // core_relos: nil // core_relo_rec_size: const = 0x10 (4 bytes) // log_true_size: int32 = 0x0 (4 bytes) // prog_token_fd: union // _bpf_prog_t[flags[bpf_raw_tracepoint_prog_types, int32], const[0, // int32], const[0, int32], const[0, int32]]_prog_token_fd_wrapper { // void: buffer: {} (length 0x0) // } // pad: union _bpf_prog_t[flags[bpf_raw_tracepoint_prog_types, int32], // const[0, int32], const[0, int32], const[0, int32]]_pad_wrapper { // value: const = 0x0 (4 bytes) // } // } // } // size: len = 0x94 (8 bytes) // ] // returns fd_bpf_prog_raw_tracepoint *(uint32_t*)0x200000000440 = 0x11; *(uint32_t*)0x200000000444 = 0x12; *(uint64_t*)0x200000000448 = 0x200000000140; memcpy( (void*)0x200000000140, "\x18\x08\x00\x00\xd0\xff\x00\x00\x00\x00\x00\x00\x00\x85\x10\x00\x01\x06" "\x00\x00\x00\x18\x00\x00\x00\x00\x00\x00\xcb\xf3\xb7\xd3\xef\x96\xfc\xee" "\xf0\x4c\x03\x20\x99\x79\x7d\x6a\xc9\xc5\x8b\x72\x64\xc9\x0f\x17\xd8\xf8" "\x5e\xc1\xed\x05\x60\x84\x44\x8b\x5a\x0f\xa4\x0a\xea\x79\x30\x89\x22\x64" "\xdb\x85\xd1\x7b\x01\x73\x11\xfd\xaf\xd2\x23\x82\x65\xe0\xfe\x4c\x40\x5f" "\x47\xee\x8d\x43\x0a\x29\x13\xbf\xd7\x59\x13\xaa\xd4\xed\x1d\x82\x3a\x99" "\x4c\x87\x3d\x10\xce\xcd\x22\x8c\x42\x05\x53\xe2\x29\x66\xab\xb7\x92\xab" "\xa9\x25\x3d\x26\x68\x5b\x99\x32\x0c\x0a\x73\x19\x44\x72\xa1\x78\xf8\x43" "\xdc\x1f\xa0\x92\x36\xde\xd9\x7b\x32\x20\x81\x71\x81\x06\x24\x14\x64\xb2" "\xff\xaf\x6a\xca\x02\x6d\x00\x00\x00\x00\x00\xe9\xb8\xfa\x25\x6b\x2d\xc8" "\xa1\x5e\x26\x32\x48\xcc\xce\xf5\x7e\xf1\x0d\xc7\x47\x62\x5e\xe3\x21\x92" "\xfd\xa0\x2b\xf6\x6f\xff\xbb\x1d\xd9\x03\x00\x28\x97\x23\xd4\xa5\x5e\xea" "\xc2\xd7\xdd\x3f\xd6\x40\xf3\xa5\xd5\x2a\xa1\x08\x52\x92\x9b\x4b\x0d\x1b" "\x48\x7c\xd4\x22\xa2\x5a\xf7\x60\x94\x18\xb1\xad\xc2\xd9\x28\xcd\x9c\xa7" "\xe2\x3c\xb5\xc6\xee\xa4\x34\x69\x65\xe8\xf8\x4f\xbc\x8d\xbf\x0d\x35\x88" "\x0b\xbc\x8f\xa7\x23\xcd\xc6\x87\x64\x7d\x7d\x6f\x22\x14\x17\xae\x92\x0b" "\x02\x54\x15\x7b\x55\x6e\xb8\x20\x69\x87\xde\xc7\x58\x13\xe0\xe4", 304); *(uint32_t*)0x200000000270 = -1; *(uint64_t*)0x200000000450 = 0x200000000000; memcpy((void*)0x200000000000, "GPL\000", 4); *(uint32_t*)0x200000000458 = 2; *(uint32_t*)0x20000000045c = 0; *(uint64_t*)0x200000000460 = 0; *(uint32_t*)0x200000000468 = 0; *(uint32_t*)0x20000000046c = 0xc; memset((void*)0x200000000470, 0, 16); *(uint32_t*)0x200000000480 = 0; *(uint32_t*)0x200000000484 = 0; *(uint32_t*)0x200000000488 = -1; *(uint32_t*)0x20000000048c = 8; *(uint64_t*)0x200000000490 = 0; *(uint32_t*)0x200000000498 = 0; *(uint32_t*)0x20000000049c = 0x10; *(uint64_t*)0x2000000004a0 = 0; *(uint32_t*)0x2000000004a8 = 0; *(uint32_t*)0x2000000004ac = 0; *(uint32_t*)0x2000000004b0 = 0; *(uint32_t*)0x2000000004b4 = 0; *(uint64_t*)0x2000000004b8 = 0; *(uint64_t*)0x2000000004c0 = 0; *(uint32_t*)0x2000000004c8 = 0x10; *(uint32_t*)0x2000000004cc = 0; *(uint32_t*)0x2000000004d0 = 0; syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0x200000000440ul, /*size=*/0x94ul); } 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; }