mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-03 07:38:10 +00:00
bpf, sockmap: Fix data loss caused by using apply_bytes on ingress redirect
[ Upstream commit9072931f02
] Use apply_bytes on ingress redirect, when apply_bytes is less than the length of msg data, some data may be skipped and lost in bpf_tcp_ingress(). If there is still data in the scatterlist that has not been consumed, we cannot move the msg iter. Fixes:604326b41a
("bpf, sockmap: convert to generic sk_msg interface") Signed-off-by: Pengcheng Yang <yangpc@wangsu.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Jakub Sitnicki <jakub@cloudflare.com> Link: https://lore.kernel.org/bpf/1669718441-2654-4-git-send-email-yangpc@wangsu.com Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
6105ed3598
commit
7201e4f4f5
1 changed files with 4 additions and 1 deletions
|
@ -45,8 +45,11 @@ static int bpf_tcp_ingress(struct sock *sk, struct sk_psock *psock,
|
||||||
tmp->sg.end = i;
|
tmp->sg.end = i;
|
||||||
if (apply) {
|
if (apply) {
|
||||||
apply_bytes -= size;
|
apply_bytes -= size;
|
||||||
if (!apply_bytes)
|
if (!apply_bytes) {
|
||||||
|
if (sge->length)
|
||||||
|
sk_msg_iter_var_prev(i);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} while (i != msg->sg.end);
|
} while (i != msg->sg.end);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue