]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: fix sk_skb programs without skb->dev assigned
authorJohn Fastabend <john.fastabend@gmail.com>
Thu, 5 Jul 2018 15:49:59 +0000 (08:49 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 7 Jul 2018 22:19:29 +0000 (15:19 -0700)
commit3f5c1a81eb33953ee371ad85793f946cdd0fa11e
tree77b565cda20fbeeec014f9d7c63b48d1b9c14505
parentaed3bbd5c72f4b339e3858a20e39a0afe5170b2b
bpf: fix sk_skb programs without skb->dev assigned

Multiple BPF helpers in use by sk_skb programs calculate the max
skb length using the __bpf_skb_max_len function. However, this
calculates the max length using the skb->dev pointer which can be
NULL when an sk_skb program is paired with an sk_msg program.

To force this a sk_msg program needs to redirect into the ingress
path of a sock with an attach sk_skb program. Then the the sk_skb
program would need to call one of the helpers that adjust the skb
size.

To fix the null ptr dereference use SKB_MAX_ALLOC size if no dev
is available.

Fixes: 685b9c18b8d6 ("bpf: sockmap redirect ingress support")
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
net/core/filter.c