Skip to content

Commit e78a802

Browse files
committed
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: e3e33fc ("random: do not use input pool from hard IRQs") Cc: stable@vger.kernel.org Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
1 parent d775335 commit e78a802

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/char/random.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ static void mix_interrupt_randomness(struct work_struct *work)
10041004
local_irq_enable();
10051005

10061006
mix_pool_bytes(pool, sizeof(pool));
1007-
credit_init_bits(max(1u, (count & U16_MAX) / 64));
1007+
credit_init_bits(clamp_t(unsigned int, (count & U16_MAX) / 64, 1, sizeof(pool) * 8));
10081008

10091009
memzero_explicit(pool, sizeof(pool));
10101010
}

0 commit comments

Comments
 (0)