Re: [PATCH 3/4] crypto: qcom-rng - Remove crypto_rng interface

From: Dmitry Baryshkov

Date: Sun Jun 07 2026 - 17:05:45 EST


On Fri, May 29, 2026 at 07:03:31PM -0700, Eric Biggers wrote:
> qcom-rng.c exposes the same hardware through two completely separate
> interfaces, crypto_rng and hwrng. However, the implementation of this
> is buggy because it permits generation operations from these interfaces
> to run concurrently with each other, accessing the same registers. That
> is, qcom_rng_generate() synchronizes with itself but not with
> qcom_hwrng_read(). This results in potential repetition of output from
> the RNG, output of non-random values, etc.
>
> Fortunately, there's actually no point in hardware RNG drivers
> implementing the crypto_rng interface. It's not actually used by
> anything besides the "rng" algorithm type of AF_ALG, which in turn is
> not actually used in practice. Other crypto_rng hardware drivers are
> likewise being phased out, leaving just the hwrng support.

It looks like Debian codebase knows about exactly two users of "rng":
kernel itself and stress-ng:

https://codesearch.debian.net/search?q=.salg_type.*%22rng%22&literal=0


> Thus, remove it to simplify the code and avoid conflict (and confusion)
> with the hwrng interface which is the one that actually matters.
>
> Note that while this means the driver stops supporting "qcom,prng" and
> "qcom,prng-ee", it didn't do anything useful on SoCs with those anyway.
>
> Fixes: f29cd5bb64c2 ("crypto: qcom-rng - Add hw_random interface support")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Eric Biggers <ebiggers@xxxxxxxxxx>
> ---
> drivers/crypto/Kconfig | 1 -
> drivers/crypto/qcom-rng.c | 175 ++------------------------------------
> 2 files changed, 9 insertions(+), 167 deletions(-)
>
> static const struct of_device_id __maybe_unused qcom_rng_of_match[] = {
> - { .compatible = "qcom,prng", .data = &qcom_prng_match_data },
> - { .compatible = "qcom,prng-ee", .data = &qcom_prng_ee_match_data },
> - { .compatible = "qcom,trng", .data = &qcom_trng_match_data },
> + { .compatible = "qcom,trng" },

This means that the devices won't be bound to the driver, which will
affect GCC state when we finally get the clk_sync_state() supported in
the kernel.

I'd ask to keep on binding to the qcom,prng / prng-ee devices and skip
hwrng registration (possibly with some dev_info message).

> {}
> };
> MODULE_DEVICE_TABLE(of, qcom_rng_of_match);
>
> static struct platform_driver qcom_rng_driver = {
> .probe = qcom_rng_probe,
> - .remove = qcom_rng_remove,
> .driver = {
> .name = KBUILD_MODNAME,
> .of_match_table = qcom_rng_of_match,
> - .acpi_match_table = ACPI_PTR(qcom_rng_acpi_match),
> }
> };
> module_platform_driver(qcom_rng_driver);
>
> MODULE_ALIAS("platform:" KBUILD_MODNAME);
> --
> 2.54.0
>

--
With best wishes
Dmitry