]> git.baikalelectronics.ru Git - kernel.git/commit
net/mlx5e: Fix refcount leak on kTLS RX resync
authorMaxim Mikityanskiy <maximmi@mellanox.com>
Thu, 8 Oct 2020 09:34:10 +0000 (12:34 +0300)
committerSaeed Mahameed <saeedm@nvidia.com>
Tue, 17 Nov 2020 19:50:51 +0000 (11:50 -0800)
commita751aff8b24806b24716be429effa6d0e69b23f9
tree676cc3b1ee6422e364c872dd6dd733d719a6775e
parent4e6282868220a6bab7750aecbdc33c278221e750
net/mlx5e: Fix refcount leak on kTLS RX resync

On resync, the driver calls inet_lookup_established
(__inet6_lookup_established) that increases sk_refcnt of the socket. To
decrease it, the driver set skb->destructor to sock_edemux. However, it
didn't work well, because the TCP stack also sets this destructor for
early demux, and the refcount gets decreased only once, while increased
two times (in mlx5e and in the TCP stack). It leads to a socket leak, a
TLS context leak, which in the end leads to calling tls_dev_del twice:
on socket close and on driver unload, which in turn leads to a crash.

This commit fixes the refcount leak by calling sock_gen_put right away
after using the socket, thus fixing all the subsequent issues.

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