Patch "bpf, sockmap: Fix data loss caused by using apply_bytes on ingress redirect" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    bpf, sockmap: Fix data loss caused by using apply_bytes on ingress redirect

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     bpf-sockmap-fix-data-loss-caused-by-using-apply_byte.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit dbe18f2cbaf35b9d673e7cc28ffa32267384b6d2
Author: Pengcheng Yang <yangpc@xxxxxxxxxx>
Date:   Tue Nov 29 18:40:40 2022 +0800

    bpf, sockmap: Fix data loss caused by using apply_bytes on ingress redirect
    
    [ Upstream commit 9072931f020bfd907d6d89ee21ff1481cd78b407 ]
    
    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 <yangpc@xxxxxxxxxx>
    Signed-off-by: Daniel Borkmann <daniel@xxxxxxxxxxxxx>
    Acked-by: Jakub Sitnicki <jakub@xxxxxxxxxxxxxx>
    Link: https://lore.kernel.org/bpf/1669718441-2654-4-git-send-email-yangpc@xxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c
index 027f7f9256e1..6a1685461f89 100644
--- a/net/ipv4/tcp_bpf.c
+++ b/net/ipv4/tcp_bpf.c
@@ -125,8 +125,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);
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux