Once tls_sw_recvmsg() has copied enough data to meet the receive
low-water mark, the receive loop continues only while another
record is ready. A zero-length application_data record is consumed
without advancing len, so a peer that follows data with a stream of
empty records keeps the reader in the loop. The reader does not get
the data already copied until the stream stops or a signal is
pending. The delay has not been reproduced.

Leave the receive loop at an empty record once the low-water mark
is met. A reader that has copied nothing still reads empty records
for as long as they arrive.

Fixes: 04b25a5411f9 ("net/tls: fix no wakeup on partial reads")
Suggested-by: sashiko-bot <[email protected]>
Link: 
https://lore.kernel.org/r/[email protected]
Signed-off-by: Chuck Lever <[email protected]>
---
 net/tls/tls_sw.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 550308410ff1..599bf1f21189 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -1933,6 +1933,12 @@ int tls_sw_recvmsg(struct sock *sk,
                        /* An empty record still marks a boundary. */
                        msg->msg_flags |= MSG_EOR;
 
+                       /* Return data already copied instead of holding it
+                        * through a run of empty records.
+                        */
+                       if (decrypted + copied >= target)
+                               break;
+
                        /* A run of empty records advances neither loop bound,
                         * and tls_rx_rec_wait() tests for a signal only after
                         * sleeping.

-- 
2.55.0


Reply via email to