From: Steffen Klassert <steffen.klassert@secunet.com>
To: David Miller <davem@davemloft.net>, Jakub Kicinski <kuba@kernel.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
Steffen Klassert <steffen.klassert@secunet.com>,
<netdev@vger.kernel.org>
Subject: [PATCH 5/6] af_key: Do not call xfrm_probe_algs in parallel
Date: Wed, 24 Aug 2022 07:02:12 +0200 [thread overview]
Message-ID: <20220824050213.3643599-6-steffen.klassert@secunet.com> (raw)
In-Reply-To: <20220824050213.3643599-1-steffen.klassert@secunet.com>
From: Herbert Xu <herbert@gondor.apana.org.au>
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>
---
net/key/af_key.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/key/af_key.c b/net/key/af_key.c
index fb16d7c4e1b8..20e73643b9c8 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -1697,9 +1697,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);
--
2.25.1
next prev parent reply other threads:[~2022-08-24 5:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-24 5:02 [PATCH 0/6] pull request (net): ipsec 2022-08-24 Steffen Klassert
2022-08-24 5:02 ` [PATCH 1/6] xfrm: fix refcount leak in __xfrm_policy_check() Steffen Klassert
2022-08-24 12:10 ` patchwork-bot+netdevbpf
2022-08-24 5:02 ` [PATCH 2/6] Revert "xfrm: update SA curlft.use_time" Steffen Klassert
2022-08-24 5:02 ` [PATCH 3/6] xfrm: fix XFRMA_LASTUSED comment Steffen Klassert
2022-08-24 5:02 ` [PATCH 4/6] xfrm: clone missing x->lastused in xfrm_do_migrate Steffen Klassert
2022-08-24 5:02 ` Steffen Klassert [this message]
2022-08-24 5:02 ` [PATCH 6/6] xfrm: policy: fix metadata dst->dev xmit null pointer dereference Steffen Klassert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220824050213.3643599-6-steffen.klassert@secunet.com \
--to=steffen.klassert@secunet.com \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.