]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net/tls: Consume empty data records in tls_sw_read_sock()
authorChuck Lever <cel@kernel.org>
Tue, 30 Jun 2026 19:15:51 +0000 (15:15 -0400)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 7 Jul 2026 08:12:11 +0000 (10:12 +0200)
A peer may send a zero-length TLS application_data record; TLS 1.3
explicitly permits these as a traffic-analysis countermeasure (RFC
8446, Section 5.1). After decryption such a record has full_len ==
0. tls_sw_read_sock() hands it to the read_actor, which has no
payload to consume and returns zero. The loop treats a zero return
as backpressure (used <= 0), requeues the skb at the head of
rx_list, and stops. rx_list is serviced head-first on the next
call, so the empty record is dequeued, fails the same way, and is
requeued again; every later record on the connection is blocked
behind it.

tls_sw_recvmsg() does not stall on this: a zero-length data record
copies nothing and falls through to consume_skb(). Mirror that in
the read_sock() path by recognizing an empty data record before
the actor runs, consuming it, and continuing.

Fixes: 662fbcec32f4 ("net/tls: implement ->read_sock()")
Signed-off-by: Chuck Lever <cel@kernel.org>
Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>
Link: https://patch.msgid.link/20260630191551.875664-1-cel@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/tls/tls_sw.c

index 9324e4ed20a3eead461707df793d390482902b39..d4afc90fd7966ebf291c4962374295b784f9f7d0 100644 (file)
@@ -2115,6 +2115,17 @@ int tls_sw_read_sock(struct sock *sk, read_descriptor_t *desc,
                        goto read_sock_requeue;
                }
 
+               /* An empty data record (legal in TLS 1.3) gives a zero
+                * read_actor return, indistinguishable from the consumer
+                * stalling; the used <= 0 path would requeue it at the
+                * head of rx_list and block all later records. Consume it
+                * here instead.
+                */
+               if (rxm->full_len == 0) {
+                       consume_skb(skb);
+                       continue;
+               }
+
                used = read_actor(desc, skb, rxm->offset, rxm->full_len);
                if (used <= 0) {
                        if (!copied)