Commit b0afd9d1 authored by Theodore Ts'o's avatar Theodore Ts'o Committed by Greg Kroah-Hartman

random: use a tighter cap in credit_entropy_bits_safe()

commit 9f886f4d upstream.

This fixes a harmless UBSAN where root could potentially end up
causing an overflow while bumping the entropy_total field (which is
ignored once the entropy pool has been initialized, and this generally
is completed during the boot sequence).

This is marginal for the stable kernel series, but it's a really
trivial patch, and it fixes UBSAN warning that might cause security
folks to get overly excited for no reason.
Signed-off-by: default avatarTheodore Ts'o <>
Reported-by: default avatarChen Feng <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent 439e8b2d
......@@ -732,7 +732,7 @@ static void credit_entropy_bits(struct entropy_store *r, int nbits)
static int credit_entropy_bits_safe(struct entropy_store *r, int nbits)
const int nbits_max = (int)(~0U >> (ENTROPY_SHIFT + 1));
const int nbits_max = r->poolinfo->poolwords * 32;
if (nbits < 0)
return -EINVAL;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment