netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] tls: check RCV_SHUTDOWN in tls_wait_data
@ 2018-07-18 23:22 Doron Roberts-Kedes
  2018-07-20 21:40 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Doron Roberts-Kedes @ 2018-07-18 23:22 UTC (permalink / raw)
  To: David S . Miller; +Cc: Dave Watson, netdev, Doron Roberts-Kedes

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@fb.com>
Signed-off-by: Doron Roberts-Kedes <doronrk@fb.com>
---
 net/tls/tls_sw.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index ef15e35232dd..f90c4391f859 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -647,6 +647,9 @@ static struct sk_buff *tls_wait_data(struct sock *sk, int flags,
 			return NULL;
 		}
 
+		if (sk->sk_shutdown & RCV_SHUTDOWN)
+			return NULL;
+
 		if (sock_flag(sk, SOCK_DONE))
 			return NULL;
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] tls: check RCV_SHUTDOWN in tls_wait_data
  2018-07-18 23:22 [PATCH net] tls: check RCV_SHUTDOWN in tls_wait_data Doron Roberts-Kedes
@ 2018-07-20 21:40 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-07-20 21:40 UTC (permalink / raw)
  To: doronrk; +Cc: davejwatson, netdev

From: Doron Roberts-Kedes <doronrk@fb.com>
Date: Wed, 18 Jul 2018 16:22:27 -0700

> 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@fb.com>
> Signed-off-by: Doron Roberts-Kedes <doronrk@fb.com>

Applied and queued up for -stable, thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-07-20 22:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-18 23:22 [PATCH net] tls: check RCV_SHUTDOWN in tls_wait_data Doron Roberts-Kedes
2018-07-20 21:40 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).