From: Thorsten Blum <blum@kernel.org>
To: Olivia Mackall <olivia@selenic.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
Thorsten Blum <blum@kernel.org>,
Manos Pitsidianakis <manos@pitsidianak.is>,
Andy Shevchenko <andriy.shevchenko@intel.com>,
David Laight <david.laight.linux@gmail.com>,
Jonathan McDowell <noodles@meta.com>,
Lianjie Wang <karin0.zst@gmail.com>,
"Thomas Richard (TI)" <thomas.richard@bootlin.com>,
PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] hwrng: core - reject unknown RNG names
Date: Thu, 24 Sep 2026 23:21:13 +0200 [thread overview]
Message-ID: <20260924212114.120633-2-blum@kernel.org> (raw)
In rng_current_store(), err is 0 after successfully locking rng_mutex,
and if the requested RNG name cannot be found, the function reports
success even though the current RNG was not changed.
Set err = -ENODEV before searching the RNG list to reject unknown names.
Fixes: 142a27f0a731 ("hwrng: core - Reset user selected rng by writing "" to rng_current")
Cc: stable@vger.kernel.org
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
drivers/char/hw_random/core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index 57eeefe90da9..1f9e31cdc7f0 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -376,6 +376,7 @@ static ssize_t rng_current_store(struct device *dev,
cur_rng_set_by_user = 1;
drop_current_rng();
} else {
+ err = -ENODEV;
list_for_each_entry(rng, &rng_list, list) {
if (sysfs_streq(rng->name, buf)) {
err = set_current_rng(rng);
next reply other threads:[~2026-09-24 21:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 21:21 Thorsten Blum [this message]
2026-09-25 10:00 ` Andy Shevchenko
2026-09-25 10:06 ` Andy Shevchenko
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=20260924212114.120633-2-blum@kernel.org \
--to=blum@kernel.org \
--cc=andriy.shevchenko@intel.com \
--cc=david.laight.linux@gmail.com \
--cc=herbert@gondor.apana.org.au \
--cc=karin0.zst@gmail.com \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=manos@pitsidianak.is \
--cc=noodles@meta.com \
--cc=olivia@selenic.com \
--cc=prasannatsmkumar@gmail.com \
--cc=thomas.richard@bootlin.com \
/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
all inboxes | Powered by JetHome®