Skip to content

Commit 37f9669

Browse files
committed
crypto: af_alg - Use bh_lock_sock in sk_destruct
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: syzbot+c2f1558d49e25cc36e5e@syzkaller.appspotmail.com Reported-by: Eric Dumazet <eric.dumazet@gmail.com> Fixes: c840ac6 ("crypto: af_alg - Disallow bind/setkey/...") Cc: <stable@vger.kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent bfcdcef commit 37f9669

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎crypto/af_alg.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,13 @@ void af_alg_release_parent(struct sock *sk)
134134
sk = ask->parent;
135135
ask = alg_sk(sk);
136136

137-
lock_sock(sk);
137+
local_bh_disable();
138+
bh_lock_sock(sk);
138139
ask->nokey_refcnt -= nokey;
139140
if (!last)
140141
last = !--ask->refcnt;
141-
release_sock(sk);
142+
bh_unlock_sock(sk);
143+
local_bh_enable();
142144

143145
if (last)
144146
sock_put(sk);

0 commit comments

Comments
 (0)