Skip to content

Commit

Permalink
chelsio/chtls: fix memory leaks caused by a race
Browse files Browse the repository at this point in the history
race between user context and softirq causing memleak,
consider the call sequence scenario

chtls_setkey()         //user context
chtls_peer_close()
chtls_abort_req_rss()
chtls_setkey()         //user context

work request skb queued in chtls_setkey() won't be freed
because resources are already cleaned for this connection,
fix it by not queuing work request while socket is closing.

v1->v2:
- fix W=1 warning.

v2->v3:
- separate it out from another memleak fix.

Fixes: cc35c88 ("crypto : chtls - CPL handler definition")
Signed-off-by: Vinay Kumar Yadav <vinay.yadav@chelsio.com>
Link: https://lore.kernel.org/r/20201102173650.24754-1-vinay.yadav@chelsio.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Vinay Kumar Yadav authored and Jakub Kicinski committed Nov 3, 2020
1 parent 5fd8477 commit 8080b46
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_hw.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,9 @@ int chtls_setkey(struct chtls_sock *csk, u32 keylen,
if (ret)
goto out_notcb;

if (unlikely(csk_flag(sk, CSK_ABORT_SHUTDOWN)))
goto out_notcb;

set_wr_txq(skb, CPL_PRIORITY_DATA, csk->tlshws.txqid);
csk->wr_credits -= DIV_ROUND_UP(len, 16);
csk->wr_unacked += DIV_ROUND_UP(len, 16);
Expand Down

0 comments on commit 8080b46

Please sign in to comment.