linux/net/tls
Jakub Kicinski 6db015fc4b tls: handle data disappearing from under the TLS ULP
TLS expects that it owns the receive queue of the TCP socket.
This cannot be guaranteed in case the reader of the TCP socket
entered before the TLS ULP was installed, or uses some non-standard
read API (eg. zerocopy ones). Replace the WARN_ON() and a buggy
early exit (which leaves anchor pointing to a freed skb) with real
error handling. Wipe the parsing state and tell the reader to retry.

We already reload the anchor every time we (re)acquire the socket lock,
so the only condition we need to avoid is an out of bounds read
(not having enough bytes in the socket for previously parsed record len).

If some data was read from under TLS but there's enough in the queue
we'll reload and decrypt what is most likely not a valid TLS record.
Leading to some undefined behavior from TLS perspective (corrupting
a stream? missing an alert? missing an attack?) but no kernel crash
should take place.

Reported-by: William Liu <will@willsroot.io>
Reported-by: Savino Dicanosa <savy@syst3mfailure.io>
Link: https://lore.kernel.org/tFjq_kf7sWIG3A7CrCg_egb8CVsT_gsmHAK0_wxDPJXfIzxFAMxqmLwp3MlU5EHiet0AwwJldaaFdgyHpeIUCS-3m3llsmRzp9xIOBR4lAI=@syst3mfailure.io
Fixes: 84c61fe1a7 ("tls: rx: do not use the standard strparser")
Reviewed-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20250807232907.600366-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2025-08-12 18:59:05 -07:00
..
Kconfig net: skbuff: generalize the skb->decrypted bit 2024-04-06 17:34:31 +01:00
Makefile tls: rx: async: hold onto the input skb 2022-07-18 11:24:11 +01:00
tls.h tls: handle data disappearing from under the TLS ULP 2025-08-12 18:59:05 -07:00
tls_device.c tcp: move icsk_clean_acked to a better location 2025-03-24 09:55:18 -07:00
tls_device_fallback.c net/tls: use the new scatterwalk functions 2025-03-02 15:19:44 +08:00
tls_main.c net: tls: explicitly disallow disconnect 2025-04-08 11:38:49 +02:00
tls_proc.c tls: add counters for rekey 2024-12-16 12:47:30 +00:00
tls_strp.c tls: handle data disappearing from under the TLS ULP 2025-08-12 18:59:05 -07:00
tls_sw.c tls: handle data disappearing from under the TLS ULP 2025-08-12 18:59:05 -07:00
tls_toe.c tls: create an internal header 2022-07-08 18:38:45 -07:00
trace.c
trace.h move asm/unaligned.h to linux/unaligned.h 2024-10-02 17:23:23 -04:00