Commit 986fe2f
committed
selftests/bpf: Fix map_kptr/correct_btf_id_check_size on 32-bit
The test hard-codes an expected result string assuming 64-bit pointers are
used in 'struct prog_test_ref_kfunc'. Update the string with a regex that
also matches on 32-bit systems, to avoid errors such as (e.g. armhf):
run_subtest:PASS:obj_open_mem 0 nsec
libbpf: prog 'correct_btf_id_check_size': BPF program load failed: -EACCES
libbpf: prog 'correct_btf_id_check_size': failed to load: -EACCES
libbpf: failed to load object 'map_kptr_fail'
run_subtest:PASS:unexpected_load_success 0 nsec
validate_msgs:FAIL:768 expect_msg
VERIFIER LOG:
=============
0: R1=ctx() R10=fp0
; int correct_btf_id_check_size(struct __sk_buff *ctx) @ map_kptr_fail.c:168
0: (b4) w6 = 0 ; R6_w=0
; int key = 0; @ map_kptr_fail.c:172
1: (63) *(u32 *)(r10 -4) = r6 ; R6_w=0 R10=fp0 fp-8=0000????
2: (bf) r2 = r10 ; R2_w=fp0 R10=fp0
3: (07) r2 += -4 ; R2_w=fp-4
; v = bpf_map_lookup_elem(&array_map, &key); @ map_kptr_fail.c:174
4: (18) r1 = 0xc4068a00 ; R1_w=map_ptr(map=array_map,ks=4,vs=32)
6: (85) call bpf_map_lookup_elem#1 ; R0_w=map_value(map=array_map,ks=4,vs=32)
; if (!v) @ map_kptr_fail.c:175
7: (15) if r0 == 0x0 goto pc+3 ; R0_w=map_value(map=array_map,ks=4,vs=32)
; p = v->unref_ptr; @ map_kptr_fail.c:178
8: (79) r1 = *(u64 *)(r0 +8) ; R0=map_value(map=array_map,ks=4,vs=32) R
1=untrusted_ptr_or_null_prog_test_ref_kfunc(id=1)
; if (!p) @ map_kptr_fail.c:179
9: (15) if r1 == 0x0 goto pc+1 ; R1=untrusted_ptr_prog_test_ref_kfunc()
; return *(int *)((void *)p + bpf_core_type_size(struct prog_test_ref_kfunc)); @
map_kptr_fail.c:181
10: (61) r6 = *(u32 *)(r1 +24)
access beyond struct prog_test_ref_kfunc at off 24 size 4
processed 10 insns (limit 1000000) max_states_per_insn 0 total_states 1 peak_sta
tes 1 mark_read 1
=============
EXPECTED SUBSTR: 'access beyond struct prog_test_ref_kfunc at off 32 size 4'
torvalds#187/9 map_kptr/correct_btf_id_check_size:FAIL
Signed-off-by: Tony Ambardar <tony.ambardar@gmail.com>1 parent 2390b2f commit 986fe2f
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | | - | |
| 167 | + | |
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| |||
0 commit comments