Thread (10 messages) 10 messages, 1 author, 2d ago

[PATCH net-next v6 6/9] tls: Return copied data ahead of a run of empty records

flat view
WARM2d

From: Chuck Lever <cel@kernel.org>
Date: 2026-10-19 16:55:39
Also in: linux-kselftest
Subsystem: networking [general], networking [tls], the rest · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, John Fastabend, Sabrina Dubroca, Linus Torvalds

Revision v6 of 6 in this series.

Revisions (6)
  1. v1 [diff vs current]
  2. v2 [diff vs current]
  3. v3 [diff vs current]
  4. v4 [diff vs current]
  5. v5 [diff vs current]
  6. v6 current
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 <netdev-bot+sashiko@kernel.org>
Link: https://lore.kernel.org/r/179124254665.434549.12245680127262431659@kernel.org (local)
Signed-off-by: Chuck Lever <cel@kernel.org>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help