2 "bpf_map_ptr: read with negative offset rejected",
4 BPF_MOV64_REG(BPF_REG_1
, BPF_REG_10
),
5 BPF_LD_MAP_FD(BPF_REG_1
, 0),
6 BPF_LDX_MEM(BPF_DW
, BPF_REG_6
, BPF_REG_1
, -8),
7 BPF_MOV64_IMM(BPF_REG_0
, 1),
10 .fixup_map_array_48b
= { 1 },
11 .result_unpriv
= REJECT
,
12 .errstr_unpriv
= "bpf_array access is allowed only to CAP_PERFMON and CAP_SYS_ADMIN",
14 .errstr
= "R1 is bpf_array invalid negative access: off=-8",
17 "bpf_map_ptr: write rejected",
19 BPF_ST_MEM(BPF_DW
, BPF_REG_10
, -8, 0),
20 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
21 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
22 BPF_LD_MAP_FD(BPF_REG_1
, 0),
23 BPF_STX_MEM(BPF_DW
, BPF_REG_1
, BPF_REG_2
, 0),
24 BPF_MOV64_IMM(BPF_REG_0
, 1),
27 .fixup_map_array_48b
= { 3 },
28 .result_unpriv
= REJECT
,
29 .errstr_unpriv
= "bpf_array access is allowed only to CAP_PERFMON and CAP_SYS_ADMIN",
31 .errstr
= "only read from bpf_array is supported",
34 "bpf_map_ptr: read non-existent field rejected",
36 BPF_MOV64_IMM(BPF_REG_6
, 0),
37 BPF_LD_MAP_FD(BPF_REG_1
, 0),
38 BPF_LDX_MEM(BPF_W
, BPF_REG_6
, BPF_REG_1
, 1),
39 BPF_MOV64_IMM(BPF_REG_0
, 1),
42 .fixup_map_array_48b
= { 1 },
43 .result_unpriv
= REJECT
,
44 .errstr_unpriv
= "bpf_array access is allowed only to CAP_PERFMON and CAP_SYS_ADMIN",
46 .errstr
= "cannot access ptr member ops with moff 0 in struct bpf_map with off 1 size 4",
47 .flags
= F_NEEDS_EFFICIENT_UNALIGNED_ACCESS
,
50 "bpf_map_ptr: read ops field accepted",
52 BPF_MOV64_IMM(BPF_REG_6
, 0),
53 BPF_LD_MAP_FD(BPF_REG_1
, 0),
54 BPF_LDX_MEM(BPF_DW
, BPF_REG_6
, BPF_REG_1
, 0),
55 BPF_MOV64_IMM(BPF_REG_0
, 1),
58 .fixup_map_array_48b
= { 1 },
59 .result_unpriv
= REJECT
,
60 .errstr_unpriv
= "bpf_array access is allowed only to CAP_PERFMON and CAP_SYS_ADMIN",
65 "bpf_map_ptr: r = 0, map_ptr = map_ptr + r",
67 BPF_ST_MEM(BPF_DW
, BPF_REG_10
, -8, 0),
68 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
69 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
70 BPF_MOV64_IMM(BPF_REG_0
, 0),
71 BPF_LD_MAP_FD(BPF_REG_1
, 0),
72 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_0
),
73 BPF_RAW_INSN(BPF_JMP
| BPF_CALL
, 0, 0, 0, BPF_FUNC_map_lookup_elem
),
74 BPF_MOV64_IMM(BPF_REG_0
, 0),
77 .fixup_map_hash_16b
= { 4 },
81 "bpf_map_ptr: r = 0, r = r + map_ptr",
83 BPF_ST_MEM(BPF_DW
, BPF_REG_10
, -8, 0),
84 BPF_MOV64_REG(BPF_REG_2
, BPF_REG_10
),
85 BPF_ALU64_IMM(BPF_ADD
, BPF_REG_2
, -8),
86 BPF_MOV64_IMM(BPF_REG_1
, 0),
87 BPF_LD_MAP_FD(BPF_REG_0
, 0),
88 BPF_ALU64_REG(BPF_ADD
, BPF_REG_1
, BPF_REG_0
),
89 BPF_RAW_INSN(BPF_JMP
| BPF_CALL
, 0, 0, 0, BPF_FUNC_map_lookup_elem
),
90 BPF_MOV64_IMM(BPF_REG_0
, 0),
93 .fixup_map_hash_16b
= { 4 },