]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commitd403c678b82b5f68db64e299931a7f951cd2ebe8
tree2fe06a2fb7523d985f56786b85efd889ee4aaab4
parent3a01dba068bfb40a70fe18bf1c16e1156ddb2545
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: c104d60a266d ("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