linux/net/tls
Chuck Lever 78ded647d4 tls: Honor O_NONBLOCK in tls_sw_splice_read()
tls_sw_splice_read() takes its blocking behavior from
SPLICE_F_NONBLOCK alone. When splicing from a socket to a pipe,
do_splice() sets that flag from the pipe's O_NONBLOCK, not the
socket's. On a nonblocking socket, a splice(2) call without
SPLICE_F_NONBLOCK therefore sleeps in tls_rx_rec_wait() until a
record arrives. tcp_splice_read() instead reads sock->file->f_flags
and returns -EAGAIN.

Polling first does not avoid the sleep once tls_sw_splice_read()
consumes zero-length records, as it does after a later patch in this
series. tls_sw_sock_is_readable() reports the socket readable while
any record sits on rx_list, including a zero-length record that
delivers no bytes to the pipe. For TLS 1.3 the strparser announces a
record before decryption, when its plaintext length is still unknown,
so the readiness test cannot screen such a record out. A splice that
consumes the record and waits for the next stalls every connection
an event loop multiplexes.

An LLM audit of the TLS read paths found this defect.

Treat the socket's O_NONBLOCK as nonblocking too. A caller that
sets O_NONBLOCK on the socket and splices without SPLICE_F_NONBLOCK
now gets -EAGAIN where the splice blocked before. sendfile(2) from
a TLS socket changes the same way, because do_sendfile() leaves the
input file's O_NONBLOCK out of the splice flags. Both now behave as
they do on a plain TCP socket.

Fixes: c46234ebb4 ("tls: RX path for ktls")
Signed-off-by: Chuck Lever <cel@kernel.org>
Link: https://patch.msgid.link/20261027015215.605919-2-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2026-10-28 16:50:20 -07:00
..
Kconfig tls: remove tls_toe and the related driver 2026-06-12 16:43:10 -07:00
Makefile tls: remove tls_toe and the related driver 2026-06-12 16:43:10 -07:00
tls_device_fallback.c netmem: rename get/put_netmem() to netmem_inc/dec_ref() 2026-10-21 17:00:00 -07:00
tls_device.c tls: keep TX and RX hardware offload on the same device 2026-10-28 08:45:02 +00:00
tls_main.c tls: avoid field-spanning write when copying crypto info 2026-10-23 16:05:59 -07:00
tls_proc.c tls: snmp: do not use SNMP_MIB_SENTINEL anymore 2025-09-08 18:06:21 -07:00
tls_strp.c net: skbuff: replace skb_page_unref() and __skb_frag_unref() with skb_netmem_unref() 2026-10-20 11:52:46 +02:00
tls_sw.c tls: Honor O_NONBLOCK in tls_sw_splice_read() 2026-10-28 16:50:20 -07:00
tls.h tls: Suppress spurious saved_data_ready on all receive paths 2026-06-08 20:10:21 -07:00
trace.c
trace.h move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00