From 51ffabff7cb5896d5f7faa73236f6f0099004755 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 14 Jun 2023 16:16:02 +0000 Subject: [PATCH] Revert "bpf, sockmap: Handle fin correctly" This reverts commit 3a2129ebae359f354e5469916958c77e4871457d. It breaks the Android KABI and will be brought back at a later time when it is safe to do so. Bug: 161946584 Change-Id: Ib4d8c98270484b4d2c63e838bbe0d24c00642f87 Signed-off-by: Greg Kroah-Hartman --- net/ipv4/tcp_bpf.c | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c index 73c13642d47f..2e9547467edb 100644 --- a/net/ipv4/tcp_bpf.c +++ b/net/ipv4/tcp_bpf.c @@ -174,24 +174,6 @@ static int tcp_msg_wait_data(struct sock *sk, struct sk_psock *psock, return ret; } -static bool is_next_msg_fin(struct sk_psock *psock) -{ - struct scatterlist *sge; - struct sk_msg *msg_rx; - int i; - - msg_rx = sk_psock_peek_msg(psock); - i = msg_rx->sg.start; - sge = sk_msg_elem(msg_rx, i); - if (!sge->length) { - struct sk_buff *skb = msg_rx->skb; - - if (skb && TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN) - return true; - } - return false; -} - static int tcp_bpf_recvmsg_parser(struct sock *sk, struct msghdr *msg, size_t len, @@ -214,19 +196,6 @@ static int tcp_bpf_recvmsg_parser(struct sock *sk, lock_sock(sk); msg_bytes_ready: copied = sk_msg_recvmsg(sk, psock, msg, len, flags); - /* The typical case for EFAULT is the socket was gracefully - * shutdown with a FIN pkt. So check here the other case is - * some error on copy_page_to_iter which would be unexpected. - * On fin return correct return code to zero. - */ - if (copied == -EFAULT) { - bool is_fin = is_next_msg_fin(psock); - - if (is_fin) { - copied = 0; - goto out; - } - } if (!copied) { long timeo; int data;