[PATCH] crypto: loongson - Select CRYPTO_RNG

Eric Biggers posted 1 patch 2 days, 17 hours ago
drivers/crypto/loongson/Kconfig | 1 +
1 file changed, 1 insertion(+)
[PATCH] crypto: loongson - Select CRYPTO_RNG
Posted by Eric Biggers 2 days, 17 hours ago
This driver registers a rng_alg, so it requires CRYPTO_RNG.

Fixes: 766b2d724c8d ("crypto: loongson - add Loongson RNG driver support")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202605201622.qWOiiZTV-lkp@intel.com/
Cc: stable@vger.kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
 drivers/crypto/loongson/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/crypto/loongson/Kconfig b/drivers/crypto/loongson/Kconfig
index 15475da8fc11..f4e1544ffbb4 100644
--- a/drivers/crypto/loongson/Kconfig
+++ b/drivers/crypto/loongson/Kconfig
@@ -1,5 +1,6 @@
 config CRYPTO_DEV_LOONGSON_RNG
 	tristate "Support for Loongson RNG Driver"
 	depends on MFD_LOONGSON_SE
+	select CRYPTO_RNG
 	help
 	  Support for Loongson RNG Driver.

base-commit: 6c9dddeb582fde005360f4fe02c760d45ca05fb5
-- 
2.54.0
Re: [PATCH] crypto: loongson - Select CRYPTO_RNG
Posted by Huacai Chen 2 days, 16 hours ago
On Fri, May 22, 2026 at 10:26 AM Eric Biggers <ebiggers@kernel.org> wrote:
>
> This driver registers a rng_alg, so it requires CRYPTO_RNG.
>
> Fixes: 766b2d724c8d ("crypto: loongson - add Loongson RNG driver support")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202605201622.qWOiiZTV-lkp@intel.com/
> Cc: stable@vger.kernel.org
> Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
> ---
>  drivers/crypto/loongson/Kconfig | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/crypto/loongson/Kconfig b/drivers/crypto/loongson/Kconfig
> index 15475da8fc11..f4e1544ffbb4 100644
> --- a/drivers/crypto/loongson/Kconfig
> +++ b/drivers/crypto/loongson/Kconfig
> @@ -1,5 +1,6 @@
>  config CRYPTO_DEV_LOONGSON_RNG
>         tristate "Support for Loongson RNG Driver"
>         depends on MFD_LOONGSON_SE
> +       select CRYPTO_RNG
>         help
>           Support for Loongson RNG Driver.
>
> base-commit: 6c9dddeb582fde005360f4fe02c760d45ca05fb5
> --
> 2.54.0
>
Re: [PATCH] crypto: loongson - Select CRYPTO_RNG
Posted by Eric Biggers 2 days, 16 hours ago
On Fri, May 22, 2026 at 10:52:42AM +0800, Huacai Chen wrote:
> On Fri, May 22, 2026 at 10:26 AM Eric Biggers <ebiggers@kernel.org> wrote:
> >
> > This driver registers a rng_alg, so it requires CRYPTO_RNG.
> >
> > Fixes: 766b2d724c8d ("crypto: loongson - add Loongson RNG driver support")
> > Reported-by: kernel test robot <lkp@intel.com>
> > Closes: https://lore.kernel.org/oe-kbuild-all/202605201622.qWOiiZTV-lkp@intel.com/
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Eric Biggers <ebiggers@kernel.org>
> Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
> > ---
> >  drivers/crypto/loongson/Kconfig | 1 +
> >  1 file changed, 1 insertion(+)
> >

By the way, do any of the loongson people have any comment on what they
think the point of this driver is?  It's not registered with the actual
hwrng subsystem, but rather the pointless crypto_rng system which no one
uses.  So if it was intended to provide entropy for /dev/urandom etc.,
that isn't what it's doing.

Can we just delete this driver?

