bpf: fix bpf_skb_adjust_net/bpf_skb_proto_xlat to deal with gso sctp skbs
authorDaniel Axtens <dja@axtens.net>
Sat, 3 Mar 2018 02:03:46 +0000 (03:03 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 3 Mar 2018 21:01:11 +0000 (13:01 -0800)
commitd02f51cbcf12b09ab945873e35046045875eed9a
tree986c3a4022275f49fde59e84ab1435ff738b8752
parent4a0c7191c75e94b0aaaa52855bf44d94bfe97403
bpf: fix bpf_skb_adjust_net/bpf_skb_proto_xlat to deal with gso sctp skbs

SCTP GSO skbs have a gso_size of GSO_BY_FRAGS, so any sort of
unconditionally mangling of that will result in nonsense value
and would corrupt the skb later on.

Therefore, i) add two helpers skb_increase_gso_size() and
skb_decrease_gso_size() that would throw a one time warning and
bail out for such skbs and ii) refuse and return early with an
error in those BPF helpers that are affected. We do need to bail
out as early as possible from there before any changes on the
skb have been performed.

Fixes: 6578171a7ff0 ("bpf: add bpf_skb_change_proto helper")
Co-authored-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Daniel Axtens <dja@axtens.net>
Cc: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Documentation/networking/segmentation-offloads.txt
include/linux/skbuff.h
net/core/filter.c