From: Herbert Xu <herbert@gondor.apana.org.au>
To: Abhishek Shah <abhishek.shah@columbia.edu>
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
netdev@vger.kernel.org, pabeni@redhat.com,
steffen.klassert@secunet.com, linux-kernel@vger.kernel.org,
Gabriel Ryan <gabe@cs.columbia.edu>,
Fan Du <fan.du@windriver.com>,
Steffen Klassert <klassert@kernel.org>
Subject: [PATCH] af_key: Do not call xfrm_probe_algs in parallel
Date: Thu, 4 Aug 2022 18:03:46 +0800 [thread overview]
Message-ID: <YuuZgsdmJK8roKLD@gondor.apana.org.au> (raw)
In-Reply-To: <YuNGR/5U5pSo6YM3@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>
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);
--
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
next prev parent reply other threads:[~2022-08-04 10:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAEHB24-9hXY+TgQKxJB4bE9a9dFD9C+Lan+ShBwpvwaHVAGMFg@mail.gmail.com>
2022-07-22 3:16 ` Race 1 in net/xfrm/xfrm_algo.c Herbert Xu
[not found] ` <CAEHB249ygptvp9wpynMF7zZ2Kcet0+bwLVuVg5UReZHOU1+8HA@mail.gmail.com>
2022-07-29 2:30 ` Herbert Xu
2022-08-04 10:03 ` Herbert Xu [this message]
2022-08-09 5:47 ` [PATCH] af_key: Do not call xfrm_probe_algs in parallel Steffen Klassert
2022-08-22 16:19 ` Gabriel Ryan
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=YuuZgsdmJK8roKLD@gondor.apana.org.au \
--to=herbert@gondor.apana.org.au \
--cc=abhishek.shah@columbia.edu \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fan.du@windriver.com \
--cc=gabe@cs.columbia.edu \
--cc=klassert@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=steffen.klassert@secunet.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®