Commit 1e7e356
committed
bpf: Fix sock_addr_is_valid_access() for 32-bit
Support 32-bit pointers and fix errors like:
root@qemu-armhf:/usr/libexec/kselftests-bpf# ./test_progs -w 0 -a socket_cookie
libbpf: prog 'set_cookie': BPF program load failed: -EACCES
libbpf: prog 'set_cookie': -- BEGIN PROG LOAD LOG --
0: R1=ctx() R10=fp0
; if (ctx->family != AF_INET6 || ctx->user_family != AF_INET6) @ socket_cookie_prog.c:37
0: (61) r2 = *(u32 *)(r1 +28) ; R1=ctx() R2_w=scalar(smin=0,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff))
1: (56) if w2 != 0xa goto pc+16 ; R2_w=10
2: (61) r2 = *(u32 *)(r1 +0) ; R1=ctx() R2_w=scalar(smin=0,smax=umax=0xffffffff,var_off=(0x0; 0xffffffff))
3: (56) if w2 != 0xa goto pc+14 ; R2_w=10
; p = bpf_sk_storage_get(&socket_cookies, ctx->sk, 0, @ socket_cookie_prog.c:40
4: (61) r2 = *(u32 *)(r1 +64)
invalid bpf_context access off=64 size=4 insn_idx=4 is_valid_access=c096ceec
processed 5 insns (limit 1000000) max_states_per_insn 0 total_states 0 peak_states 0 mark_read 0
-- END PROG LOAD LOG --
libbpf: prog 'set_cookie': failed to load: -EACCES
libbpf: failed to load object 'socket_cookie_prog'
libbpf: failed to load BPF skeleton 'socket_cookie_prog': -EACCES
test_socket_cookie:FAIL:skel_open unexpected error: -13
torvalds#366 socket_cookie:FAIL
Fixes: fb85c4a ("bpf: export bpf_sock for BPF_PROG_TYPE_CGROUP_SOCK_ADDR prog type")
Signed-off-by: Tony Ambardar <tony.ambardar@gmail.com>1 parent 3263881 commit 1e7e356
1 file changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9268 | 9268 | | |
9269 | 9269 | | |
9270 | 9270 | | |
9271 | | - | |
| 9271 | + | |
9272 | 9272 | | |
9273 | 9273 | | |
9274 | | - | |
| 9274 | + | |
9275 | 9275 | | |
9276 | 9276 | | |
9277 | 9277 | | |
| |||
0 commit comments