lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 31 May 2019 17:23:51 +0800
From:   Kefeng Wang <wangkefeng.wang@...wei.com>
To:     Steffen Klassert <steffen.klassert@...unet.com>,
        Herbert Xu <herbert@...dor.apana.org.au>,
        "David S. Miller" <davem@...emloft.net>
CC:     <linux-crypto@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        Hulk Robot <hulkci@...wei.com>
Subject: Re: [PATCH] crypto: pcrypt: Fix possible deadlock in
 padata_sysfs_release


On 2019/5/31 17:29, Kefeng Wang wrote:
> There is a deadlock issue in pcrypt_init_padata(),
>
> pcrypt_init_padata()
>     cpus_read_lock()
>       padata_free()
>         padata_sysfs_release()
>           cpus_read_lock()
>
> Narrow rcu_read_lock/unlock() and move put_online_cpus()
> before padata_free() to fix it.
>
> Reported-by: Hulk Robot <hulkci@...wei.com>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@...wei.com>
> ---
>  crypto/pcrypt.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
> index 0e9ce329fd47..662228b48b70 100644
> --- a/crypto/pcrypt.c
> +++ b/crypto/pcrypt.c
> @@ -407,13 +407,14 @@ static int pcrypt_init_padata(struct padata_pcrypt *pcrypt,
>  	int ret = -ENOMEM;
>  	struct pcrypt_cpumask *mask;
>  
> -	get_online_cpus();
>  
>  	pcrypt->wq = alloc_workqueue("%s", WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE,
>  				     1, name);
>  	if (!pcrypt->wq)
>  		goto err;
>  
> +	get_online_cpus();
> +
>  	pcrypt->pinst = padata_alloc_possible(pcrypt->wq);
>  	if (!pcrypt->pinst) 

Oh, forget to add put_online_cpus in this error path, will resend v2 if there is no comment.


>  		goto err_destroy_workqueue;
> @@ -448,12 +449,11 @@ static int pcrypt_init_padata(struct padata_pcrypt *pcrypt,
>  	free_cpumask_var(mask->mask);
>  	kfree(mask);
>  err_free_padata:
> +	put_online_cpus();
>  	padata_free(pcrypt->pinst);
>  err_destroy_workqueue:
>  	destroy_workqueue(pcrypt->wq);
>  err:
> -	put_online_cpus();
> -
>  	return ret;
>  }
>  

Powered by blists - more mailing lists