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]
Message-ID: <aUTAznUr2OrikTH9@gondor.apana.org.au>
Date: Fri, 19 Dec 2025 11:04:46 +0800
From: Herbert Xu <herbert@...dor.apana.org.au>
To: Chenghai Huang <huangchenghai2@...wei.com>
Cc: davem@...emloft.net, linux-kernel@...r.kernel.org,
	linux-crypto@...r.kernel.org, fanghao11@...wei.com,
	liulongfang@...wei.com, qianweili@...wei.com,
	linwenkai6@...ilicon.com, wangzhou1@...ilicon.com
Subject: Re: [PATCH 1/2] crypto: hisilicon/trng - use DEFINE_MUTEX() and
 LIST_HEAD()

On Thu, Nov 20, 2025 at 09:58:11PM +0800, Chenghai Huang wrote:
>
> @@ -308,12 +302,10 @@ static void hisi_trng_remove(struct platform_device *pdev)
>  	struct hisi_trng *trng = platform_get_drvdata(pdev);
>  
>  	/* Wait until the task is finished */
> -	while (hisi_trng_del_from_list(trng))
> -		;
> -
> -	if (trng->ver != HISI_TRNG_VER_V1 &&
> -	    atomic_dec_return(&trng_active_devs) == 0)
> -		crypto_unregister_rng(&hisi_trng_alg);
> +	while (hisi_trng_crypto_unregister(trng)) {
> +		dev_info(&pdev->dev, "trng is in using!\n");
> +		msleep(WAIT_PERIOD);
> +	}

Please use the new CRYPTO_ALG_DUP_FIRST flag to let the Crypto API
deal with reference count tracking.  With that, you should be able
to unregister the RNG even if there are still tfms using it.

The RNG will be freed after all tfms using it are freed.

Of course you should create a way to mark the trng as dead so
that the hisi_trng_generate returns an error instead of trying
to read from the non-existant RNG.

Cheers,
-- 
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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