Skip to content

Commit ce5af41

Browse files
qsnkuba-moo
authored andcommitted
tls: trim encrypted message to match the plaintext on short splice
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: fe1e81d ("tls/sw: Support MSG_SPLICE_PAGES") Reported-by: Jann Horn <[email protected]> Signed-off-by: Sabrina Dubroca <[email protected]> Link: https://patch.msgid.link/66a0ae99c9efc15f88e9e56c1f58f902f442ce86.1760432043.git.sd@queasysnail.net Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 0c3f2e6 commit ce5af41

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

net/tls/tls_sw.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,8 +1112,11 @@ static int tls_sw_sendmsg_locked(struct sock *sk, struct msghdr *msg,
11121112
goto send_end;
11131113
tls_ctx->pending_open_record_frags = true;
11141114

1115-
if (sk_msg_full(msg_pl))
1115+
if (sk_msg_full(msg_pl)) {
11161116
full_record = true;
1117+
sk_msg_trim(sk, msg_en,
1118+
msg_pl->sg.size + prot->overhead_size);
1119+
}
11171120

11181121
if (full_record || eor)
11191122
goto copied;

0 commit comments

Comments
 (0)