Skip to content

Commit e243e51

Browse files
author
Sabrina Dubroca
committed
tls: don't reset prot->aad_size and prot->tail_size for TLS_HW
JIRA: https://issues.redhat.com/browse/RHEL-14902 commit b7c4f57 Author: Sabrina Dubroca <[email protected]> Date: Fri Oct 20 16:00:55 2023 +0200 tls: don't reset prot->aad_size and prot->tail_size for TLS_HW Prior to commit 1a074f7 ("tls: also use init_prot_info in tls_set_device_offload"), setting TLS_HW on TX didn't touch prot->aad_size and prot->tail_size. They are set to 0 during context allocation (tls_prot_info is embedded in tls_context, kzalloc'd by tls_ctx_create). When the RX key is configured, tls_set_sw_offload is called (for both TLS_SW and TLS_HW). If the TX key is configured in TLS_HW mode after the RX key has been installed, init_prot_info will now overwrite the correct values of aad_size and tail_size, breaking SW decryption and causing -EBADMSG errors to be returned to userspace. Since TLS_HW doesn't use aad_size and tail_size at all (for TLS1.2, tail_size is always 0, and aad_size is equal to TLS_HEADER_SIZE + rec_seq_size), we can simply drop this hunk. Fixes: 1a074f7 ("tls: also use init_prot_info in tls_set_device_offload") Signed-off-by: Sabrina Dubroca <[email protected]> Acked-by: Jakub Kicinski <[email protected]> Tested-by: Ran Rozenstein <[email protected]> Link: https://lore.kernel.org/r/979d2f89a6a994d5bb49cae49a80be54150d094d.1697653889.git.sd@queasysnail.net Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Sabrina Dubroca <[email protected]>
1 parent 22422ec commit e243e51

File tree

3 files changed

+4
-11
lines changed

3 files changed

+4
-11
lines changed

net/tls/tls.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ void tls_err_abort(struct sock *sk, int err);
142142

143143
int init_prot_info(struct tls_prot_info *prot,
144144
const struct tls_crypto_info *crypto_info,
145-
const struct tls_cipher_desc *cipher_desc,
146-
int mode);
145+
const struct tls_cipher_desc *cipher_desc);
147146
int tls_set_sw_offload(struct sock *sk, int tx);
148147
void tls_update_rx_zc_capable(struct tls_context *tls_ctx);
149148
void tls_sw_strparser_arm(struct sock *sk, struct tls_context *ctx);

net/tls/tls_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@ int tls_set_device_offload(struct sock *sk)
11131113
goto release_netdev;
11141114
}
11151115

1116-
rc = init_prot_info(prot, crypto_info, cipher_desc, TLS_HW);
1116+
rc = init_prot_info(prot, crypto_info, cipher_desc);
11171117
if (rc)
11181118
goto release_netdev;
11191119

net/tls/tls_sw.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2640,8 +2640,7 @@ static struct tls_sw_context_rx *init_ctx_rx(struct tls_context *ctx)
26402640

26412641
int init_prot_info(struct tls_prot_info *prot,
26422642
const struct tls_crypto_info *crypto_info,
2643-
const struct tls_cipher_desc *cipher_desc,
2644-
int mode)
2643+
const struct tls_cipher_desc *cipher_desc)
26452644
{
26462645
u16 nonce_size = cipher_desc->nonce;
26472646

@@ -2654,11 +2653,6 @@ int init_prot_info(struct tls_prot_info *prot,
26542653
prot->tail_size = 0;
26552654
}
26562655

2657-
if (mode == TLS_HW) {
2658-
prot->aad_size = 0;
2659-
prot->tail_size = 0;
2660-
}
2661-
26622656
/* Sanity-check the sizes for stack allocations. */
26632657
if (nonce_size > TLS_MAX_IV_SIZE || prot->aad_size > TLS_MAX_AAD_SIZE)
26642658
return -EINVAL;
@@ -2718,7 +2712,7 @@ int tls_set_sw_offload(struct sock *sk, int tx)
27182712
goto free_priv;
27192713
}
27202714

2721-
rc = init_prot_info(prot, crypto_info, cipher_desc, TLS_SW);
2715+
rc = init_prot_info(prot, crypto_info, cipher_desc);
27222716
if (rc)
27232717
goto free_priv;
27242718

0 commit comments

Comments
 (0)