skmsg: Lose offset info in sk_psock_skb_ingress
authorLiu Jian <liujian56@huawei.com>
Fri, 29 Oct 2021 14:12:14 +0000 (22:12 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Nov 2021 18:16:45 +0000 (19:16 +0100)
commitc47be68b31cf317f2b6d80839ac57ef6db325816
tree25d420c3273a604c9e54873982f8323da58440c5
parentb5c69b9fb5c4b7982dd31bf0adee353256e1bf3a
skmsg: Lose offset info in sk_psock_skb_ingress

[ Upstream commit 7303524e04af49a47991e19f895c3b8cdc3796c7 ]

If sockmap enable strparser, there are lose offset info in
sk_psock_skb_ingress(). If the length determined by parse_msg function is not
skb->len, the skb will be converted to sk_msg multiple times, and userspace
app will get the data multiple times.

Fix this by get the offset and length from strp_msg. And as Cong suggested,
add one bit in skb->_sk_redir to distinguish enable or disable strparser.

Fixes: 604326b41a6fb ("bpf, sockmap: convert to generic sk_msg interface")
Signed-off-by: Liu Jian <liujian56@huawei.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Cong Wang <cong.wang@bytedance.com>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20211029141216.211899-1-liujian56@huawei.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/skmsg.h
net/core/skmsg.c