diff options
| author | Pengcheng Yang <[email protected]> | 2022-11-29 10:40:40 +0000 |
|---|---|---|
| committer | Daniel Borkmann <[email protected]> | 2022-12-01 00:07:36 +0000 |
| commit | 9072931f020bfd907d6d89ee21ff1481cd78b407 (patch) | |
| tree | 5efdcf273715c4befe710602cef6106e98e7b283 /net/ipv4/tcp_bpf.c | |
| parent | bpf, sockmap: Fix missing BPF_F_INGRESS flag when using apply_bytes (diff) | |
| download | kernel-9072931f020bfd907d6d89ee21ff1481cd78b407.tar.gz kernel-9072931f020bfd907d6d89ee21ff1481cd78b407.zip | |
bpf, sockmap: Fix data loss caused by using apply_bytes on ingress redirect
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: 604326b41a6f ("bpf, sockmap: convert to generic sk_msg interface")
Signed-off-by: Pengcheng Yang <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Acked-by: Jakub Sitnicki <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'net/ipv4/tcp_bpf.c')
| -rw-r--r-- | net/ipv4/tcp_bpf.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c index 275c5ca9e04d..94aad3870c5f 100644 --- a/net/ipv4/tcp_bpf.c +++ b/net/ipv4/tcp_bpf.c @@ -45,8 +45,11 @@ static int bpf_tcp_ingress(struct sock *sk, struct sk_psock *psock, tmp->sg.end = i; if (apply) { apply_bytes -= size; - if (!apply_bytes) + if (!apply_bytes) { + if (sge->length) + sk_msg_iter_var_prev(i); break; + } } } while (i != msg->sg.end); |
