net/mlx5e: kTLS, Use refcounts to free kTLS RX priv context
authorMaxim Mikityanskiy <maximmi@mellanox.com>
Fri, 22 Jan 2021 16:42:29 +0000 (18:42 +0200)
committerSaeed Mahameed <saeedm@nvidia.com>
Fri, 12 Feb 2021 02:50:13 +0000 (18:50 -0800)
commitb850bbff965129c34f50962638c0a66c82563536
tree2fe06a2fb7523d985f56786b85efd889ee4aaab4
parentebf79b6be67c0a77a9ab7cdf74c43fd7d9619f0c
net/mlx5e: kTLS, Use refcounts to free kTLS RX priv context

wait_for_resync is unreliable - if it timeouts, priv_rx will be freed
anyway. However, mlx5e_ktls_handle_get_psv_completion will be called
sooner or later, leading to use-after-free. For example, it can happen
if a CQ error happened, and ICOSQ stopped, but later on the queues are
destroyed, and ICOSQ is flushed with mlx5e_free_icosq_descs.

This patch converts the lifecycle of priv_rx to fully refcount-based, so
that the struct won't be freed before the refcount goes to zero.

Fixes: 0419d8c9d8f8 ("net/mlx5e: kTLS, Add kTLS RX resync support")
Signed-off-by: Maxim Mikityanskiy <maximmi@mellanox.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c