// https://syzkaller.appspot.com/bug?id=1b15111009caee854b129be233db379ff28ffb20 // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #ifndef __NR_bpf #define __NR_bpf 321 #endif #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)))) uint64_t r[1] = {0xffffffffffffffff}; 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; 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 = 0x3 (4 bytes) // ninsn: bytesize8 = 0x3 (4 bytes) // insns: ptr[in, bpf_instructions] { // union bpf_instructions { // framed: bpf_framed_program { // initr0: bpf_insn_init_r0 { // code: const = 0x18 (1 bytes) // dst: const = 0x0 (0 bytes) // src: const = 0x0 (1 bytes) // off: const = 0x0 (2 bytes) // imm: int32 = 0x88f (4 bytes) // code2: const = 0x0 (1 bytes) // regs2: const = 0x0 (1 bytes) // off2: const = 0x0 (2 bytes) // imm2: int32 = 0x0 (4 bytes) // } // body: array[bpf_insn] { // } // exit: bpf_insn_exit { // code: const = 0x95 (1 bytes) // regs: const = 0x0 (1 bytes) // off: const = 0x0 (2 bytes) // imm: const = 0x0 (4 bytes) // } // } // } // } // 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 = 0xb (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 { // sched_cls: sched_cls_attach_types = 0x0 (4 bytes) // } // btf_fd: fd_btf (resource) // func_info_rec_size: const = 0x0 (4 bytes) // func_info: nil // func_info_cnt: len = 0x0 (4 bytes) // line_info_rec_size: const = 0x0 (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 = 0x0 (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 = 0x94 (8 bytes) // ] // returns fd_bpf_prog *(uint32_t*)0x2000000003c0 = 3; *(uint32_t*)0x2000000003c4 = 3; *(uint64_t*)0x2000000003c8 = 0x200000000100; *(uint8_t*)0x200000000100 = 0x18; STORE_BY_BITMASK(uint8_t, , 0x200000000101, 0, 0, 4); STORE_BY_BITMASK(uint8_t, , 0x200000000101, 0, 4, 4); *(uint16_t*)0x200000000102 = 0; *(uint32_t*)0x200000000104 = 0x88f; *(uint8_t*)0x200000000108 = 0; *(uint8_t*)0x200000000109 = 0; *(uint16_t*)0x20000000010a = 0; *(uint32_t*)0x20000000010c = 0; *(uint8_t*)0x200000000110 = 0x95; *(uint8_t*)0x200000000111 = 0; *(uint16_t*)0x200000000112 = 0; *(uint32_t*)0x200000000114 = 0; *(uint64_t*)0x2000000003d0 = 0x200000000500; memcpy((void*)0x200000000500, "GPL\000", 4); *(uint32_t*)0x2000000003d8 = 0; *(uint32_t*)0x2000000003dc = 0; *(uint64_t*)0x2000000003e0 = 0; *(uint32_t*)0x2000000003e8 = 0; *(uint32_t*)0x2000000003ec = 0xb; memset((void*)0x2000000003f0, 0, 16); *(uint32_t*)0x200000000400 = 0; *(uint32_t*)0x200000000404 = 0; *(uint32_t*)0x200000000408 = -1; *(uint32_t*)0x20000000040c = 0; *(uint64_t*)0x200000000410 = 0; *(uint32_t*)0x200000000418 = 0; *(uint32_t*)0x20000000041c = 0; *(uint64_t*)0x200000000420 = 0; *(uint32_t*)0x200000000428 = 0; *(uint32_t*)0x20000000042c = 0; *(uint32_t*)0x200000000430 = 0; *(uint32_t*)0x200000000434 = 0; *(uint64_t*)0x200000000438 = 0; *(uint64_t*)0x200000000440 = 0; *(uint32_t*)0x200000000448 = 0; *(uint32_t*)0x20000000044c = 0; *(uint32_t*)0x200000000450 = 0; res = syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0x2000000003c0ul, /*size=*/0x94ul); if (res != -1) r[0] = res; // close arguments: [ // fd: fd (resource) // ] syscall(__NR_close, /*fd=*/3); // 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 = 0x1 (4 bytes) // ninsn: bytesize8 = 0x8 (4 bytes) // insns: ptr[inout, array[ANYUNION]] { // array[ANYUNION] { // union ANYUNION { // ANYBLOB: buffer: {7a 0a f8 ff 75 25 70 25 bf a1 00 00 00 00 00 // 00 07 01 00 00 f8 ff ff ff b7 02 00 00 05 00 00 00 bf 13 00 00 // 00 00 00 00 85 00 00 00 06 00 00 00 b7 00 00 00 00 00 00 00 95 // 00 00 ff 00 00 00 00} (length 0x40) // } // } // } // 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 = 0x48 (8 bytes) // ] // returns fd_bpf_prog *(uint32_t*)0x200000000000 = 1; *(uint32_t*)0x200000000004 = 8; *(uint64_t*)0x200000000008 = 0x200000001000; memcpy((void*)0x200000001000, "\x7a\x0a\xf8\xff\x75\x25\x70\x25\xbf\xa1\x00\x00\x00\x00\x00\x00\x07" "\x01\x00\x00\xf8\xff\xff\xff\xb7\x02\x00\x00\x05\x00\x00\x00\xbf\x13" "\x00\x00\x00\x00\x00\x00\x85\x00\x00\x00\x06\x00\x00\x00\xb7\x00\x00" "\x00\x00\x00\x00\x00\x95\x00\x00\xff\x00\x00\x00\x00", 64); *(uint64_t*)0x200000000010 = 0x200000000100; memcpy((void*)0x200000000100, "GPL\000", 4); *(uint32_t*)0x200000000018 = 0; *(uint32_t*)0x20000000001c = 0; *(uint64_t*)0x200000000020 = 0; *(uint32_t*)0x200000000028 = 0; *(uint32_t*)0x20000000002c = 0; memset((void*)0x200000000030, 0, 16); *(uint32_t*)0x200000000040 = 0; *(uint32_t*)0x200000000044 = 0; *(uint32_t*)0x200000000048 = -1; *(uint32_t*)0x20000000004c = 8; *(uint64_t*)0x200000000050 = 0; *(uint32_t*)0x200000000058 = 0; *(uint32_t*)0x20000000005c = 0x10; *(uint64_t*)0x200000000060 = 0; *(uint32_t*)0x200000000068 = 0; *(uint32_t*)0x20000000006c = 0; *(uint32_t*)0x200000000070 = -1; *(uint32_t*)0x200000000074 = 0; *(uint64_t*)0x200000000078 = 0; *(uint64_t*)0x200000000080 = 0; *(uint32_t*)0x200000000088 = 0x10; *(uint32_t*)0x20000000008c = 0; *(uint32_t*)0x200000000090 = 0; syscall(__NR_bpf, /*cmd=*/5ul, /*arg=*/0x200000000000ul, /*size=*/0x48ul); // bpf$BPF_PROG_TEST_RUN arguments: [ // cmd: const = 0xa (8 bytes) // arg: ptr[in, bpf_test_prog_arg] { // bpf_test_prog_arg { // prog: fd_bpf_prog (resource) // retval: const = 0x0 (4 bytes) // insizedata: len = 0x28 (4 bytes) // outsizedata: len = 0x0 (4 bytes) // indata: ptr[in, buffer] { // buffer: {e3 00 80 67 00 00 ec 67 83 87 17 bd 86 dd} (length 0xe) // } // outdata: nil // repeat: int32 = 0x401 (4 bytes) // dur: const = 0x0 (4 bytes) // insizectx: len = 0x0 (4 bytes) // outsizectx: len = 0x0 (4 bytes) // inctx: nil // outctx: nil // flags: bpf_prog_test_run_flags = 0x0 (4 bytes) // cpu: const = 0x0 (4 bytes) // batch_size: int32 = 0x0 (4 bytes) // pad = 0x0 (4 bytes) // } // } // size: len = 0x50 (8 bytes) // ] *(uint32_t*)0x200000000040 = r[0]; *(uint32_t*)0x200000000044 = 0; *(uint32_t*)0x200000000048 = 0x28; *(uint32_t*)0x20000000004c = 0; *(uint64_t*)0x200000000050 = 0x2000000000c0; memcpy((void*)0x2000000000c0, "\xe3\x00\x80\x67\x00\x00\xec\x67\x83\x87\x17\xbd\x86\xdd", 14); *(uint64_t*)0x200000000058 = 0; *(uint32_t*)0x200000000060 = 0x401; *(uint32_t*)0x200000000064 = 0; *(uint32_t*)0x200000000068 = 0; *(uint32_t*)0x20000000006c = 0; *(uint64_t*)0x200000000070 = 0; *(uint64_t*)0x200000000078 = 0; *(uint32_t*)0x200000000080 = 0; *(uint32_t*)0x200000000084 = 0; *(uint32_t*)0x200000000088 = 0; syscall(__NR_bpf, /*cmd=*/0xaul, /*arg=*/0x200000000040ul, /*size=*/0x50ul); return 0; }