Subject: Re: [v2 PATCH] af_key: Fix send_acquire race with pfkey_register

From: Sabrina Dubroca <[email-masked]>
Date: Mon, 24 Oct 2022 09:20:00 +0200

2022-10-24, 14:06:12 +0800, Herbert Xu wrote:
> @@ -1697,11 +1699,11 @@ 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);
> +	spin_lock_bh(&pfkey_alg_lock);
>  	xfrm_probe_algs();

I don't think we can do that:

void xfrm_probe_algs(void)
{
	int i, status;

	BUG_ON(in_softirq());

>  
>  	supp_skb = compose_sadb_supported(hdr, GFP_KERNEL | __GFP_ZERO);
> -	mutex_unlock(&pfkey_mutex);
> +	spin_unlock_bh(&pfkey_alg_lock);
>  
>  	if (!supp_skb) {
>  		if (hdr->sadb_msg_satype != SADB_SATYPE_UNSPEC)

-- 
Sabrina