linux-stable/net/tls
Jakub Kicinski 059ec8287f net: tls: avoid discarding data on record close
commit 6b47808f22 upstream.

TLS records end with a 16B tag. For TLS device offload we only
need to make space for this tag in the stream, the device will
generate and replace it with the actual calculated tag.

Long time ago the code would just re-reference the head frag
which mostly worked but was suboptimal because it prevented TCP
from combining the record into a single skb frag. I'm not sure
if it was correct as the first frag may be shorter than the tag.

The commit under fixes tried to replace that with using the page
frag and if the allocation failed rolling back the data, if record
was long enough. It achieves better fragment coalescing but is
also buggy.

We don't roll back the iterator, so unless we're at the end of
send we'll skip the data we designated as tag and start the
next record as if the rollback never happened.
There's also the possibility that the record was constructed
with MSG_MORE and the data came from a different syscall and
we already told the user space that we "got it".

Allocate a single dummy page and use it as fallback.

Found by code inspection, and proven by forcing allocation
failures.

Fixes: e7b159a48b ("net/tls: remove the record tail optimization")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-08-16 18:27:27 +02:00
..
Kconfig net/tls: Select SOCK_RX_QUEUE_MAPPING from TLS_DEVICE 2021-02-11 19:08:06 -08:00
Makefile tls: rx: async: hold onto the input skb 2022-07-18 11:24:11 +01:00
tls.h tls: rx: strp: preserve decryption status of skbs when needed 2023-06-05 09:26:18 +02:00
tls_device.c net: tls: avoid discarding data on record close 2023-08-16 18:27:27 +02:00
tls_device_fallback.c net/tls: Fix memory leak in tls_enc_skb() and tls_sw_fallback_init() 2022-11-11 20:08:17 -08:00
tls_main.c net: deal with most data-races in sk_wait_event() 2023-05-24 17:32:32 +01:00
tls_proc.c tls: rx: add counter for NoPad violations 2022-07-11 19:48:33 -07:00
tls_strp.c tls: improve lockless access safety of tls_err_abort() 2023-06-09 10:34:01 +02:00
tls_sw.c tls: rx: strp: don't use GFP_KERNEL in softirq context 2023-06-09 10:34:29 +02:00
tls_toe.c tls: create an internal header 2022-07-08 18:38:45 -07:00
trace.c
trace.h