summaryrefslogtreecommitdiff
path: root/net/tls
diff options
context:
space:
mode:
authorSabrina Dubroca <sd@queasysnail.net>2025-10-14 11:16:56 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-10-23 16:16:32 +0200
commit071377a13834aba5507e85e72730f73736002bc7 (patch)
treebccdf6028e872a16b37aae0f4b5ea7f856a650f6 /net/tls
parent3dd3aa80e5af6e3082ad9199f135e0078a57e047 (diff)
downloadlinux-071377a13834aba5507e85e72730f73736002bc7.tar.gz
linux-071377a13834aba5507e85e72730f73736002bc7.tar.bz2
linux-071377a13834aba5507e85e72730f73736002bc7.zip
tls: trim encrypted message to match the plaintext on short splice
[ Upstream commit ce5af41e3234425a40974696682163edfd21128c ] During tls_sw_sendmsg_locked, we pre-allocate the encrypted message for the size we're expecting to send during the current iteration, but we may end up sending less, for example when splicing: if we're getting the data from small fragments of memory, we may fill up all the slots in the skmsg with less data than expected. In this case, we need to trim the encrypted message to only the length we actually need, to avoid pushing uninitialized bytes down the underlying TCP socket. Fixes: fe1e81d4f73b ("tls/sw: Support MSG_SPLICE_PAGES") Reported-by: Jann Horn <jannh@google.com> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net> Link: https://patch.msgid.link/66a0ae99c9efc15f88e9e56c1f58f902f442ce86.1760432043.git.sd@queasysnail.net Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/tls')
-rw-r--r--net/tls/tls_sw.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 435235a351e2..21276ac1f81d 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -1112,8 +1112,11 @@ alloc_encrypted:
goto send_end;
tls_ctx->pending_open_record_frags = true;
- if (sk_msg_full(msg_pl))
+ if (sk_msg_full(msg_pl)) {
full_record = true;
+ sk_msg_trim(sk, msg_en,
+ msg_pl->sg.size + prot->overhead_size);
+ }
if (full_record || eor)
goto copied;