Skip to content

Commit cc4a9cc

Browse files
Tariq ToukanSaeed Mahameed
authored andcommitted
net/mlx5e: kTLS, Fix crash in RX resync flow
For the TLS RX resync flow, we maintain a list of TLS contexts that require some attention, to communicate their resync information to the HW. Here we fix list corruptions, by protecting the entries against movements coming from resync_handle_seq_match(), until their resync handling in napi is fully completed. Fixes: e9ce991 ("net/mlx5e: kTLS, Add resiliency to RX resync failures") Signed-off-by: Tariq Toukan <tariqt@nvidia.com> Reviewed-by: Maxim Mikityanskiy <maximmi@nvidia.com> Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
1 parent 848e5d6 commit cc4a9cc

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

  • drivers/net/ethernet/mellanox/mlx5/core/en_accel

‎drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ struct mlx5e_ktls_offload_context_rx {
5555
DECLARE_BITMAP(flags, MLX5E_NUM_PRIV_RX_FLAGS);
5656

5757
/* resync */
58+
spinlock_t lock; /* protects resync fields */
5859
struct mlx5e_ktls_rx_resync_ctx resync;
5960
struct list_head list;
6061
};
@@ -386,14 +387,18 @@ static void resync_handle_seq_match(struct mlx5e_ktls_offload_context_rx *priv_r
386387
struct mlx5e_icosq *sq;
387388
bool trigger_poll;
388389

389-
memcpy(info->rec_seq, &priv_rx->resync.sw_rcd_sn_be, sizeof(info->rec_seq));
390-
391390
sq = &c->async_icosq;
392391
ktls_resync = sq->ktls_resync;
392+
trigger_poll = false;
393393

394394
spin_lock_bh(&ktls_resync->lock);
395-
list_add_tail(&priv_rx->list, &ktls_resync->list);
396-
trigger_poll = !test_and_set_bit(MLX5E_SQ_STATE_PENDING_TLS_RX_RESYNC, &sq->state);
395+
spin_lock_bh(&priv_rx->lock);
396+
memcpy(info->rec_seq, &priv_rx->resync.sw_rcd_sn_be, sizeof(info->rec_seq));
397+
if (list_empty(&priv_rx->list)) {
398+
list_add_tail(&priv_rx->list, &ktls_resync->list);
399+
trigger_poll = !test_and_set_bit(MLX5E_SQ_STATE_PENDING_TLS_RX_RESYNC, &sq->state);
400+
}
401+
spin_unlock_bh(&priv_rx->lock);
397402
spin_unlock_bh(&ktls_resync->lock);
398403

399404
if (!trigger_poll)
@@ -617,6 +622,8 @@ int mlx5e_ktls_add_rx(struct net_device *netdev, struct sock *sk,
617622
if (err)
618623
goto err_create_key;
619624

625+
INIT_LIST_HEAD(&priv_rx->list);
626+
spin_lock_init(&priv_rx->lock);
620627
priv_rx->crypto_info =
621628
*(struct tls12_crypto_info_aes_gcm_128 *)crypto_info;
622629

@@ -730,10 +737,14 @@ bool mlx5e_ktls_rx_handle_resync_list(struct mlx5e_channel *c, int budget)
730737
priv_rx = list_first_entry(&local_list,
731738
struct mlx5e_ktls_offload_context_rx,
732739
list);
740+
spin_lock(&priv_rx->lock);
733741
cseg = post_static_params(sq, priv_rx);
734-
if (IS_ERR(cseg))
742+
if (IS_ERR(cseg)) {
743+
spin_unlock(&priv_rx->lock);
735744
break;
736-
list_del(&priv_rx->list);
745+
}
746+
list_del_init(&priv_rx->list);
747+
spin_unlock(&priv_rx->lock);
737748
db_cseg = cseg;
738749
}
739750
if (db_cseg)

0 commit comments

Comments
 (0)