Skip to content

Commit

Permalink
crypto: af_alg - Use bh_lock_sock in sk_destruct
Browse files Browse the repository at this point in the history
As af_alg_release_parent may be called from BH context (most notably
due to an async request that only completes after socket closure,
or as reported here because of an RCU-delayed sk_destruct call), we
must use bh_lock_sock instead of lock_sock.

Reported-by: [email protected]
Reported-by: Eric Dumazet <[email protected]>
Fixes: c840ac6 ("crypto: af_alg - Disallow bind/setkey/...")
Cc: <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
herbertx committed Dec 11, 2019
1 parent bfcdcef commit 37f9669
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions crypto/af_alg.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,13 @@ void af_alg_release_parent(struct sock *sk)
sk = ask->parent;
ask = alg_sk(sk);

lock_sock(sk);
local_bh_disable();
bh_lock_sock(sk);
ask->nokey_refcnt -= nokey;
if (!last)
last = !--ask->refcnt;
release_sock(sk);
bh_unlock_sock(sk);
local_bh_enable();

if (last)
sock_put(sk);
Expand Down

0 comments on commit 37f9669

Please sign in to comment.