Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: Qunqin Zhao <zhaoqunqin@loongson.cn>
Cc: Huacai Chen <chenhuacai@kernel.org>,
	linux-crypto@vger.kernel.org,
	Herbert Xu <herbert@gondor.apana.org.au>,
	linux-kernel@vger.kernel.org, loongarch@lists.linux.dev,
	Yinggang Gu <guyinggang@loongson.cn>, Lee Jones <lee@kernel.org>,
	kernel test robot <lkp@intel.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH] crypto: loongson - Select CRYPTO_RNG
Date: Mon, 25 May 2026 09:59:39 -0500	[thread overview]
Message-ID: <20260525145939.GC2018@quark> (raw)
In-Reply-To: <05c794a7-f82d-5454-8df9-0ac543f8f8f7@loongson.cn>

On Mon, May 25, 2026 at 04:17:25PM +0800, Qunqin Zhao wrote:
> 
> 在 2026/5/25 上午11:20, Eric Biggers 写道:
> > On Mon, May 25, 2026 at 10:45:14AM +0800, Qunqin Zhao wrote:
> > > > > 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?
> > > Loongson's hardware supports both TRNG and PRNG simultaneously.
> > > 
> > > We can locate a reseed function within loongson-rng.c, which clearly
> > > indicates that it is a PRNG driver.
> > That reseed function gets called with entropy from the Linux RNG.  So,
> > it seems it's really just a PRNG seeded from the Linux RNG.  What value
> > does that provide over just using the Linux RNG directly?
> 
> Alternatively,the reseed function can serve  as a stirring mechanism, where
> the primary entropy comes from the internal hardware TRNG.
> 
> Or simply ignore the  entropy from the Linux RNG entirely, trigger a
> reseeding internal.
> 
> 
> The driver merely forwards the seed to the firmware; how it is utilized and
> what kind of random numbers are returned are entirely determined by the
> firmware implementation.
> 
> > 
> > > So the core issue here is whether a PRNG driver can utilize the crypto
> > > interface.
> > If you're asking about crypto_rng, it can.  But the crypto_rng interface
> > is also kind of useless.  If you're asking about hwrng, it does look
> > like it's designed for TRNGs.  Would it be possible for this driver to
> > use the TRNG mode?
> 
> I mean crypto_rng.
> 
> We might use the hwrng interface to add support for the TRNG in this driver.

If you can actually provide fresh entropy on each call, then yes you
should implement hwrng.

> > 
> > > If it cannot, does that imply the drivers listed below serve no practical
> > > purpose? (7.1-rc1)
> > > 
> > > loongson@loongson:~/upstream/linux/drivers/crypto$ grep crypto_register_rng
> > Most of the drivers in drivers/crypto/ are added by the hardware
> > manufacturer without any regard for whether they're useful or not.
> 
> If we are dropping crypto-rng drivers entirely,

We should, since they have no real point.

> I am fine with removing the Loongson driver along with the others.
> 
> However, targeting the Loongson driver alone is unacceptable.

We just happen to be digging into the details on this driver right now,
since we're having to spend time fixing it.  Thanks for confirming that
this is supported purely for parity with other drivers.

- Eric

      reply	other threads:[~2026-05-25 14:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-22  2:25 [PATCH] crypto: loongson - Select CRYPTO_RNG Eric Biggers
2026-05-22  2:52 ` Huacai Chen
2026-05-22  2:57   ` Eric Biggers
2026-05-22  3:41     ` Qunqin Zhao
2026-05-22  4:03       ` Eric Biggers
2026-05-22  6:40         ` Qunqin Zhao
2026-05-22 17:48           ` Eric Biggers
2026-05-25  2:45             ` Qunqin Zhao
2026-05-25  3:20               ` Eric Biggers
2026-05-25  8:17                 ` Qunqin Zhao
2026-05-25 14:59                   ` Eric Biggers [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260525145939.GC2018@quark \
    --to=ebiggers@kernel.org \
    --cc=chenhuacai@kernel.org \
    --cc=guyinggang@loongson.cn \
    --cc=herbert@gondor.apana.org.au \
    --cc=lee@kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=loongarch@lists.linux.dev \
    --cc=stable@vger.kernel.org \
    --cc=zhaoqunqin@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox