Skip to content

Commit 8a08f98

Browse files
committed
WIP: 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
1 parent 3815a01 commit 8a08f98

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/core/filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9262,7 +9262,7 @@ static bool sock_addr_is_valid_access(int off, int size,
92629262
case offsetof(struct bpf_sock_addr, sk):
92639263
if (type != BPF_READ)
92649264
return false;
9265-
if (size != sizeof(__u64))
9265+
if (size != sizeof(void *))
92669266
return false;
92679267
info->reg_type = PTR_TO_SOCKET;
92689268
break;

0 commit comments

Comments
 (0)