- Eric
Re: [PATCH] crypto: loongson - Select CRYPTO_RNG
Posted by Qunqin Zhao 2 days, 15 hours ago
在 2026/5/22 上午10:57, Eric Biggers 写道:
> On Fri, May 22, 2026 at 10:52:42AM +0800, Huacai Chen wrote:
>> On Fri, May 22, 2026 at 10:26 AM Eric Biggers <ebiggers@kernel.org> wrote:
>>> This driver registers a rng_alg, so it requires CRYPTO_RNG.
>>>
>>> Fixes: 766b2d724c8d ("crypto: loongson - add Loongson RNG driver support")
>>> Reported-by: kernel test robot <lkp@intel.com>
>>> Closes: https://lore.kernel.org/oe-kbuild-all/202605201622.qWOiiZTV-lkp@intel.com/
>>> Cc: stable@vger.kernel.org
>>> Signed-off-by: Eric Biggers <ebiggers@kernel.org>
>> Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
>>> ---
>>>   drivers/crypto/loongson/Kconfig | 1 +
>>>   1 file changed, 1 insertion(+)
>>>
> By the way, do any of the loongson people have any comment on what they
> think the point of this driver is?  It's not registered with the actual

To provide an AF_ALG-based random number generation interface for other 
modules and user-space programs.

Thanks,

Qunqin

> hwrng subsystem, but rather the pointless crypto_rng system which no one
> uses.  So if it was intended to provide entropy for /dev/urandom etc.,
> that isn't what it's doing.

>
> Can we just delete this driver?
>
> - Eric

Re: [PATCH] crypto: loongson - Select CRYPTO_RNG
Posted by Eric Biggers 2 days, 15 hours ago
On Fri, May 22, 2026 at 11:41:15AM +0800, Qunqin Zhao wrote:
> 
> 在 2026/5/22 上午10:57, Eric Biggers 写道:
> > On Fri, May 22, 2026 at 10:52:42AM +0800, Huacai Chen wrote:
> > > On Fri, May 22, 2026 at 10:26 AM Eric Biggers <ebiggers@kernel.org> wrote:
> > > > This driver registers a rng_alg, so it requires CRYPTO_RNG.
> > > > 
> > > > Fixes: 766b2d724c8d ("crypto: loongson - add Loongson RNG driver support")
> > > > Reported-by: kernel test robot <lkp@intel.com>
> > > > Closes: https://lore.kernel.org/oe-kbuild-all/202605201622.qWOiiZTV-lkp@intel.com/
> > > > Cc: stable@vger.kernel.org
> > > > Signed-off-by: Eric Biggers <ebiggers@kernel.org>
> > > Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
> > > > ---
> > > >   drivers/crypto/loongson/Kconfig | 1 +
> > > >   1 file changed, 1 insertion(+)
> > > > 
> > By the way, do any of the loongson people have any comment on what they
> > think the point of this driver is?  It's not registered with the actual
> 
> To provide an AF_ALG-based random number generation interface for other
> modules and user-space programs.
> 
> Thanks,
> 
> Qunqin

AF_ALG is a userspace interface; it's not available for in-kernel use.
If you mean using crypto_rng directly, note that no kernel code actually
uses it other than the tests, the implementation of AF_ALG, and the
FIPS-specific code which uses drbg.c specifically.

So, the first half of your justification doesn't make any sense.

As far as the second half: why would a userspace program do that instead
of just using the regular Linux RNG (/dev/urandom)?

AFAIK, the only reason to use a HW RNG directly is for certification
reasons.

However, there's also already an interface for that: /dev/hw_random.

So AF_ALG seems completely redundant for this case.

