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] [day] [month] [year] [list]
Message-ID: <aMTra7C-CayEcaCY@gondor.apana.org.au>
Date: Sat, 13 Sep 2025 11:56:27 +0800
From: Herbert Xu <herbert@...dor.apana.org.au>
To: Jonathan McDowell <noodles@...th.li>
Cc: Olivia Mackall <olivia@...enic.com>, linux-crypto@...r.kernel.org,
	linux-kernel@...r.kernel.org, linux-integrity@...r.kernel.org
Subject: Re: [PATCH] hwrng: core - Allow runtime disabling of the HW RNG

On Mon, Sep 01, 2025 at 02:55:01PM +0100, Jonathan McDowell wrote:
> From: Jonathan McDowell <noodles@...a.com>
> 
> The HW RNG core allows for manual selection of which RNG device to use,
> but does not allow for no device to be enabled. It may be desirable to
> do this on systems with only a single suitable hardware RNG, where we
> need exclusive access to other functionality on this device. In
> particular when performing TPM firmware upgrades this lets us ensure the
> kernel does not try to access the device.
> 
> Before:
> 
> root@...ian-qemu-efi:~# grep "" /sys/devices/virtual/misc/hw_random/rng_*
> /sys/devices/virtual/misc/hw_random/rng_available:tpm-rng-0
> /sys/devices/virtual/misc/hw_random/rng_current:tpm-rng-0
> /sys/devices/virtual/misc/hw_random/rng_quality:1024
> /sys/devices/virtual/misc/hw_random/rng_selected:0
> 
> After:
> 
> root@...ian-qemu-efi:~# grep "" /sys/devices/virtual/misc/hw_random/rng_*
> /sys/devices/virtual/misc/hw_random/rng_available:tpm-rng-0 none
> /sys/devices/virtual/misc/hw_random/rng_current:tpm-rng-0
> /sys/devices/virtual/misc/hw_random/rng_quality:1024
> /sys/devices/virtual/misc/hw_random/rng_selected:0
> 
> root@...ian-qemu-efi:~# echo none > /sys/devices/virtual/misc/hw_random/rng_current
> root@...ian-qemu-efi:~# grep "" /sys/devices/virtual/misc/hw_random/rng_*
> /sys/devices/virtual/misc/hw_random/rng_available:tpm-rng-0 none
> /sys/devices/virtual/misc/hw_random/rng_current:none
> grep: /sys/devices/virtual/misc/hw_random/rng_quality: No such device
> /sys/devices/virtual/misc/hw_random/rng_selected:1
> 
> (Observe using bpftrace no calls to TPM being made)
> 
> root@...ian-qemu-efi:~# echo "" > /sys/devices/virtual/misc/hw_random/rng_current
> root@...ian-qemu-efi:~# grep "" /sys/devices/virtual/misc/hw_random/rng_*
> /sys/devices/virtual/misc/hw_random/rng_available:tpm-rng-0 none
> /sys/devices/virtual/misc/hw_random/rng_current:tpm-rng-0
> /sys/devices/virtual/misc/hw_random/rng_quality:1024
> /sys/devices/virtual/misc/hw_random/rng_selected:0
> 
> (Observe using bpftrace that calls to the TPM resume)
> 
> Signed-off-by: Jonathan McDowell <noodles@...a.com>
> ---
>  drivers/char/hw_random/core.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
> index 018316f54621..11c8077b792b 100644
> --- a/drivers/char/hw_random/core.c
> +++ b/drivers/char/hw_random/core.c
> @@ -341,6 +341,10 @@ static ssize_t rng_current_store(struct device *dev,
>  
>  	if (sysfs_streq(buf, "")) {
>  		err = enable_best_rng();
> +	} else if (sysfs_streq(buf, "none")) {
> +		if (current_rng)
> +			cur_rng_set_by_user = 1;
> +		drop_current_rng();

Is this setting supposed to be sticky?

Because as it stands, if another HWRNG is registered after setting
it to none, it would still become the default RNG which seems to be
surprising.

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