// 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$PROG_LOAD arguments: [ // cmd: const = 0x5 (8 bytes) // arg: ptr[in, bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], fd_bpf_prog[opt]]] { // bpf_prog_t[flags[bpf_prog_type, int32], bpf_prog_attach_types, // bpf_btf_id[opt], fd_bpf_prog[opt]] { // type: bpf_prog_type = 0xd (4 bytes) // ninsn: bytesize8 = 0x4 (4 bytes) // insns: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {b4 00 17 93 a3 77 ea 24 7f 01 01 00 00 38 60 // 5a 99 2b e7 bf 5d f0 00 00 00 0a 00 00 61 11 90 00 00 00 00 00 // c6 00 00 a6 8b 87 c6 bd 5a b0 7a 6a 89 37 4d 3d cb 0a df e4 48 // 1d 3c ac 97 81 7e 74 9b c4 e7 d2 b2 49 18 e7 c8 a1 db 9f 3d d1 // c6 2b 5d 15 64 8d ca 70 79 b3 ff c2 42 f5 34 d7 4a 27 48 89 70 // 2e f7 9c 72 35 b1 41 73 1b d8 fd 1a 59 5b e9 98 c8 fa 79 80 f0 // ce 3c e3 a7 26 b8 56 24 d2 51 11 bc 24 7b fc 07 c5 81 ca 55 35 // 1d 91 9a ea 88 b2 ba 79 a4 92 54 7a 51 24 dd 94 3e 39 1b bd 51 // 27 8d 2d f2 d0 a8 da 17 7a 4f 43 52 ba 35 08 84 8c a6 42 d3 f1 // 52 7c 03 ca 04 b3 30 c1 42 c2 75 5d c5 de f9 91 70 d1 e9 77 de // cc 67 c5 ef ba 38 4b 94} (length 0xd4) // } // } // } // license: ptr[in, buffer] { // buffer: {47 50 4c 00} (length 0x4) // } // loglev: int32 = 0x5 (4 bytes) // logsize: len = 0xfd90 (4 bytes) // log: ptr[out, buffer] { // buffer: (DirOut) // } // kern_version: bpf_kern_version = 0x1e00 (4 bytes) // flags: bpf_prog_load_flags = 0x0 (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: // union bpf_prog_attach_types { // sock_ops: sock_ops_attach_types = 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: bpf_btf_id (resource) // attach_prog_fd: fd_bpf_prog (resource) // 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_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], // fd_bpf_prog[opt]]_prog_token_fd_wrapper { // void: buffer: {} (length 0x0) // } // pad: union _bpf_prog_t[flags[bpf_prog_type, int32], // bpf_prog_attach_types, bpf_btf_id[opt], // fd_bpf_prog[opt]]_pad_wrapper { // value: const = 0x0 (4 bytes) // } // } // } // size: len = 0x54 (8 bytes) // ] // returns fd_bpf_prog *(uint32_t*)0x20000000e000 = 0xd; *(uint32_t*)0x20000000e004 = 4; *(uint64_t*)0x20000000e008 = 0x200000000980; memcpy( (void*)0x200000000980, "\xb4\x00\x17\x93\xa3\x77\xea\x24\x7f\x01\x01\x00\x00\x38\x60\x5a\x99\x2b" "\xe7\xbf\x5d\xf0\x00\x00\x00\x0a\x00\x00\x61\x11\x90\x00\x00\x00\x00\x00" "\xc6\x00\x00\xa6\x8b\x87\xc6\xbd\x5a\xb0\x7a\x6a\x89\x37\x4d\x3d\xcb\x0a" "\xdf\xe4\x48\x1d\x3c\xac\x97\x81\x7e\x74\x9b\xc4\xe7\xd2\xb2\x49\x18\xe7" "\xc8\xa1\xdb\x9f\x3d\xd1\xc6\x2b\x5d\x15\x64\x8d\xca\x70\x79\xb3\xff\xc2" "\x42\xf5\x34\xd7\x4a\x27\x48\x89\x70\x2e\xf7\x9c\x72\x35\xb1\x41\x73\x1b" "\xd8\xfd\x1a\x59\x5b\xe9\x98\xc8\xfa\x79\x80\xf0\xce\x3c\xe3\xa7\x26\xb8" "\x56\x24\xd2\x51\x11\xbc\x24\x7b\xfc\x07\xc5\x81\xca\x55\x35\x1d\x91\x9a" "\xea\x88\xb2\xba\x79\xa4\x92\x54\x7a\x51\x24\xdd\x94\x3e\x39\x1b\xbd\x51" "\x27\x8d\x2d\xf2\xd0\xa8\xda\x17\x7a\x4f\x43\x52\xba\x35\x08\x84\x8c\xa6" "\x42\xd3\xf1\x52\x7c\x03\xca\x04\xb3\x30\xc1\x42\xc2\x75\x5d\xc5\xde\xf9" "\x91\x70\xd1\xe9\x77\xde\xcc\x67\xc5\xef\xba\x38\x4b\x94", 212); *(uint64_t*)0x20000000e010 = 0x200000003ff6; memcpy((void*)0x200000003ff6, "GPL\000", 4); *(uint32_t*)0x20000000e018 = 5; *(uint32_t*)0x20000000e01c = 0xfd90; *(uint64_t*)0x20000000e020 = 0x20000000cf3d; *(uint32_t*)0x20000000e028 = 0x1e00; *(uint32_t*)0x20000000e02c = 0; memset((void*)0x20000000e030, 0, 16); *(uint32_t*)0x20000000e040 = 0; *(uint32_t*)0x20000000e044 = 0; *(uint32_t*)0x20000000e048 = -1; *(uint32_t*)0x20000000e04c = 8; *(uint64_t*)0x20000000e050 = 0; *(uint32_t*)0x20000000e058 = 0; *(uint32_t*)0x20000000e05c = 0x10; *(uint64_t*)0x20000000e060 = 0; *(uint32_t*)0x20000000e068 = 0; *(uint32_t*)0x20000000e06c = 0; *(uint32_t*)0x20000000e070 = -1; *(uint32_t*)0x20000000e074 = 0; *(uint64_t*)0x20000000e078 = 0; *(uint64_t*)0x20000000e080 = 0; *(uint32_t*)0x20000000e088 = 0x10; *(uint32_t*)0x20000000e08c = 0; *(uint32_t*)0x20000000e090 = 0; syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0x20000000e000ul, /*size=*/0x54ul); } 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; }