Skip to content

Commit 520493f

Browse files
committed
tls: splice_read: fix record type check
We don't support splicing control records. TLS 1.3 changes moved the record type check into the decrypt if(). The skb may already be decrypted and still be an alert. Note that decrypt_skb_update() is idempotent and updates ctx->decrypted so the if() is pointless. Reorder the check for decryption errors with the content type check while touching them. This part is not really a bug, because if decryption failed in TLS 1.3 content type will be DATA, and for TLS 1.2 it will be correct. Nevertheless its strange to touch output before checking if the function has failed. Fixes: fedf201 ("net: tls: Refactor control message handling on recv") Signed-off-by: Jakub Kicinski <[email protected]>
1 parent ef0fc0b commit 520493f

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

net/tls/tls_sw.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,21 +2018,18 @@ ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos,
20182018
if (!skb)
20192019
goto splice_read_end;
20202020

2021-
if (!ctx->decrypted) {
2022-
err = decrypt_skb_update(sk, skb, NULL, &chunk, &zc, false);
2023-
2024-
/* splice does not support reading control messages */
2025-
if (ctx->control != TLS_RECORD_TYPE_DATA) {
2026-
err = -EINVAL;
2027-
goto splice_read_end;
2028-
}
2021+
err = decrypt_skb_update(sk, skb, NULL, &chunk, &zc, false);
2022+
if (err < 0) {
2023+
tls_err_abort(sk, -EBADMSG);
2024+
goto splice_read_end;
2025+
}
20292026

2030-
if (err < 0) {
2031-
tls_err_abort(sk, -EBADMSG);
2032-
goto splice_read_end;
2033-
}
2034-
ctx->decrypted = 1;
2027+
/* splice does not support reading control messages */
2028+
if (ctx->control != TLS_RECORD_TYPE_DATA) {
2029+
err = -EINVAL;
2030+
goto splice_read_end;
20352031
}
2032+
20362033
rxm = strp_msg(skb);
20372034

20382035
chunk = min_t(unsigned int, rxm->full_len, len);

0 commit comments

Comments
 (0)