// https://syzkaller.appspot.com/bug?id=34e75e253d362f5c112bdc528ba1e586171cbc75 // 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 321 #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; } #define BITMASK(bf_off, bf_len) (((1ull << (bf_len)) - 1) << (bf_off)) #define STORE_BY_BITMASK(type, htobe, addr, val, bf_off, bf_len) \ *(type*)(addr) = \ htobe((htobe(*(type*)(addr)) & ~BITMASK((bf_off), (bf_len))) | \ (((type)(val) << (bf_off)) & BITMASK((bf_off), (bf_len)))) 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)) { } // perf_event_open arguments: [ // attr: ptr[in, perf_event_attr] { // perf_event_attr { // type: perf_event_type = 0x2 (4 bytes) // size: len = 0x80 (4 bytes) // config0: int8 = 0x1b (1 bytes) // config1: int8 = 0x1 (1 bytes) // config2: int8 = 0x0 (1 bytes) // config3: int8 = 0x0 (1 bytes) // config4: const = 0x0 (4 bytes) // sample_freq: int64 = 0x0 (8 bytes) // sample_type: perf_sample_type = 0x0 (8 bytes) // read_format: perf_read_format = 0x0 (8 bytes) // disabled: int64 = 0x0 (0 bytes) // inherit: int64 = 0x0 (0 bytes) // pinned: int64 = 0x0 (0 bytes) // exclusive: int64 = 0x0 (0 bytes) // exclude_user: int64 = 0x0 (0 bytes) // exclude_kernel: int64 = 0x0 (0 bytes) // exclude_hv: int64 = 0x0 (0 bytes) // exclude_idle: int64 = 0x0 (0 bytes) // mmap: int64 = 0x0 (0 bytes) // comm: int64 = 0x0 (0 bytes) // freq: int64 = 0x0 (0 bytes) // inherit_stat: int64 = 0x0 (0 bytes) // enable_on_exec: int64 = 0x0 (0 bytes) // task: int64 = 0x0 (0 bytes) // watermark: int64 = 0x0 (0 bytes) // precise_ip: int64 = 0x0 (0 bytes) // mmap_data: int64 = 0x0 (0 bytes) // sample_id_all: int64 = 0x0 (0 bytes) // exclude_host: int64 = 0x0 (0 bytes) // exclude_guest: int64 = 0x0 (0 bytes) // exclude_callchain_kernel: int64 = 0x0 (0 bytes) // exclude_callchain_user: int64 = 0x0 (0 bytes) // mmap2: int64 = 0x0 (0 bytes) // comm_exec: int64 = 0x0 (0 bytes) // use_clockid: int64 = 0x0 (0 bytes) // context_switch: int64 = 0x0 (0 bytes) // write_backward: int64 = 0x0 (0 bytes) // namespaces: int64 = 0x0 (0 bytes) // ksymbol: int64 = 0x0 (0 bytes) // bpf_event: int64 = 0x0 (0 bytes) // aux_output: int64 = 0x0 (0 bytes) // cgroup: int64 = 0x0 (0 bytes) // text_poke: int64 = 0x0 (0 bytes) // build_id: int64 = 0x0 (0 bytes) // inherit_thread: int64 = 0x0 (0 bytes) // remove_on_exec: int64 = 0x0 (0 bytes) // sigtrap: int64 = 0x0 (0 bytes) // __reserved_1: const = 0x0 (8 bytes) // wakeup_events: int32 = 0x0 (4 bytes) // bp_type: perf_bp_type = 0x0 (4 bytes) // bp_config: union perf_bp_config { // perf_config_ext: perf_config_ext { // config1: int64 = 0x7 (8 bytes) // config2: int64 = 0x0 (8 bytes) // } // } // branch_sample_type: perf_branch_sample_type = 0x20 (8 bytes) // sample_regs_user: int64 = 0x3 (8 bytes) // sample_stack_user: int32 = 0x7 (4 bytes) // clockid: clock_type = 0x5 (4 bytes) // sample_regs_intr: int64 = 0xce9 (8 bytes) // aux_watermark: int32 = 0x0 (4 bytes) // sample_max_stack: int16 = 0x0 (2 bytes) // __reserved_2: const = 0x0 (2 bytes) // aux_sample_size: int32 = 0x0 (4 bytes) // __reserved_3: const = 0x0 (4 bytes) // sig_data: int64 = 0x0 (8 bytes) // } // } // pid: pid (resource) // cpu: intptr = 0x0 (8 bytes) // group: fd_perf (resource) // flags: perf_flags = 0x0 (8 bytes) // ] // returns fd_perf *(uint32_t*)0x200000000140 = 2; *(uint32_t*)0x200000000144 = 0x80; *(uint8_t*)0x200000000148 = 0x1b; *(uint8_t*)0x200000000149 = 1; *(uint8_t*)0x20000000014a = 0; *(uint8_t*)0x20000000014b = 0; *(uint32_t*)0x20000000014c = 0; *(uint64_t*)0x200000000150 = 0; *(uint64_t*)0x200000000158 = 0; *(uint64_t*)0x200000000160 = 0; STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 0, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 1, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 2, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 3, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 4, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 5, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 6, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 7, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 8, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 9, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 10, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 11, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 12, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 13, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 14, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 15, 2); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 17, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 18, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 19, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 20, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 21, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 22, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 23, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 24, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 25, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 26, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 27, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 28, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 29, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 30, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 31, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 32, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 33, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 34, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 35, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 36, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 37, 1); STORE_BY_BITMASK(uint64_t, , 0x200000000168, 0, 38, 26); *(uint32_t*)0x200000000170 = 0; *(uint32_t*)0x200000000174 = 0; *(uint64_t*)0x200000000178 = 7; *(uint64_t*)0x200000000180 = 0; *(uint64_t*)0x200000000188 = 0x20; *(uint64_t*)0x200000000190 = 3; *(uint32_t*)0x200000000198 = 7; *(uint32_t*)0x20000000019c = 5; *(uint64_t*)0x2000000001a0 = 0xce9; *(uint32_t*)0x2000000001a8 = 0; *(uint16_t*)0x2000000001ac = 0; *(uint16_t*)0x2000000001ae = 0; *(uint32_t*)0x2000000001b0 = 0; *(uint32_t*)0x2000000001b4 = 0; *(uint64_t*)0x2000000001b8 = 0; res = syscall(__NR_perf_event_open, /*attr=*/0x200000000140ul, /*pid=*/0, /*cpu=*/0ul, /*group=*/(intptr_t)-1, /*flags=*/0ul); if (res != -1) r[0] = res; // 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 = 0x5 (4 bytes) // ninsn: bytesize8 = 0x3 (4 bytes) // insns: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {85 00 00 00 2a 00 00 00 25 00 00 00 00 00 00 // 00 95 00 00 00 00 00 00 00 ae cd 48 d6 49 4d 61 4d cc 6f ab 53 // 35 ec 47 0d b2 c6 16 1d ba 39 21 76 dd 29 63 03 8e 1d 69 ba 7e // a9 4c 50 0d c4 ef 2f ad 94 ed 40 6f 21 ca f5 ad cf 92 05 69 c0 // 0c c1 19 96 84 fa 75 81 47 09 fe a0 19 af 24 7c 93 83 6d 9e a2 // cf b0 e6 04 36 e0 54 25 cc 46 86 b0 66 70 7d e9 4a 4f 4d 5f c7 // 9c 1f ac a0 f9 d9 92 4b e4 1a 91 69 bd fa f1 6d a9 15 b2 e2 49 // ee 1c 6e ee 84 30 9e 7a 23 c1 9a 39 48 48 09 53 9f ca 4e 0b 6f // ab 1a a7 d5 55 45 a3 4e ff a0 77 fa a5 5c 59 e8 82 54 f5 40 77 // f7 99 bf 16 83 01 00 00 00 bf 22 55 d6 a0 24 4d 35 b2 13 bd a8 // 4c c1 72 af d8 cc 2e 47 a7 d8 b8 5a 5e 3d 77 ac 46 39 20 e2 31 // b7 ae 0d a8 61 6d 2b 79 db 2e 3d 59 86 c8 2b 5a a9 4e 53 9b 20 // 4d 58 f9 1f 5d a6 c0 25 d0 60 ab 18 6d 94 af 98 af 1d a2 b5 95 // 2e b1 58 55 93 3a 21 23 04 e0 35 f7 a3 5d fc 72 c8 12 56 a5 5a // 25 f8 fe 3b 28 d7 e5 3c 71 60 ec 83 07 00 00 02 00 00 00 40 15 // cf 10 45 3f 6c 0b 97 3b 81 a4 84 eb ad 04 85 9d 92 83 65 a7 ea // 3f ab 8b 4b 38 0a 00 d7 2b 00 00 00 00 00 00 1c f5 55 c1 4d 56 // b5 1c 22 98 23 7b eb fc 08 e0 d5 97 6a 94 2b 84 69 70 cf d9 8b // 9d 41 39 f1 11 1f 2c c5 e4 6a c1 c6 0a 9b 03 00 74 bf bc d4 b0 // 90 12 17 54 84 13 5f 0e 51 9f 0b 1e 4a aa 02 6d 57 0e cb 5e 8c // dd be d6 5f f7 02 00 00 00 a3 ff 4f 8a 4c f7 96 b0 7a 6f f6 1c // 55 52 41 7f d7 03 f7 f1 4d 8b 78 ac 02 ca 3c df 6a 66 2d b1 c9 // c8 9c 91 20 07 2a 5d 00 dc dd 85 95 35 6c 9b 24 92 aa f1 26 4d // 4e f4 a4 10 c8 82 83 48 67 bc d2 b6 e5 59 d1 78 79 57 0c 8a d9 // 43 e3 92 95 5f 4f 97 9e a1 32 01 ba fe dc d2 06 3d 11 dd 66 56 // 47 22 3c 78 a9 96 81 00 00 00 05 71 cb b1 7d 9f 37 28 24 62 f0 // e9 c1 47 c0 d4 97 c6 14 33 c6 cc c3 56 01 ee f9 7e e6 11 be 8c // 97 f4 15 1f fd f6 f7 82 05 49 cd a6 cb 79 9c 6e 92 49 66 a7 f9 // 0b f8 fd 1e 75 ee 76 bd 89 34 6c fb b5 56 7e 54 d3 50 47 23 17 // 7d 35 6c 46 04 b7 a4 92 ec ec 37 e8 3e fc ee fd 7c a2 53 36 59 // ed c8 be 05 cc 85 45 1c 6a 14 50 74 34 eb 54 b6 f4 3c ae a5 c4 // bf 69 04 41 97 4b 15 5f 5a dc 68 1a 03 c0 bb b8 35 88 56 17 5e // 2c e8 b0 cb bb e3 c0 33 e5 4f fc a9 ec 9a 7a 37 55 e0 f2 09 15 // 0a 07 68 2c 4e 14 e3 a8 35 58 df 6f 3f c9 7f 17 30 a1 36 bd ee // 07 e9 8c b9 84 b2 e2 30 4a 1b 63 af ef db 63 6e 56 bb aa e4 e6 // 21 36 57 4b c6 37 1a 0b b2 be 1a 96 2a ae 9c 12 58 da 6e f5 90 // e1 d8 5e a9 e1 2b 30 25 f4 3e 7e 08 cc ff c5 06 4d ea 4c 39 cf // 4b 98 e1 fc 6e fb 59 78 f5 1e 16 b6 78 ec a0 b6 58 a5 60 08 94 // 8e 56 1a 98 45 e4 ff 29 e2 bd b1 d0 b9 23 b2 72 34 1c 5e 09 3f // d6 6a 29 43 51 c5 35 6c 1d 06 c9 2c f8 ce 3c 7c 56 cd 31 12 16 // 24 d7 45 17 fd 36 66 27 7f 67 0e 81 2b 28 e2 f3 0d 03 5c ee 5d // 0e 77 a3 c7 22 00 00 00 00 00 00 00 05 a4 74 81 6b c5 9d 2e 2a // 00 09 24 19 30 4b 33 8a 98 7e 9d 30 44 d8 56 ce 24 f3 70 03 0b // e3 b5 f7 9f 03 4b 8d 3e bc e6 86 63 ef 5a f4 69 ab e7 5b 31 4f // ae 31 a0 44 58 59 a5 ec e8 fb 11 a4 ee 8e 46 35 4c 9c 3a 04 1e // 12 28 2c e2 44 63 aa f2 83 45 bd 16 8b 41 77 ce 37 ed 85 46 4c // 31 67 90 53 e7 f9 d0 4b b5 cb 51 da 0b 79 58 98 9f d7 0f 09 00 // 00 00 00 00 00 00 4f c4 bd a3 45 36 02 00 45 35 a9 76 ea cd 3a // da a4 d2 ee 6f e0 d0 72 cc d4 43 41 f7 fd 53 df 58 ae 79 1e e8 // b4 89 a7 c9 ef e3 62 5a 9d 97 1b 59 97 48 5d 6a 06 3d c6 f7 35 // 9e 2e cc c2 fb 39 d4 01 ad f5 9d 44 e5 8e b1 c6 0b 34 75 be 31 // a9 b7 cf 42 b6 40 23 12 d2 72 5b 8d 9f a7 00 a8 64 07 e7 9a e2 // 9d 2c 11 7c a6 5f c8 6c 2d ce 97 aa 03 27 9a 66 ec 87 12 22 19 // b0 f7 96 ab 92 b1 ad ec ae 50 fd b4 0f 7f 02 f7 50 d6 c9 77 a1 // 91 85 2c 9a e0 31 db 04 4b 23 53 19 95 46 60 9f 9f 69 a6 cf ef // df 87 9d 44 7d f5 3f 3b 9b 70 d1 03 55 b0 03 00 00 00 00 00 00 // 00 55 3d 18 a6 cc 50 fe eb 7b fa d9 b7 be 32 83 b6 45 0d 26 4e // 77 12 d2 f1 d7 00 45 48 b1 91 62 ce f0 4d 18 d4 f5 8f ab 98 7b // aa b9 7a 9b fb d8 f1 85 b5 63 18 20 42 0b f5 b6 52 2c 0e 21 c8 // 82 c6 6f 4f 25 ff b6 d9 5e 07 de 02 20 5f ca 4f 18 a2 eb 5b 63 // e4 5d 5d 80 fe 52 73 40 93 5a a3 c0 b4 f3 f4 5b 41 8a 18 21 77 // 47 ae 44 2e 31 56 0e 5b 74 14 45 ea 2a 1a ce e2 a8 14 25 ff 00 // 00 00 d2 a0 a7 65 d2 0b 30 f8 7a f9 76 a4 6f 9a 9a 1a c7 de a1 // ea 68 45 f9 aa 66 23 92 0d ac c1 07 f5 32 34 8c c2 11 64 ef e7 // 94 87 4e ac 73 38 1e 96 1f 3d 9c 8c 21 57 8f e3 24 50 97 c2 80 // ab e5 14 23 b9 f6 cd 72 b5 da 6d 02 52 80 3c 66 73 0c d5 ea c9 // 07 f0 9b 96 95 90 63 13 f8 87 35 fc e5 11 5d c8 3e d7 3d 8e e4 // a9 13 22 60 8c 6f c0 1e 1b 9e 16 58 7b b5 f7 21 30 3e 6b 89 e5 // c5 4d 68 0a c6 6d 09 af 90 db f5 00 00 00 00 00 00 fa 08 ad 06 // 31 c4 b8 39 68 8b 22 c4 da 2a 6b c4 cf 45 85 4d 22 1a 2d 5f 96 // bc 64 64 7f 15 da a2 ba 79 cd 0f 42 54 ed 55 21 79 12 ef 84 bd // 29 27 df 82 fc 06 1a ef 29 20 c4 9b 2a 90 88 6d a7 55 61 17 3f // a1 86 cb 7e e8 6d d4 28 5c 47 21 eb 42 8c 95 32 96 bb 2f 5d 82 // 5d a5 4d be f0 7c 1b 34 9b 49 01 e0 93 d1 3e 6b 9a 00 00 00 9b // 5b 22 e8 87 bc 06 1d 40 bc af 0a a1 86 23 fd 9b 71 79 cc c6 92 // ba 74 b5 31 b6 5c 4d ec f9 d0 80 a8 ac 7e 82 d4 cd e1 26 7a a6 // 4b 2a 94 fd 87 a0 09 e6 74 2c 2d dc 3a 9d 7e cc bb 18 31 b1 fa // 21 82 77 c2 81 4a 91 ca b7 cb 59 c6 97 16 6d 6f 1b b1 a3 60 47 // 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 f9 f9 b4 ce 7e 87 1f 50 70 84 c8 c8 8e 06 52 de // cb e5 79 b0 3e d8 4e a9 45 97 dd 10 59 62 0a 05 0f 69 ea 03 b9 // 9b 4e 19 d3 5f 4a 3b 54 e9 6a e2 17 2e ff ec ec 80 f6 ba a4 bf // 69 a6 eb f5 39 28 82 df 78 b0 98 3e 66 2d c0 cb 64 b7 7f 3f 00 // 6b 6b 25 44 31 97 ae 93 f0 be 6d e5 a7 03 d0 03 f0 07 20 94 3c // 0e 4b 33 af 00 00 00 00 00 00 00 00 00 21 a6 88 b2 d7 00 7f cc // 4b 59 f7 19 af b0 b3 b7 e0 ae e3 06 ca 70 fe 42 bf 49 84 a6 8f // 40 e1 fc 04 3a 03 a1 7e 47 44 35 9b 87 dc 27 c8 2d 51 cb eb 64 // e5 2a 28 da eb 6a 78 d6 fe 06 18 1e cc 84 00 00} (length // 0x72d) // } // } // } // license: ptr[in, buffer] { // buffer: {47 50 4c 00} (length 0x4) // } // loglev: int32 = 0x5 (4 bytes) // logsize: len = 0x252 (4 bytes) // log: ptr[out, buffer] { // buffer: (DirOut) // } // 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 = 0x48 (8 bytes) // ] // returns fd_bpf_prog *(uint32_t*)0x200000000080 = 5; *(uint32_t*)0x200000000084 = 3; *(uint64_t*)0x200000000088 = 0x200000001240; memcpy( (void*)0x200000001240, "\x85\x00\x00\x00\x2a\x00\x00\x00\x25\x00\x00\x00\x00\x00\x00\x00\x95\x00" "\x00\x00\x00\x00\x00\x00\xae\xcd\x48\xd6\x49\x4d\x61\x4d\xcc\x6f\xab\x53" "\x35\xec\x47\x0d\xb2\xc6\x16\x1d\xba\x39\x21\x76\xdd\x29\x63\x03\x8e\x1d" "\x69\xba\x7e\xa9\x4c\x50\x0d\xc4\xef\x2f\xad\x94\xed\x40\x6f\x21\xca\xf5" "\xad\xcf\x92\x05\x69\xc0\x0c\xc1\x19\x96\x84\xfa\x75\x81\x47\x09\xfe\xa0" "\x19\xaf\x24\x7c\x93\x83\x6d\x9e\xa2\xcf\xb0\xe6\x04\x36\xe0\x54\x25\xcc" "\x46\x86\xb0\x66\x70\x7d\xe9\x4a\x4f\x4d\x5f\xc7\x9c\x1f\xac\xa0\xf9\xd9" "\x92\x4b\xe4\x1a\x91\x69\xbd\xfa\xf1\x6d\xa9\x15\xb2\xe2\x49\xee\x1c\x6e" "\xee\x84\x30\x9e\x7a\x23\xc1\x9a\x39\x48\x48\x09\x53\x9f\xca\x4e\x0b\x6f" "\xab\x1a\xa7\xd5\x55\x45\xa3\x4e\xff\xa0\x77\xfa\xa5\x5c\x59\xe8\x82\x54" "\xf5\x40\x77\xf7\x99\xbf\x16\x83\x01\x00\x00\x00\xbf\x22\x55\xd6\xa0\x24" "\x4d\x35\xb2\x13\xbd\xa8\x4c\xc1\x72\xaf\xd8\xcc\x2e\x47\xa7\xd8\xb8\x5a" "\x5e\x3d\x77\xac\x46\x39\x20\xe2\x31\xb7\xae\x0d\xa8\x61\x6d\x2b\x79\xdb" "\x2e\x3d\x59\x86\xc8\x2b\x5a\xa9\x4e\x53\x9b\x20\x4d\x58\xf9\x1f\x5d\xa6" "\xc0\x25\xd0\x60\xab\x18\x6d\x94\xaf\x98\xaf\x1d\xa2\xb5\x95\x2e\xb1\x58" "\x55\x93\x3a\x21\x23\x04\xe0\x35\xf7\xa3\x5d\xfc\x72\xc8\x12\x56\xa5\x5a" "\x25\xf8\xfe\x3b\x28\xd7\xe5\x3c\x71\x60\xec\x83\x07\x00\x00\x02\x00\x00" "\x00\x40\x15\xcf\x10\x45\x3f\x6c\x0b\x97\x3b\x81\xa4\x84\xeb\xad\x04\x85" "\x9d\x92\x83\x65\xa7\xea\x3f\xab\x8b\x4b\x38\x0a\x00\xd7\x2b\x00\x00\x00" "\x00\x00\x00\x1c\xf5\x55\xc1\x4d\x56\xb5\x1c\x22\x98\x23\x7b\xeb\xfc\x08" "\xe0\xd5\x97\x6a\x94\x2b\x84\x69\x70\xcf\xd9\x8b\x9d\x41\x39\xf1\x11\x1f" "\x2c\xc5\xe4\x6a\xc1\xc6\x0a\x9b\x03\x00\x74\xbf\xbc\xd4\xb0\x90\x12\x17" "\x54\x84\x13\x5f\x0e\x51\x9f\x0b\x1e\x4a\xaa\x02\x6d\x57\x0e\xcb\x5e\x8c" "\xdd\xbe\xd6\x5f\xf7\x02\x00\x00\x00\xa3\xff\x4f\x8a\x4c\xf7\x96\xb0\x7a" "\x6f\xf6\x1c\x55\x52\x41\x7f\xd7\x03\xf7\xf1\x4d\x8b\x78\xac\x02\xca\x3c" "\xdf\x6a\x66\x2d\xb1\xc9\xc8\x9c\x91\x20\x07\x2a\x5d\x00\xdc\xdd\x85\x95" "\x35\x6c\x9b\x24\x92\xaa\xf1\x26\x4d\x4e\xf4\xa4\x10\xc8\x82\x83\x48\x67" "\xbc\xd2\xb6\xe5\x59\xd1\x78\x79\x57\x0c\x8a\xd9\x43\xe3\x92\x95\x5f\x4f" "\x97\x9e\xa1\x32\x01\xba\xfe\xdc\xd2\x06\x3d\x11\xdd\x66\x56\x47\x22\x3c" "\x78\xa9\x96\x81\x00\x00\x00\x05\x71\xcb\xb1\x7d\x9f\x37\x28\x24\x62\xf0" "\xe9\xc1\x47\xc0\xd4\x97\xc6\x14\x33\xc6\xcc\xc3\x56\x01\xee\xf9\x7e\xe6" "\x11\xbe\x8c\x97\xf4\x15\x1f\xfd\xf6\xf7\x82\x05\x49\xcd\xa6\xcb\x79\x9c" "\x6e\x92\x49\x66\xa7\xf9\x0b\xf8\xfd\x1e\x75\xee\x76\xbd\x89\x34\x6c\xfb" "\xb5\x56\x7e\x54\xd3\x50\x47\x23\x17\x7d\x35\x6c\x46\x04\xb7\xa4\x92\xec" "\xec\x37\xe8\x3e\xfc\xee\xfd\x7c\xa2\x53\x36\x59\xed\xc8\xbe\x05\xcc\x85" "\x45\x1c\x6a\x14\x50\x74\x34\xeb\x54\xb6\xf4\x3c\xae\xa5\xc4\xbf\x69\x04" "\x41\x97\x4b\x15\x5f\x5a\xdc\x68\x1a\x03\xc0\xbb\xb8\x35\x88\x56\x17\x5e" "\x2c\xe8\xb0\xcb\xbb\xe3\xc0\x33\xe5\x4f\xfc\xa9\xec\x9a\x7a\x37\x55\xe0" "\xf2\x09\x15\x0a\x07\x68\x2c\x4e\x14\xe3\xa8\x35\x58\xdf\x6f\x3f\xc9\x7f" "\x17\x30\xa1\x36\xbd\xee\x07\xe9\x8c\xb9\x84\xb2\xe2\x30\x4a\x1b\x63\xaf" "\xef\xdb\x63\x6e\x56\xbb\xaa\xe4\xe6\x21\x36\x57\x4b\xc6\x37\x1a\x0b\xb2" "\xbe\x1a\x96\x2a\xae\x9c\x12\x58\xda\x6e\xf5\x90\xe1\xd8\x5e\xa9\xe1\x2b" "\x30\x25\xf4\x3e\x7e\x08\xcc\xff\xc5\x06\x4d\xea\x4c\x39\xcf\x4b\x98\xe1" "\xfc\x6e\xfb\x59\x78\xf5\x1e\x16\xb6\x78\xec\xa0\xb6\x58\xa5\x60\x08\x94" "\x8e\x56\x1a\x98\x45\xe4\xff\x29\xe2\xbd\xb1\xd0\xb9\x23\xb2\x72\x34\x1c" "\x5e\x09\x3f\xd6\x6a\x29\x43\x51\xc5\x35\x6c\x1d\x06\xc9\x2c\xf8\xce\x3c" "\x7c\x56\xcd\x31\x12\x16\x24\xd7\x45\x17\xfd\x36\x66\x27\x7f\x67\x0e\x81" "\x2b\x28\xe2\xf3\x0d\x03\x5c\xee\x5d\x0e\x77\xa3\xc7\x22\x00\x00\x00\x00" "\x00\x00\x00\x05\xa4\x74\x81\x6b\xc5\x9d\x2e\x2a\x00\x09\x24\x19\x30\x4b" "\x33\x8a\x98\x7e\x9d\x30\x44\xd8\x56\xce\x24\xf3\x70\x03\x0b\xe3\xb5\xf7" "\x9f\x03\x4b\x8d\x3e\xbc\xe6\x86\x63\xef\x5a\xf4\x69\xab\xe7\x5b\x31\x4f" "\xae\x31\xa0\x44\x58\x59\xa5\xec\xe8\xfb\x11\xa4\xee\x8e\x46\x35\x4c\x9c" "\x3a\x04\x1e\x12\x28\x2c\xe2\x44\x63\xaa\xf2\x83\x45\xbd\x16\x8b\x41\x77" "\xce\x37\xed\x85\x46\x4c\x31\x67\x90\x53\xe7\xf9\xd0\x4b\xb5\xcb\x51\xda" "\x0b\x79\x58\x98\x9f\xd7\x0f\x09\x00\x00\x00\x00\x00\x00\x00\x4f\xc4\xbd" "\xa3\x45\x36\x02\x00\x45\x35\xa9\x76\xea\xcd\x3a\xda\xa4\xd2\xee\x6f\xe0" "\xd0\x72\xcc\xd4\x43\x41\xf7\xfd\x53\xdf\x58\xae\x79\x1e\xe8\xb4\x89\xa7" "\xc9\xef\xe3\x62\x5a\x9d\x97\x1b\x59\x97\x48\x5d\x6a\x06\x3d\xc6\xf7\x35" "\x9e\x2e\xcc\xc2\xfb\x39\xd4\x01\xad\xf5\x9d\x44\xe5\x8e\xb1\xc6\x0b\x34" "\x75\xbe\x31\xa9\xb7\xcf\x42\xb6\x40\x23\x12\xd2\x72\x5b\x8d\x9f\xa7\x00" "\xa8\x64\x07\xe7\x9a\xe2\x9d\x2c\x11\x7c\xa6\x5f\xc8\x6c\x2d\xce\x97\xaa" "\x03\x27\x9a\x66\xec\x87\x12\x22\x19\xb0\xf7\x96\xab\x92\xb1\xad\xec\xae" "\x50\xfd\xb4\x0f\x7f\x02\xf7\x50\xd6\xc9\x77\xa1\x91\x85\x2c\x9a\xe0\x31" "\xdb\x04\x4b\x23\x53\x19\x95\x46\x60\x9f\x9f\x69\xa6\xcf\xef\xdf\x87\x9d" "\x44\x7d\xf5\x3f\x3b\x9b\x70\xd1\x03\x55\xb0\x03\x00\x00\x00\x00\x00\x00" "\x00\x55\x3d\x18\xa6\xcc\x50\xfe\xeb\x7b\xfa\xd9\xb7\xbe\x32\x83\xb6\x45" "\x0d\x26\x4e\x77\x12\xd2\xf1\xd7\x00\x45\x48\xb1\x91\x62\xce\xf0\x4d\x18" "\xd4\xf5\x8f\xab\x98\x7b\xaa\xb9\x7a\x9b\xfb\xd8\xf1\x85\xb5\x63\x18\x20" "\x42\x0b\xf5\xb6\x52\x2c\x0e\x21\xc8\x82\xc6\x6f\x4f\x25\xff\xb6\xd9\x5e" "\x07\xde\x02\x20\x5f\xca\x4f\x18\xa2\xeb\x5b\x63\xe4\x5d\x5d\x80\xfe\x52" "\x73\x40\x93\x5a\xa3\xc0\xb4\xf3\xf4\x5b\x41\x8a\x18\x21\x77\x47\xae\x44" "\x2e\x31\x56\x0e\x5b\x74\x14\x45\xea\x2a\x1a\xce\xe2\xa8\x14\x25\xff\x00" "\x00\x00\xd2\xa0\xa7\x65\xd2\x0b\x30\xf8\x7a\xf9\x76\xa4\x6f\x9a\x9a\x1a" "\xc7\xde\xa1\xea\x68\x45\xf9\xaa\x66\x23\x92\x0d\xac\xc1\x07\xf5\x32\x34" "\x8c\xc2\x11\x64\xef\xe7\x94\x87\x4e\xac\x73\x38\x1e\x96\x1f\x3d\x9c\x8c" "\x21\x57\x8f\xe3\x24\x50\x97\xc2\x80\xab\xe5\x14\x23\xb9\xf6\xcd\x72\xb5" "\xda\x6d\x02\x52\x80\x3c\x66\x73\x0c\xd5\xea\xc9\x07\xf0\x9b\x96\x95\x90" "\x63\x13\xf8\x87\x35\xfc\xe5\x11\x5d\xc8\x3e\xd7\x3d\x8e\xe4\xa9\x13\x22" "\x60\x8c\x6f\xc0\x1e\x1b\x9e\x16\x58\x7b\xb5\xf7\x21\x30\x3e\x6b\x89\xe5" "\xc5\x4d\x68\x0a\xc6\x6d\x09\xaf\x90\xdb\xf5\x00\x00\x00\x00\x00\x00\xfa" "\x08\xad\x06\x31\xc4\xb8\x39\x68\x8b\x22\xc4\xda\x2a\x6b\xc4\xcf\x45\x85" "\x4d\x22\x1a\x2d\x5f\x96\xbc\x64\x64\x7f\x15\xda\xa2\xba\x79\xcd\x0f\x42" "\x54\xed\x55\x21\x79\x12\xef\x84\xbd\x29\x27\xdf\x82\xfc\x06\x1a\xef\x29" "\x20\xc4\x9b\x2a\x90\x88\x6d\xa7\x55\x61\x17\x3f\xa1\x86\xcb\x7e\xe8\x6d" "\xd4\x28\x5c\x47\x21\xeb\x42\x8c\x95\x32\x96\xbb\x2f\x5d\x82\x5d\xa5\x4d" "\xbe\xf0\x7c\x1b\x34\x9b\x49\x01\xe0\x93\xd1\x3e\x6b\x9a\x00\x00\x00\x9b" "\x5b\x22\xe8\x87\xbc\x06\x1d\x40\xbc\xaf\x0a\xa1\x86\x23\xfd\x9b\x71\x79" "\xcc\xc6\x92\xba\x74\xb5\x31\xb6\x5c\x4d\xec\xf9\xd0\x80\xa8\xac\x7e\x82" "\xd4\xcd\xe1\x26\x7a\xa6\x4b\x2a\x94\xfd\x87\xa0\x09\xe6\x74\x2c\x2d\xdc" "\x3a\x9d\x7e\xcc\xbb\x18\x31\xb1\xfa\x21\x82\x77\xc2\x81\x4a\x91\xca\xb7" "\xcb\x59\xc6\x97\x16\x6d\x6f\x1b\xb1\xa3\x60\x47\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\xf9\xf9\xb4\xce\x7e\x87\x1f\x50\x70\x84\xc8\xc8\x8e\x06\x52\xde" "\xcb\xe5\x79\xb0\x3e\xd8\x4e\xa9\x45\x97\xdd\x10\x59\x62\x0a\x05\x0f\x69" "\xea\x03\xb9\x9b\x4e\x19\xd3\x5f\x4a\x3b\x54\xe9\x6a\xe2\x17\x2e\xff\xec" "\xec\x80\xf6\xba\xa4\xbf\x69\xa6\xeb\xf5\x39\x28\x82\xdf\x78\xb0\x98\x3e" "\x66\x2d\xc0\xcb\x64\xb7\x7f\x3f\x00\x6b\x6b\x25\x44\x31\x97\xae\x93\xf0" "\xbe\x6d\xe5\xa7\x03\xd0\x03\xf0\x07\x20\x94\x3c\x0e\x4b\x33\xaf\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x21\xa6\x88\xb2\xd7\x00\x7f\xcc\x4b\x59\xf7" "\x19\xaf\xb0\xb3\xb7\xe0\xae\xe3\x06\xca\x70\xfe\x42\xbf\x49\x84\xa6\x8f" "\x40\xe1\xfc\x04\x3a\x03\xa1\x7e\x47\x44\x35\x9b\x87\xdc\x27\xc8\x2d\x51" "\xcb\xeb\x64\xe5\x2a\x28\xda\xeb\x6a\x78\xd6\xfe\x06\x18\x1e\xcc\x84\x00" "\x00", 1837); *(uint64_t*)0x200000000090 = 0x200000000000; memcpy((void*)0x200000000000, "GPL\000", 4); *(uint32_t*)0x200000000098 = 5; *(uint32_t*)0x20000000009c = 0x252; *(uint64_t*)0x2000000000a0 = 0x20000000cf3d; *(uint32_t*)0x2000000000a8 = 0; *(uint32_t*)0x2000000000ac = 0; memset((void*)0x2000000000b0, 0, 16); *(uint32_t*)0x2000000000c0 = 0; *(uint32_t*)0x2000000000c4 = 0; *(uint32_t*)0x2000000000c8 = -1; *(uint32_t*)0x2000000000cc = 8; *(uint64_t*)0x2000000000d0 = 0; *(uint32_t*)0x2000000000d8 = 0; *(uint32_t*)0x2000000000dc = 0x10; *(uint64_t*)0x2000000000e0 = 0; *(uint32_t*)0x2000000000e8 = 0; *(uint32_t*)0x2000000000ec = 0; *(uint32_t*)0x2000000000f0 = -1; *(uint32_t*)0x2000000000f4 = 0; *(uint64_t*)0x2000000000f8 = 0; *(uint64_t*)0x200000000100 = 0; *(uint32_t*)0x200000000108 = 0x10; *(uint32_t*)0x20000000010c = 0; *(uint32_t*)0x200000000110 = 0; res = syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0x200000000080ul, /*size=*/0x48ul); if (res != -1) r[1] = res; // ioctl$PERF_EVENT_IOC_SET_BPF arguments: [ // fd: fd_perf (resource) // cmd: const = 0x40042408 (4 bytes) // prog: fd_bpf_prog (resource) // ] syscall(__NR_ioctl, /*fd=*/r[0], /*cmd=*/0x40042408, /*prog=*/r[1]); } 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; for (procid = 0; procid < 5; procid++) { if (fork() == 0) { loop(); } } sleep(1000000); return 0; }