Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tls: don't reset prot->aad_size and prot->tail_size for TLS_HW

Prior to commit 1a074f7618e8 ("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: 1a074f7618e8 ("tls: also use init_prot_info in tls_set_device_offload")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Tested-by: Ran Rozenstein <ranro@nvidia.com>
Link: https://lore.kernel.org/r/979d2f89a6a994d5bb49cae49a80be54150d094d.1697653889.git.sd@queasysnail.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Sabrina Dubroca and committed by
Jakub Kicinski
b7c4f573 6e7ce2d7

+4 -11
+1 -2
net/tls/tls.h
··· 144 144 145 145 int init_prot_info(struct tls_prot_info *prot, 146 146 const struct tls_crypto_info *crypto_info, 147 - const struct tls_cipher_desc *cipher_desc, 148 - int mode); 147 + const struct tls_cipher_desc *cipher_desc); 149 148 int tls_set_sw_offload(struct sock *sk, int tx); 150 149 void tls_update_rx_zc_capable(struct tls_context *tls_ctx); 151 150 void tls_sw_strparser_arm(struct sock *sk, struct tls_context *ctx);
+1 -1
net/tls/tls_device.c
··· 1099 1099 goto release_netdev; 1100 1100 } 1101 1101 1102 - rc = init_prot_info(prot, crypto_info, cipher_desc, TLS_HW); 1102 + rc = init_prot_info(prot, crypto_info, cipher_desc); 1103 1103 if (rc) 1104 1104 goto release_netdev; 1105 1105
+2 -8
net/tls/tls_sw.c
··· 2629 2629 2630 2630 int init_prot_info(struct tls_prot_info *prot, 2631 2631 const struct tls_crypto_info *crypto_info, 2632 - const struct tls_cipher_desc *cipher_desc, 2633 - int mode) 2632 + const struct tls_cipher_desc *cipher_desc) 2634 2633 { 2635 2634 u16 nonce_size = cipher_desc->nonce; 2636 2635 ··· 2639 2640 prot->tail_size = 1; 2640 2641 } else { 2641 2642 prot->aad_size = TLS_AAD_SPACE_SIZE; 2642 - prot->tail_size = 0; 2643 - } 2644 - 2645 - if (mode == TLS_HW) { 2646 - prot->aad_size = 0; 2647 2643 prot->tail_size = 0; 2648 2644 } 2649 2645 ··· 2701 2707 goto free_priv; 2702 2708 } 2703 2709 2704 - rc = init_prot_info(prot, crypto_info, cipher_desc, TLS_SW); 2710 + rc = init_prot_info(prot, crypto_info, cipher_desc); 2705 2711 if (rc) 2706 2712 goto free_priv; 2707 2713