mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-06-29 23:43:21 -04:00
bpf: explicitly prohibit ctx_{in, out} in non-skb BPF_PROG_TEST_RUN
This should allow us later to extend BPF_PROG_TEST_RUN for non-skb case
and be sure that nobody is erroneously setting ctx_{in,out}.
Fixes: b0b9395d86
("bpf: support input __sk_buff context in BPF_PROG_TEST_RUN")
Reported-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
This commit is contained in:
parent
6b7a21140f
commit
947e8b595b
1 changed files with 6 additions and 0 deletions
|
@ -347,6 +347,9 @@ int bpf_prog_test_run_xdp(struct bpf_prog *prog, const union bpf_attr *kattr,
|
||||||
void *data;
|
void *data;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
if (kattr->test.ctx_in || kattr->test.ctx_out)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
data = bpf_test_init(kattr, size, XDP_PACKET_HEADROOM + NET_IP_ALIGN, 0);
|
data = bpf_test_init(kattr, size, XDP_PACKET_HEADROOM + NET_IP_ALIGN, 0);
|
||||||
if (IS_ERR(data))
|
if (IS_ERR(data))
|
||||||
return PTR_ERR(data);
|
return PTR_ERR(data);
|
||||||
|
@ -390,6 +393,9 @@ int bpf_prog_test_run_flow_dissector(struct bpf_prog *prog,
|
||||||
if (prog->type != BPF_PROG_TYPE_FLOW_DISSECTOR)
|
if (prog->type != BPF_PROG_TYPE_FLOW_DISSECTOR)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (kattr->test.ctx_in || kattr->test.ctx_out)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
data = bpf_test_init(kattr, size, NET_SKB_PAD + NET_IP_ALIGN,
|
data = bpf_test_init(kattr, size, NET_SKB_PAD + NET_IP_ALIGN,
|
||||||
SKB_DATA_ALIGN(sizeof(struct skb_shared_info)));
|
SKB_DATA_ALIGN(sizeof(struct skb_shared_info)));
|
||||||
if (IS_ERR(data))
|
if (IS_ERR(data))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue