summaryrefslogtreecommitdiffstats
path: root/crypto
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2019-12-05 13:45:05 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-02-05 14:18:10 +0000
commit713ff7e4d605c4dd1efd838e3f0092cd93733f0c (patch)
tree735d21e22af93a653570cf2e15faa6eced170946 /crypto
parentc662ea4fab81c530590c2be3e86e26313d047e3b (diff)
downloadlinux-stable-713ff7e4d605c4dd1efd838e3f0092cd93733f0c.tar.gz
linux-stable-713ff7e4d605c4dd1efd838e3f0092cd93733f0c.tar.bz2
linux-stable-713ff7e4d605c4dd1efd838e3f0092cd93733f0c.zip
crypto: af_alg - Use bh_lock_sock in sk_destruct
commit 37f96694cf73ba116993a9d2d99ad6a75fa7fdb0 upstream. 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: c840ac6af3f8 ("crypto: af_alg - Disallow bind/setkey/...") Cc: <stable@vger.kernel.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/af_alg.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index 422bba808f73..0679c35adf55 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -139,11 +139,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);