Skip to content

Commit da4917b

Browse files
Maxim Mikityanskiygregkh
Maxim Mikityanskiy
authored andcommitted
net/mlx5e: Fix refcount leak on kTLS RX resync
[ Upstream commit ea63609 ] 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: 0419d8c ("net/mlx5e: kTLS, Add kTLS RX resync support") Signed-off-by: Maxim Mikityanskiy <[email protected]> Reviewed-by: Tariq Toukan <[email protected]> Signed-off-by: Saeed Mahameed <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 438a5b5 commit da4917b

File tree

1 file changed

+8
-5
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/en_accel

1 file changed

+8
-5
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -476,19 +476,22 @@ static void resync_update_sn(struct mlx5e_rq *rq, struct sk_buff *skb)
476476

477477
depth += sizeof(struct tcphdr);
478478

479-
if (unlikely(!sk || sk->sk_state == TCP_TIME_WAIT))
479+
if (unlikely(!sk))
480480
return;
481481

482-
if (unlikely(!resync_queue_get_psv(sk)))
483-
return;
482+
if (unlikely(sk->sk_state == TCP_TIME_WAIT))
483+
goto unref;
484484

485-
skb->sk = sk;
486-
skb->destructor = sock_edemux;
485+
if (unlikely(!resync_queue_get_psv(sk)))
486+
goto unref;
487487

488488
seq = th->seq;
489489
datalen = skb->len - depth;
490490
tls_offload_rx_resync_async_request_start(sk, seq, datalen);
491491
rq->stats->tls_resync_req_start++;
492+
493+
unref:
494+
sock_gen_put(sk);
492495
}
493496

494497
void mlx5e_ktls_rx_resync(struct net_device *netdev, struct sock *sk,

0 commit comments

Comments
 (0)