Re: [v2 PATCH] crypto: pcrypt - Avoid deadlock by using per-instance padata queues

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 20, 2019 at 02:58:27AM +0800, Herbert Xu wrote:
>  static int __padata_remove_cpu(struct padata_instance *pinst, int cpu)
>  {
> -	struct parallel_data *pd = NULL;
> -
>  	if (cpumask_test_cpu(cpu, cpu_online_mask)) {
> +		cpumask_clear_cpu(cpu, pinst->cpumask.pcpu);
> +		cpumask_clear_cpu(cpu, pinst->cpumask.cbcpu);
>  
>  		if (!padata_validate_cpumask(pinst, pinst->cpumask.pcpu) ||
>  		    !padata_validate_cpumask(pinst, pinst->cpumask.cbcpu))
>  			__padata_stop(pinst);
>  
> -		pd = padata_alloc_pd(pinst, pinst->cpumask.pcpu,
> -				     pinst->cpumask.cbcpu);
> -		if (!pd)
> -			return -ENOMEM;
> -
> -		padata_replace(pinst, pd);
> -
> -		cpumask_clear_cpu(cpu, pd->cpumask.cbcpu);
> -		cpumask_clear_cpu(cpu, pd->cpumask.pcpu);
> +		padata_replace(pinst);
>  	}

Clearing the offlined CPU from pinst's cpumasks means it won't be used if it
comes back online.

The CPU could be cleared from all pd's attached to the instance, but that
doesn't address another bug in this function that's fixed by this patch:

    https://lore.kernel.org/linux-crypto/20190828221425.22701-6-daniel.m.jordan@xxxxxxxxxx/

Should I add it into the next version of the padata series I just posted?:

    https://lore.kernel.org/linux-crypto/20191120185412.302-1-daniel.m.jordan@xxxxxxxxxx/

It would obviate the need for your patch to mess with cpumask_clear_cpu().  Or
is there something else you'd prefer?

Thanks,
Daniel



[Index of Archives]     [Kernel]     [Gnu Classpath]     [Gnu Crypto]     [DM Crypt]     [Netfilter]     [Bugtraq]

  Powered by Linux