[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CALbthtcfPn5qc0HecmK9iN-o+ZWDVid4bwzZJmO2sthw3fKFBQ@mail.gmail.com>
Date: Mon, 22 Aug 2022 12:19:54 -0400
From: Gabriel Ryan <gabe@...columbia.edu>
To: Herbert Xu <herbert@...dor.apana.org.au>
Cc: Abhishek Shah <abhishek.shah@...umbia.edu>, davem@...emloft.net,
edumazet@...gle.com, kuba@...nel.org, netdev@...r.kernel.org,
pabeni@...hat.com, steffen.klassert@...unet.com,
linux-kernel@...r.kernel.org, Fan Du <fan.du@...driver.com>,
Steffen Klassert <klassert@...nel.org>
Subject: Re: [PATCH] af_key: Do not call xfrm_probe_algs in parallel
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@...dor.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@...umbia.edu>
> Fixes: 283bc9f35bbb ("xfrm: Namespacify xfrm state/policy locks")
> Signed-off-by: Herbert Xu <herbert@...dor.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@...dor.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
Powered by blists - more mailing lists