[PATCH 4.17 26/66] tls: check RCV_SHUTDOWN in tls_wait_data
From: Greg Kroah-Hartman
Date: Fri Jul 27 2018 - 05:48:01 EST
4.17-stable review patch. If anyone has any objections, please let me know.
------------------
From: Doron Roberts-Kedes <doronrk@xxxxxx>
[ Upstream commit fcf4793e278edede8fcd748198d12128037e526c ]
The current code does not check sk->sk_shutdown & RCV_SHUTDOWN.
tls_sw_recvmsg may return a positive value in the case where bytes have
already been copied when the socket is shutdown. sk->sk_err has been
cleared, causing the tls_wait_data to hang forever on a subsequent
invocation. Checking sk->sk_shutdown & RCV_SHUTDOWN, as in tcp_recvmsg,
fixes this problem.
Fixes: c46234ebb4d1 ("tls: RX path for ktls")
Acked-by: Dave Watson <davejwatson@xxxxxx>
Signed-off-by: Doron Roberts-Kedes <doronrk@xxxxxx>
Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
net/tls/tls_sw.c | 3 +++
1 file changed, 3 insertions(+)
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -646,6 +646,9 @@ static struct sk_buff *tls_wait_data(str
return NULL;
}
+ if (sk->sk_shutdown & RCV_SHUTDOWN)
+ return NULL;
+
if (sock_flag(sk, SOCK_DONE))
return NULL;