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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 4 Mar 2021 10:37:31 +0000 (11:37 +0100)
commit64ea9e958fba3f5ee43bdcc55c35a051bc8e9ad7
tree28a2a5eeb3640948708edae364ebaddc192711f0
parent08b42b6f891c79ca3ee2504cefcc9741bdcd56e9
net/mlx5e: kTLS, Use refcounts to free kTLS RX priv context

[ Upstream commit b850bbff965129c34f50962638c0a66c82563536 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/en_accel/ktls_rx.c