summaryrefslogtreecommitdiffstats
path: root/net/key
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2022-08-04 18:03:46 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-09-05 10:26:29 +0200
commit7dbfc8f25f22fe2a64dd808266e00c8d2661ebdd (patch)
tree057a4d3c0d71a0fdd0037a02e90161a16aaee30c /net/key
parent0769491a8acd3e85ca4c3f65080eac2c824262df (diff)
downloadlinux-stable-7dbfc8f25f22fe2a64dd808266e00c8d2661ebdd.tar.gz
linux-stable-7dbfc8f25f22fe2a64dd808266e00c8d2661ebdd.tar.bz2
linux-stable-7dbfc8f25f22fe2a64dd808266e00c8d2661ebdd.zip
af_key: Do not call xfrm_probe_algs in parallel
[ Upstream commit ba953a9d89a00c078b85f4b190bc1dde66fe16b5 ] When namespace support was added to xfrm/afkey, it caused the previously single-threaded call to xfrm_probe_algs to become multi-threaded. This is buggy and needs to be fixed with a mutex. Reported-by: Abhishek Shah <abhishek.shah@columbia.edu> Fixes: 283bc9f35bbb ("xfrm: Namespacify xfrm state/policy locks") Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/key')
-rw-r--r--net/key/af_key.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/net/key/af_key.c b/net/key/af_key.c
index af67e0d265c0..337c6bc8211e 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -1707,9 +1707,12 @@ static int pfkey_register(struct sock *sk, struct sk_buff *skb, const struct sad
pfk->registered |= (1<<hdr->sadb_msg_satype);
}
+ mutex_lock(&pfkey_mutex);
xfrm_probe_algs();
supp_skb = compose_sadb_supported(hdr, GFP_KERNEL | __GFP_ZERO);
+ mutex_unlock(&pfkey_mutex);
+
if (!supp_skb) {
if (hdr->sadb_msg_satype != SADB_SATYPE_UNSPEC)
pfk->registered &= ~(1<<hdr->sadb_msg_satype);