- Eric
Re: [PATCH] crypto: loongson - Select CRYPTO_RNG
Posted by Qunqin Zhao 2 days, 12 hours ago
在 2026/5/22 下午12:03, Eric Biggers 写道:
> On Fri, May 22, 2026 at 11:41:15AM +0800, Qunqin Zhao wrote:
>> 在 2026/5/22 上午10:57, Eric Biggers 写道:
>>> On Fri, May 22, 2026 at 10:52:42AM +0800, Huacai Chen wrote:
>>>> On Fri, May 22, 2026 at 10:26 AM Eric Biggers <ebiggers@kernel.org> wrote:
>>>>> This driver registers a rng_alg, so it requires CRYPTO_RNG.
>>>>>
>>>>> Fixes: 766b2d724c8d ("crypto: loongson - add Loongson RNG driver support")
>>>>> Reported-by: kernel test robot <lkp@intel.com>
>>>>> Closes: https://lore.kernel.org/oe-kbuild-all/202605201622.qWOiiZTV-lkp@intel.com/
>>>>> Cc: stable@vger.kernel.org
>>>>> Signed-off-by: Eric Biggers <ebiggers@kernel.org>
>>>> Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
>>>>> ---
>>>>>    drivers/crypto/loongson/Kconfig | 1 +
>>>>>    1 file changed, 1 insertion(+)
>>>>>
>>> By the way, do any of the loongson people have any comment on what they
>>> think the point of this driver is?  It's not registered with the actual
>> To provide an AF_ALG-based random number generation interface for other
>> modules and user-space programs.
>>
>> Thanks,
>>
>> Qunqin
> AF_ALG is a userspace interface; it's not available for in-kernel use.
> If you mean using crypto_rng directly, note that no kernel code actually
> uses it other than the tests, the implementation of AF_ALG, and the
> FIPS-specific code which uses drbg.c specifically.
>
> So, the first half of your justification doesn't make any sense.
>
> As far as the second half: why would a userspace program do that instead
> of just using the regular Linux RNG (/dev/urandom)?
>
> AFAIK, the only reason to use a HW RNG directly is for certification
> reasons.
>
> However, there's also already an interface for that: /dev/hw_random.
>
> So AF_ALG seems completely redundant for this case.

To be honest, I previously assumed that the `hw_random` was designed 
strictly and exclusively for the TRNG mode.

Is it architecturally acceptable or common practice for a PRNG mode to 
utilize `hw_random` as well?

Thanks,

Qunqin

>
> - Eric

Re: [PATCH] crypto: loongson - Select CRYPTO_RNG
Posted by Eric Biggers 2 days, 1 hour ago
On Fri, May 22, 2026 at 02:40:38PM +0800, Qunqin Zhao wrote:
> 
> 在 2026/5/22 下午12:03, Eric Biggers 写道:
> > On Fri, May 22, 2026 at 11:41:15AM +0800, Qunqin Zhao wrote:
> > > 在 2026/5/22 上午10:57, Eric Biggers 写道:
> > > > On Fri, May 22, 2026 at 10:52:42AM +0800, Huacai Chen wrote:
> > > > > On Fri, May 22, 2026 at 10:26 AM Eric Biggers <ebiggers@kernel.org> wrote:
> > > > > > This driver registers a rng_alg, so it requires CRYPTO_RNG.
> > > > > > 
> > > > > > Fixes: 766b2d724c8d ("crypto: loongson - add Loongson RNG driver support")
> > > > > > Reported-by: kernel test robot <lkp@intel.com>
> > > > > > Closes: https://lore.kernel.org/oe-kbuild-all/202605201622.qWOiiZTV-lkp@intel.com/
> > > > > > Cc: stable@vger.kernel.org
> > > > > > Signed-off-by: Eric Biggers <ebiggers@kernel.org>
> > > > > Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>
> > > > > > ---
> > > > > >    drivers/crypto/loongson/Kconfig | 1 +
> > > > > >    1 file changed, 1 insertion(+)
> > > > > > 
> > > > By the way, do any of the loongson people have any comment on what they
> > > > think the point of this driver is?  It's not registered with the actual
> > > To provide an AF_ALG-based random number generation interface for other
> > > modules and user-space programs.
> > > 
> > > Thanks,
> > > 
> > > Qunqin
> > AF_ALG is a userspace interface; it's not available for in-kernel use.
> > If you mean using crypto_rng directly, note that no kernel code actually
> > uses it other than the tests, the implementation of AF_ALG, and the
> > FIPS-specific code which uses drbg.c specifically.
> > 
> > So, the first half of your justification doesn't make any sense.
> > 
> > As far as the second half: why would a userspace program do that instead
> > of just using the regular Linux RNG (/dev/urandom)?

Could you answer this question?  If there's no answer to this question,
then there's no use case for this driver as-is.

> > AFAIK, the only reason to use a HW RNG directly is for certification
> > reasons.
> > 
> > However, there's also already an interface for that: /dev/hw_random.
> > 
> > So AF_ALG seems completely redundant for this case.
> 
> To be honest, I previously assumed that the `hw_random` was designed
> strictly and exclusively for the TRNG mode.
> 
> Is it architecturally acceptable or common practice for a PRNG mode to
> utilize `hw_random` as well?
> 
> Thanks,

So the Loongson RNG is a PRNG?  Where does it get its entropy from, and
what is its security strength?

- Eric