Message ID | 20210708080409.73525-1-xuanzhuo@linux.alibaba.com |
---|---|
State | New |
Headers | show |
Series | [bpf] bpf: fix for BUG: kernel NULL pointer dereference, address: 0000000000000000 | expand |
On 7/8/21 10:04 AM, Xuan Zhuo wrote: > These two types of xdp prog(BPF_XDP_DEVMAP, BPF_XDP_CPUMAP) will not be > executed directly in the driver, we should not directly run these two > XDP progs here. To run these two situations, there must be some special > preparations, otherwise it may cause kernel exceptions. Applied, thanks!
diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c index aa47af349ba8..17227e0b277b 100644 --- a/net/bpf/test_run.c +++ b/net/bpf/test_run.c @@ -701,6 +701,12 @@ int bpf_prog_test_run_xdp(struct bpf_prog *prog, const union bpf_attr *kattr, void *data; int ret; + if (prog->expected_attach_type == BPF_XDP_DEVMAP) + return -EINVAL; + + if (prog->expected_attach_type == BPF_XDP_CPUMAP) + return -EINVAL; + if (kattr->test.ctx_in || kattr->test.ctx_out) return -EINVAL;