All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gabriel Ryan <gabe@cs.columbia.edu>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Abhishek Shah <abhishek.shah@columbia.edu>,
	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,
	Fan Du <fan.du@windriver.com>,
	Steffen Klassert <klassert@kernel.org>
Subject: Re: [PATCH] af_key: Do not call xfrm_probe_algs in parallel
Date: Mon, 22 Aug 2022 12:19:54 -0400	[thread overview]
Message-ID: <CALbthtcfPn5qc0HecmK9iN-o+ZWDVid4bwzZJmO2sthw3fKFBQ@mail.gmail.com> (raw)
In-Reply-To: <YuuZgsdmJK8roKLD@gondor.apana.org.au>

We can confirm we tested this patch and it prevents the race we
detected in xfrm_ealg_get_byname / xfrm_probe_algs.

Best,

Gabe


On Thu, Aug 4, 2022 at 6:03 AM Herbert Xu <herbert@gondor.apana.org.au> wrote:
>
> 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

-- 
Gabriel Ryan
PhD Candidate at Columbia University
cs.columbia.edu/~gabe

      parent reply	other threads:[~2022-08-22 16:20 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       ` [PATCH] af_key: Do not call xfrm_probe_algs in parallel Herbert Xu
2022-08-09  5:47         ` Steffen Klassert
2022-08-22 16:19         ` Gabriel Ryan [this message]

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=CALbthtcfPn5qc0HecmK9iN-o+ZWDVid4bwzZJmO2sthw3fKFBQ@mail.gmail.com \
    --to=gabe@cs.columbia.edu \
    --cc=abhishek.shah@columbia.edu \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fan.du@windriver.com \
    --cc=herbert@gondor.apana.org.au \
    --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 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.