summaryrefslogtreecommitdiff
path: root/drivers/char/random.c
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2022-09-23 03:42:51 +0300
committerJason A. Donenfeld <Jason@zx2c4.com>2022-09-23 13:31:05 +0300
commite78a802a7b4febf53f2a92842f494b01062d85a8 (patch)
tree8e6b445d2afa1e8111d6047c1d12ee48d601ac3b /drivers/char/random.c
parentd775335e350fc07e1322960ee291dc9079ab938e (diff)
downloadlinux-e78a802a7b4febf53f2a92842f494b01062d85a8.tar.xz
random: clamp credited irq bits to maximum mixed
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") Cc: stable@vger.kernel.org Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'drivers/char/random.c')
-rw-r--r--drivers/char/random.c2
1 files changed, 1 insertions, 1 deletions
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));
}