* [PATCH] hwrng: Explicitly drop current_rng when unregistering rng device
@ 2018-01-30 23:26 Keith Packard
2018-01-31 14:36 ` Tom Lendacky
0 siblings, 1 reply; 3+ messages in thread
From: Keith Packard @ 2018-01-30 23:26 UTC (permalink / raw)
To: linux-kernel; +Cc: Keith Packard, Matt Mackall, Herbert Xu
When the currently in-use hw rng is being removed from the system,
explicitly drop it before using enable_best_rng as enable_best_rng
will not do anything if the list of avaialble RNGs is empty.
Without this, the last RNG removed from the system will never get
cleaned up and hwrng_unregister will hang.
Signed-off-by: Keith Packard <keithp@keithp.com>
---
drivers/char/hw_random/core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index 657b8770b6b9..8df3f9f147e2 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -515,8 +515,10 @@ void hwrng_unregister(struct hwrng *rng)
mutex_lock(&rng_mutex);
list_del(&rng->list);
- if (current_rng == rng)
+ if (current_rng == rng) {
+ drop_current_rng();
enable_best_rng();
+ }
if (list_empty(&rng_list)) {
mutex_unlock(&rng_mutex);
--
2.15.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] hwrng: Explicitly drop current_rng when unregistering rng device
2018-01-30 23:26 [PATCH] hwrng: Explicitly drop current_rng when unregistering rng device Keith Packard
@ 2018-01-31 14:36 ` Tom Lendacky
2018-02-05 0:08 ` Keith Packard
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lendacky @ 2018-01-31 14:36 UTC (permalink / raw)
To: Keith Packard, linux-kernel; +Cc: Matt Mackall, Herbert Xu
On 1/30/2018 5:26 PM, Keith Packard wrote:
> When the currently in-use hw rng is being removed from the system,
> explicitly drop it before using enable_best_rng as enable_best_rng
> will not do anything if the list of avaialble RNGs is empty.
>
> Without this, the last RNG removed from the system will never get
> cleaned up and hwrng_unregister will hang.
>
> Signed-off-by: Keith Packard <keithp@keithp.com>
> ---
> drivers/char/hw_random/core.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
> index 657b8770b6b9..8df3f9f147e2 100644
> --- a/drivers/char/hw_random/core.c
> +++ b/drivers/char/hw_random/core.c
> @@ -515,8 +515,10 @@ void hwrng_unregister(struct hwrng *rng)
> mutex_lock(&rng_mutex);
>
> list_del(&rng->list);
> - if (current_rng == rng)
> + if (current_rng == rng) {
> + drop_current_rng();
> enable_best_rng();
> + }
A similar fix was already in the cryptodev tree and I thought was part of
a recent pull request.
Thanks,
Tom
>
> if (list_empty(&rng_list)) {
> mutex_unlock(&rng_mutex);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] hwrng: Explicitly drop current_rng when unregistering rng device
2018-01-31 14:36 ` Tom Lendacky
@ 2018-02-05 0:08 ` Keith Packard
0 siblings, 0 replies; 3+ messages in thread
From: Keith Packard @ 2018-02-05 0:08 UTC (permalink / raw)
To: Tom Lendacky, linux-kernel; +Cc: Matt Mackall, Herbert Xu
[-- Attachment #1: Type: text/plain, Size: 372 bytes --]
Tom Lendacky <thomas.lendacky@amd.com> writes:
> A similar fix was already in the cryptodev tree and I thought was part of
> a recent pull request.
Yup, just saw it on master. I've checked and it will do pretty much the
same thing as my patch, with the addition of clearing
cur_rng_set_by_user, which is necessary. Thanks for looking at my patch!
--
-keith
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-02-05 0:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-30 23:26 [PATCH] hwrng: Explicitly drop current_rng when unregistering rng device Keith Packard
2018-01-31 14:36 ` Tom Lendacky
2018-02-05 0:08 ` Keith Packard
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.