Skip to content

Commit ed3e469

Browse files
mtardyAlexei Starovoitov
authored andcommitted
bpf: fix cgroup_skb prog test run direct packet access
This is needed in the context of Tetragon to test cgroup_skb programs using BPF_PROG_TEST_RUN with direct packet access. Commit b39b5f4 ("bpf: add cg_skb_is_valid_access for BPF_PROG_TYPE_CGROUP_SKB") added direct packet access for cgroup_skb programs and following commit 2cb494a ("bpf: add tests for direct packet access from CGROUP_SKB") added tests to the verifier to ensure that access to skb fields was possible and also fixed bpf_prog_test_run_skb. However, is_direct_pkt_access was never set to true for this program type, so data pointers were not computed when using prog_test_run, making data_end always equal to zero (data_meta is not accessible for cgroup_skb). Signed-off-by: Mahe Tardy <mahe.tardy@gmail.com> Link: https://lore.kernel.org/r/20241125152603.375898-1-mahe.tardy@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent 98ebe5e commit ed3e469

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

net/bpf/test_run.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,7 @@ int bpf_prog_test_run_skb(struct bpf_prog *prog, const union bpf_attr *kattr,
10181018
case BPF_PROG_TYPE_LWT_IN:
10191019
case BPF_PROG_TYPE_LWT_OUT:
10201020
case BPF_PROG_TYPE_LWT_XMIT:
1021+
case BPF_PROG_TYPE_CGROUP_SKB:
10211022
is_direct_pkt_access = true;
10221023
break;
10231024
default:

0 commit comments

Comments
 (0)