diff options
author | Andrii Nakryiko <andrii@kernel.org> | 2021-08-04 08:37:50 -0700 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2021-08-04 23:55:00 +0200 |
commit | 6d4eb36d65979ad48f4b05c3309e0c74f04e5ac6 (patch) | |
tree | 466bd7717cf94a44256039bb36c4cc1e28d0164c /net | |
parent | 83f31535565c63ac4f62c7b8592210929a630d3d (diff) | |
download | linux-6d4eb36d65979ad48f4b05c3309e0c74f04e5ac6.tar.bz2 |
bpf: Fix bpf_prog_test_run_xdp logic after incorrect merge resolution
During recent net into net-next merge ([0]) a piece of old logic ([1]) got
reintroduced accidentally while resolving merge conflict between bpf's [2]
and bpf-next's [3]. This check was removed in bpf-next tree to allow extra
ctx_in parameter passed for XDP test runs. Reinstating the check breaks
bpf_prog_test_run_xdp logic and causes a corresponding xdp_context_test_run
selftest failure. Fix by removing the check and allow ctx_in for XDP test
runs.
[0] 5af84df962dd ("Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net")
[1] 947e8b595b82 ("bpf: explicitly prohibit ctx_{in, out} in non-skb BPF_PROG_TEST_RUN")
[2] 5e21bb4e8125 ("bpf, test: fix NULL pointer dereference on invalid expected_attach_type")
[3] 47316f4a3053 ("bpf: Support input xdp_md context in BPF_PROG_TEST_RUN")
Fixes: 5af84df962dd ("Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/bpf/test_run.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c index 695449088e42..335e1d8c17f8 100644 --- a/net/bpf/test_run.c +++ b/net/bpf/test_run.c @@ -763,8 +763,7 @@ int bpf_prog_test_run_xdp(struct bpf_prog *prog, const union bpf_attr *kattr, if (prog->expected_attach_type == BPF_XDP_DEVMAP || prog->expected_attach_type == BPF_XDP_CPUMAP) return -EINVAL; - if (kattr->test.ctx_in || kattr->test.ctx_out) - return -EINVAL; + ctx = bpf_ctx_init(kattr, sizeof(struct xdp_md)); if (IS_ERR(ctx)) return PTR_ERR(ctx); |