Message ID | 20191018193737.13959-12-saeedm@mellanox.com |
---|---|
State | Accepted |
Delegated to: | David Miller |
Headers | show |
Series | [net,01/15] net/mlx5e: Tx, Fix assumption of single WQEBB of NOP in cleanup flow | expand |
On Fri, 18 Oct 2019 19:38:22 +0000, Saeed Mahameed wrote: > From: Tariq Toukan <tariqt@mellanox.com> > > Do not assume the crypto info is accessible during the > connection lifetime. Save a copy of it in the private > TX context. It should be around as long as the driver knows about the socket, no?
On 10/19/2019 2:16 AM, Jakub Kicinski wrote: > On Fri, 18 Oct 2019 19:38:22 +0000, Saeed Mahameed wrote: >> From: Tariq Toukan <tariqt@mellanox.com> >> >> Do not assume the crypto info is accessible during the >> connection lifetime. Save a copy of it in the private >> TX context. > > It should be around as long as the driver knows about the socket, no? > The crypto info instance passed to the driver (as parameter in connection creation callback) might be modified/zeroed/reused, so the driver is expected to save its own copy, not just the pointer.
On Sun, 20 Oct 2019 07:46:00 +0000, Tariq Toukan wrote: > On 10/19/2019 2:16 AM, Jakub Kicinski wrote: > > On Fri, 18 Oct 2019 19:38:22 +0000, Saeed Mahameed wrote: > >> From: Tariq Toukan <tariqt@mellanox.com> > >> > >> Do not assume the crypto info is accessible during the > >> connection lifetime. Save a copy of it in the private > >> TX context. > > > > It should be around as long as the driver knows about the socket, no? > > The crypto info instance passed to the driver (as parameter in > connection creation callback) might be modified/zeroed/reused, so the > driver is expected to save its own copy, not just the pointer. Can you point to a code path where that happens today?
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c index d2ff74d52720..46725cd743a3 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.c @@ -38,7 +38,7 @@ static int mlx5e_ktls_add(struct net_device *netdev, struct sock *sk, return -ENOMEM; tx_priv->expected_seq = start_offload_tcp_sn; - tx_priv->crypto_info = crypto_info; + tx_priv->crypto_info = *(struct tls12_crypto_info_aes_gcm_128 *)crypto_info; mlx5e_set_ktls_tx_priv_ctx(tls_ctx, tx_priv); /* tc and underlay_qpn values are not in use for tls tis */ diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.h b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.h index 929966e6fbc4..a3efa29a4629 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls.h @@ -44,7 +44,7 @@ enum { struct mlx5e_ktls_offload_context_tx { struct tls_offload_context_tx *tx_ctx; - struct tls_crypto_info *crypto_info; + struct tls12_crypto_info_aes_gcm_128 crypto_info; u32 expected_seq; u32 tisn; u32 key_id; diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c index 1bfeb558ff78..badc6fd26a14 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_tx.c @@ -24,14 +24,12 @@ enum { static void fill_static_params_ctx(void *ctx, struct mlx5e_ktls_offload_context_tx *priv_tx) { - struct tls_crypto_info *crypto_info = priv_tx->crypto_info; - struct tls12_crypto_info_aes_gcm_128 *info; + struct tls12_crypto_info_aes_gcm_128 *info = &priv_tx->crypto_info; char *initial_rn, *gcm_iv; u16 salt_sz, rec_seq_sz; char *salt, *rec_seq; u8 tls_version; - info = (struct tls12_crypto_info_aes_gcm_128 *)crypto_info; EXTRACT_INFO_FIELDS; gcm_iv = MLX5_ADDR_OF(tls_static_params, ctx, gcm_iv); @@ -233,14 +231,12 @@ tx_post_resync_params(struct mlx5e_txqsq *sq, struct mlx5e_ktls_offload_context_tx *priv_tx, u64 rcd_sn) { - struct tls_crypto_info *crypto_info = priv_tx->crypto_info; - struct tls12_crypto_info_aes_gcm_128 *info; + struct tls12_crypto_info_aes_gcm_128 *info = &priv_tx->crypto_info; __be64 rn_be = cpu_to_be64(rcd_sn); bool skip_static_post; u16 rec_seq_sz; char *rec_seq; - info = (struct tls12_crypto_info_aes_gcm_128 *)crypto_info; rec_seq = info->rec_seq; rec_seq_sz = sizeof(info->rec_seq);