* [PATCH] random: clamp credited irq bits to maximum mixed
@ 2022-09-23 9:22 Jason A. Donenfeld
2022-09-23 10:26 ` [PATCH v2] " Jason A. Donenfeld
0 siblings, 1 reply; 2+ messages in thread
From: Jason A. Donenfeld @ 2022-09-23 9:22 UTC (permalink / raw)
To: linux-kernel; +Cc: Jason A. Donenfeld
Since the most that's mixed into the pool is sizeof(long)*2, don't
credit more than that many bytes of entropy.
Fixes: e3e33fc2ea7f ("random: do not use input pool from hard IRQs")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
drivers/char/random.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 520a385c7dab..593fb3b3cf74 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1004,7 +1004,7 @@ static void mix_interrupt_randomness(struct work_struct *work)
local_irq_enable();
mix_pool_bytes(pool, sizeof(pool));
- credit_init_bits(max(1u, (count & U16_MAX) / 64));
+ credit_init_bits(clamp_t(unsigned int, 1, (count & U16_MAX) / 64, sizeof(pool) * 8));
memzero_explicit(pool, sizeof(pool));
}
--
2.37.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH v2] random: clamp credited irq bits to maximum mixed
2022-09-23 9:22 [PATCH] random: clamp credited irq bits to maximum mixed Jason A. Donenfeld
@ 2022-09-23 10:26 ` Jason A. Donenfeld
0 siblings, 0 replies; 2+ messages in thread
From: Jason A. Donenfeld @ 2022-09-23 10:26 UTC (permalink / raw)
To: linux-kernel; +Cc: Jason A. Donenfeld
Since the most that's mixed into the pool is sizeof(long)*2, don't
credit more than that many bytes of entropy.
Fixes: e3e33fc2ea7f ("random: do not use input pool from hard IRQs")
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
drivers/char/random.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 520a385c7dab..2f370aa248b2 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1004,7 +1004,7 @@ static void mix_interrupt_randomness(struct work_struct *work)
local_irq_enable();
mix_pool_bytes(pool, sizeof(pool));
- credit_init_bits(max(1u, (count & U16_MAX) / 64));
+ credit_init_bits(clamp_t(unsigned int, (count & U16_MAX) / 64, 1, sizeof(pool) * 8));
memzero_explicit(pool, sizeof(pool));
}
--
2.37.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-23 10:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-23 9:22 [PATCH] random: clamp credited irq bits to maximum mixed Jason A. Donenfeld
2022-09-23 10:26 ` [PATCH v2] " Jason A. Donenfeld
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).