]> git.baikalelectronics.ru Git - kernel.git/commit
bpf, sockmap: Avoid failures from skb_to_sgvec when skb has frag_list
authorJohn Fastabend <john.fastabend@gmail.com>
Mon, 16 Nov 2020 22:29:28 +0000 (14:29 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 17 Nov 2020 23:14:04 +0000 (00:14 +0100)
commitf6ee8d52239b5aa71f8374526bb9aa667c892d9a
treeaf1536961c439659efc1310db414eaece5c8a849
parent46c381cb53276131b0633d6b498d7c45f73e8dd6
bpf, sockmap: Avoid failures from skb_to_sgvec when skb has frag_list

When skb has a frag_list its possible for skb_to_sgvec() to fail. This
happens when the scatterlist has fewer elements to store pages than would
be needed for the initial skb plus any of its frags.

This case appears rare, but is possible when running an RX parser/verdict
programs exposed to the internet. Currently, when this happens we throw
an error, break the pipe, and kfree the msg. This effectively breaks the
application or forces it to do a retry.

Lets catch this case and handle it by doing an skb_linearize() on any
skb we receive with frags. At this point skb_to_sgvec should not fail
because the failing conditions would require frags to be in place.

Fixes: eaf66302e4568 ("bpf, sockmap: convert to generic sk_msg interface")
Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com>
Link: https://lore.kernel.org/bpf/160556576837.73229.14800682790808797635.stgit@john-XPS-13-9370
net/core/skmsg.c