// https://syzkaller.appspot.com/bug?id=101b7e71f53b37caf00bf159bd293d6d6512242a // 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 #ifndef __NR_bpf #define __NR_bpf 280 #endif #ifndef __NR_mmap #define __NR_mmap 222 #endif #ifndef __NR_openat #define __NR_openat 56 #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 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[2] = {0xffffffffffffffff, 0xffffffffffffffff}; void execute_one(void) { intptr_t res = 0; 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 = 0x9 (4 bytes) // ninsn: bytesize8 = 0x4 (4 bytes) // insns: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {18 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 61 12 00 00 00 00 00 00 95 00 00 00 00 00 00 00 51 fa 78 24 // c7 41 86 dc 02 ec 06 96 c3 7b 64 e3 b2 4d a3 18 01 00 00 00 05 // 34 5c 0f 63 cd c2 e8 28 18 25 49 50 ee 03 56 8b 88 09 a1 f0 4c // 7c 47 50 ea bf af cb 95 31 b3 1e 6a 86 82 7d 10 10 c5 a9 09 ab // 98 e0 0e 19 64 4a 88 e9 5b a2 6d 1c 9e ec dd b2 d1 1c 54 14 18 // ce eb 29 b9 b6 82 9c 6e 43 38 22 bd b3 cc 85 24 4a ab 66 c1 aa // e9 31 4d 73 81 fc fe b9 70 be a6 72 01 00 00 00 00 00 00 00 43 // 14 46 48 a0 7a 97 5b d8 9d c3 98 71 23 76 61 0f aa 54 f1 24 95 // b4 65 9b e8 67 30 86 f6 f3 54 32 05 d4 bc 4c e0 5b 8b 96 11 03 // 67 3d ff 7f 15 80 52 e6 2b fb dc dd de 69 85 f3 f1 ac 5d 9a 94 // cc 53 20 78 99 76 2a 07 28 2a 19 14 45 2d 11 85 8e 79 5a 3c a3 // 0a 10 1a f5 57 4f 90 35 f2 b5 f7 03 e5 be 7e 4a cf 8b 78 c2 83 // 4a e5 80 5f ff ee 38 a9 a0 03 3d 52 0b cf 6b 08 ed e5 08 99 d4 // b9 bd f8 5c 71 c5 ed 44 03 9a ab 46 41 94 96 36 2e 54 cf ad 05 // b4 00 4a c7 1a 00 3d 7b 85 d0 71 91 be d4 e5 a8 90 82 63 72 2d // 41 46 f7 ed 56 99 85 43 9b aa 35 5c f3 d8 73 1f 5e 7a 23 7b c0 // 6d 03 5a 8d 60 1f 21 74 6d 88 08 19 f3 8b 34 a4 95 04 00 00 00 // 00 71 c2 f0 cc e8 c9 3c c1 7e 9a fa 31 4f cb 2b a1 5d 64 6c 5b // 9f 87 d9 88 c9 fb d2 b9 d9 b4 e2 d7 17 53 b1 54 9f a7 34 f0 b2 // e5 fc f9 54 98 04 cd da d7 21 97 16 37 f9 c9 73 0a 9c c3 84 ee // d3 03 45 97 9d b9 c9 3e 1c 52 f4 2c ad 0a 4d 4f 94 36 d3 f3 9b // 0e d0 9c 39 5d c6 e9 70 36 60 87 a8 e4 da ee b1 b0 17 00 6f 25 // ca f0 cb ce fd 13 d6 88 39 89 3e 39 c5 88 eb 03 29 05 f9 1c af // a4 99 6d bf 0c c8 22 8d 02 a3 09 2c 08 30 b8 f5 87 a5 62 45 15 // 29 8b 2d 4e b2 bd e6 f9 a2 eb 83 d5 3f 71 0c 49 0e cd 08 5d 28 // 11 a7 55 5c 53 03 00 00 00 7f 00 00 00 00 bf a6 47 8e b9 6b 07 // 9c 27 7e 29 10 b7 cc dc 3d 67 2e d3 4a a6 52 78 c5 49 e2 ab b5 // 49 ad 95 48 84 28 91 30 bc 71 ce e2 b7 de 62 bf 48 12 9a e1 af // 05 2a 2d 46 a6 16 5e b0 95 4d ac 72 65 f1 f4 25 73 5a cf 63 77 // 79 39 46 b3 22 9e 86 1d 8e a4 98 06 b3 b5 33 34 5d 36 ec ef 9d // f7 00 00 00 00 f3 37 b1 ce b2 d8 a6 5d cd cd 89 5d 7b a3 70 98 // d2 59 3f da ae f4 45 af 5b ee 02 01 9c 00 00 00 aa ae 37 f0 44 // bc ad eb 0f 68 46 58 2b 76 53 66 5a a3 36 db 9f 03 84 d3 c7 dd // f7 9c 2e 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 e1 54 aa 0d 3e 41 98 6a 66 8e e1 e5 ef 93 a8 ce // ac 75 f4 4a ae 95 e2 67 42 f8 95 f2 87 11 1f 8e e8 6f 7e 3f fb // 63 cf b0 e3 45 cf 7f c6 3d d2 b0 d3 09 77 89 9c 6f 03 64 00 40 // af 4d b7 1f 74 52 bf c7 9a 05 11 8d 8b b4 2b 63 b1 95 77 1e 42 // f9 94 2e c6 26 bd 4b 54 61 b7 43 24 01 21 64 e8} (length // 0x33d) // } // } // } // license: ptr[in, buffer] { // buffer: {47 50 4c 00} (length 0x4) // } // loglev: int32 = 0x0 (4 bytes) // logsize: len = 0x0 (4 bytes) // log: nil // kern_version: bpf_kern_version = 0x0 (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 { // fallback: bpf_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 = 0x70 (8 bytes) // ] // returns fd_bpf_prog *(uint32_t*)0x20000080 = 9; *(uint32_t*)0x20000084 = 4; *(uint64_t*)0x20000088 = 0x20000280; memcpy( (void*)0x20000280, "\x18\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x61\x12" "\x00\x00\x00\x00\x00\x00\x95\x00\x00\x00\x00\x00\x00\x00\x51\xfa\x78\x24" "\xc7\x41\x86\xdc\x02\xec\x06\x96\xc3\x7b\x64\xe3\xb2\x4d\xa3\x18\x01\x00" "\x00\x00\x05\x34\x5c\x0f\x63\xcd\xc2\xe8\x28\x18\x25\x49\x50\xee\x03\x56" "\x8b\x88\x09\xa1\xf0\x4c\x7c\x47\x50\xea\xbf\xaf\xcb\x95\x31\xb3\x1e\x6a" "\x86\x82\x7d\x10\x10\xc5\xa9\x09\xab\x98\xe0\x0e\x19\x64\x4a\x88\xe9\x5b" "\xa2\x6d\x1c\x9e\xec\xdd\xb2\xd1\x1c\x54\x14\x18\xce\xeb\x29\xb9\xb6\x82" "\x9c\x6e\x43\x38\x22\xbd\xb3\xcc\x85\x24\x4a\xab\x66\xc1\xaa\xe9\x31\x4d" "\x73\x81\xfc\xfe\xb9\x70\xbe\xa6\x72\x01\x00\x00\x00\x00\x00\x00\x00\x43" "\x14\x46\x48\xa0\x7a\x97\x5b\xd8\x9d\xc3\x98\x71\x23\x76\x61\x0f\xaa\x54" "\xf1\x24\x95\xb4\x65\x9b\xe8\x67\x30\x86\xf6\xf3\x54\x32\x05\xd4\xbc\x4c" "\xe0\x5b\x8b\x96\x11\x03\x67\x3d\xff\x7f\x15\x80\x52\xe6\x2b\xfb\xdc\xdd" "\xde\x69\x85\xf3\xf1\xac\x5d\x9a\x94\xcc\x53\x20\x78\x99\x76\x2a\x07\x28" "\x2a\x19\x14\x45\x2d\x11\x85\x8e\x79\x5a\x3c\xa3\x0a\x10\x1a\xf5\x57\x4f" "\x90\x35\xf2\xb5\xf7\x03\xe5\xbe\x7e\x4a\xcf\x8b\x78\xc2\x83\x4a\xe5\x80" "\x5f\xff\xee\x38\xa9\xa0\x03\x3d\x52\x0b\xcf\x6b\x08\xed\xe5\x08\x99\xd4" "\xb9\xbd\xf8\x5c\x71\xc5\xed\x44\x03\x9a\xab\x46\x41\x94\x96\x36\x2e\x54" "\xcf\xad\x05\xb4\x00\x4a\xc7\x1a\x00\x3d\x7b\x85\xd0\x71\x91\xbe\xd4\xe5" "\xa8\x90\x82\x63\x72\x2d\x41\x46\xf7\xed\x56\x99\x85\x43\x9b\xaa\x35\x5c" "\xf3\xd8\x73\x1f\x5e\x7a\x23\x7b\xc0\x6d\x03\x5a\x8d\x60\x1f\x21\x74\x6d" "\x88\x08\x19\xf3\x8b\x34\xa4\x95\x04\x00\x00\x00\x00\x71\xc2\xf0\xcc\xe8" "\xc9\x3c\xc1\x7e\x9a\xfa\x31\x4f\xcb\x2b\xa1\x5d\x64\x6c\x5b\x9f\x87\xd9" "\x88\xc9\xfb\xd2\xb9\xd9\xb4\xe2\xd7\x17\x53\xb1\x54\x9f\xa7\x34\xf0\xb2" "\xe5\xfc\xf9\x54\x98\x04\xcd\xda\xd7\x21\x97\x16\x37\xf9\xc9\x73\x0a\x9c" "\xc3\x84\xee\xd3\x03\x45\x97\x9d\xb9\xc9\x3e\x1c\x52\xf4\x2c\xad\x0a\x4d" "\x4f\x94\x36\xd3\xf3\x9b\x0e\xd0\x9c\x39\x5d\xc6\xe9\x70\x36\x60\x87\xa8" "\xe4\xda\xee\xb1\xb0\x17\x00\x6f\x25\xca\xf0\xcb\xce\xfd\x13\xd6\x88\x39" "\x89\x3e\x39\xc5\x88\xeb\x03\x29\x05\xf9\x1c\xaf\xa4\x99\x6d\xbf\x0c\xc8" "\x22\x8d\x02\xa3\x09\x2c\x08\x30\xb8\xf5\x87\xa5\x62\x45\x15\x29\x8b\x2d" "\x4e\xb2\xbd\xe6\xf9\xa2\xeb\x83\xd5\x3f\x71\x0c\x49\x0e\xcd\x08\x5d\x28" "\x11\xa7\x55\x5c\x53\x03\x00\x00\x00\x7f\x00\x00\x00\x00\xbf\xa6\x47\x8e" "\xb9\x6b\x07\x9c\x27\x7e\x29\x10\xb7\xcc\xdc\x3d\x67\x2e\xd3\x4a\xa6\x52" "\x78\xc5\x49\xe2\xab\xb5\x49\xad\x95\x48\x84\x28\x91\x30\xbc\x71\xce\xe2" "\xb7\xde\x62\xbf\x48\x12\x9a\xe1\xaf\x05\x2a\x2d\x46\xa6\x16\x5e\xb0\x95" "\x4d\xac\x72\x65\xf1\xf4\x25\x73\x5a\xcf\x63\x77\x79\x39\x46\xb3\x22\x9e" "\x86\x1d\x8e\xa4\x98\x06\xb3\xb5\x33\x34\x5d\x36\xec\xef\x9d\xf7\x00\x00" "\x00\x00\xf3\x37\xb1\xce\xb2\xd8\xa6\x5d\xcd\xcd\x89\x5d\x7b\xa3\x70\x98" "\xd2\x59\x3f\xda\xae\xf4\x45\xaf\x5b\xee\x02\x01\x9c\x00\x00\x00\xaa\xae" "\x37\xf0\x44\xbc\xad\xeb\x0f\x68\x46\x58\x2b\x76\x53\x66\x5a\xa3\x36\xdb" "\x9f\x03\x84\xd3\xc7\xdd\xf7\x9c\x2e\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xe1\x54\xaa\x0d" "\x3e\x41\x98\x6a\x66\x8e\xe1\xe5\xef\x93\xa8\xce\xac\x75\xf4\x4a\xae\x95" "\xe2\x67\x42\xf8\x95\xf2\x87\x11\x1f\x8e\xe8\x6f\x7e\x3f\xfb\x63\xcf\xb0" "\xe3\x45\xcf\x7f\xc6\x3d\xd2\xb0\xd3\x09\x77\x89\x9c\x6f\x03\x64\x00\x40" "\xaf\x4d\xb7\x1f\x74\x52\xbf\xc7\x9a\x05\x11\x8d\x8b\xb4\x2b\x63\xb1\x95" "\x77\x1e\x42\xf9\x94\x2e\xc6\x26\xbd\x4b\x54\x61\xb7\x43\x24\x01\x21\x64" "\xe8", 829); *(uint64_t*)0x20000090 = 0x20000100; memcpy((void*)0x20000100, "GPL\000", 4); *(uint32_t*)0x20000098 = 0; *(uint32_t*)0x2000009c = 0; *(uint64_t*)0x200000a0 = 0; *(uint32_t*)0x200000a8 = 0; *(uint32_t*)0x200000ac = 0; memset((void*)0x200000b0, 0, 16); *(uint32_t*)0x200000c0 = 0; *(uint32_t*)0x200000c4 = 0; *(uint32_t*)0x200000c8 = -1; *(uint32_t*)0x200000cc = 8; *(uint64_t*)0x200000d0 = 0; *(uint32_t*)0x200000d8 = 0; *(uint32_t*)0x200000dc = 0x10; *(uint64_t*)0x200000e0 = 0; *(uint32_t*)0x200000e8 = 0; *(uint32_t*)0x200000ec = 0; *(uint32_t*)0x200000f0 = -1; *(uint32_t*)0x200000f4 = 0; *(uint64_t*)0x200000f8 = 0; *(uint64_t*)0x20000100 = 0; *(uint32_t*)0x20000108 = 0x10; *(uint32_t*)0x2000010c = 0; *(uint32_t*)0x20000110 = 0; res = syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0x20000080ul, /*size=*/0x70ul); if (res != -1) r[0] = res; // bpf$BPF_TASK_FD_QUERY arguments: [ // cmd: const = 0x14 (8 bytes) // arg: ptr[inout, bpf_task_fd_query] { // bpf_task_fd_query { // pid: pid (resource) // fd: fd_perf_base (resource) // flags: const = 0x0 (4 bytes) // buf_len: bytesize = 0x7 (4 bytes) // buf: ptr[in, buffer] { // buffer: {63 67 72 6f 75 70 00} (length 0x7) // } // prog_id: bpf_prog_id (resource) // fd_type: int32 = 0x0 (4 bytes) // probe_offset: int64 = 0x0 (8 bytes) // probe_addr: int64 = 0x0 (8 bytes) // } // } // size: len = 0x30 (8 bytes) // ] *(uint32_t*)0x20000240 = 0; *(uint32_t*)0x20000244 = -1; *(uint32_t*)0x20000248 = 0; *(uint32_t*)0x2000024c = 7; *(uint64_t*)0x20000250 = 0x20000000; memcpy((void*)0x20000000, "cgroup\000", 7); syscall(__NR_bpf, /*cmd=*/0x14ul, /*arg=*/0x20000240ul, /*size=*/0x30ul); // openat$cgroup_root arguments: [ // fd: const = 0xffffffffffffff9c (8 bytes) // file: ptr[in, buffer] { // buffer: {} (length 0x0) // } // flags: const = 0x200002 (4 bytes) // mode: const = 0x0 (2 bytes) // ] // returns fd_cgroup res = syscall(__NR_openat, /*fd=*/0xffffffffffffff9cul, /*file=*/0x20000000ul, /*flags=*/0x200002, /*mode=*/0); if (res != -1) r[1] = res; // bpf$BPF_PROG_DETACH arguments: [ // cmd: const = 0x8 (8 bytes) // arg: ptr[in, bpf_detach_arg] { // bpf_detach_arg { // target: union bpf_attach_targets { // cgroup: fd_cgroup (resource) // } // prog: fd_bpf_prog (resource) // type: bpf_attach_types = 0x2 (4 bytes) // flags: bpf_mprog_attach_flags = 0x0 (4 bytes) // replace_bpf_fd: const = 0x4000 (4 bytes) // relative_link_fd: union _bpf_detach_arg_relative_link_fd_wrapper { // void: buffer: {} (length 0x0) // } // relative_prog_fd: union _bpf_detach_arg_relative_prog_fd_wrapper { // value: fd_bpf_prog (resource) // } // relative_link_id: union _bpf_detach_arg_relative_link_id_wrapper { // void: buffer: {} (length 0x0) // } // relative_prog_id: union _bpf_detach_arg_relative_prog_id_wrapper { // void: buffer: {} (length 0x0) // } // exp_revision: bpf_revision (resource) // } // } // size: len = 0x10 (8 bytes) // ] *(uint32_t*)0x20000240 = r[1]; *(uint32_t*)0x20000244 = r[0]; *(uint32_t*)0x20000248 = 2; *(uint32_t*)0x2000024c = 0; *(uint32_t*)0x20000250 = 0x4000; *(uint32_t*)0x20000254 = -1; *(uint64_t*)0x20000258 = 0; syscall(__NR_bpf, /*cmd=*/8ul, /*arg=*/0x20000240ul, /*size=*/0x10ul); } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=MAP_FIXED|MAP_ANONYMOUS|MAP_PRIVATE*/ 0x32ul, /*fd=*/(intptr_t)-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x20000000ul, /*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=*/0x21000000ul, /*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; }