random: use a tighter cap in credit_entropy_bits_safe()
authorTheodore Ts'o <tytso@mit.edu>
Sat, 25 Feb 2017 22:21:33 +0000 (18:21 -0400)
committerSasha Levin <alexander.levin@microsoft.com>
Wed, 23 May 2018 01:36:33 +0000 (21:36 -0400)
commit0783df1065bdc483ababf31e35338cac0e9b789a
treeeb53c015eeec619b21c347e68ace2618f9a69dc5
parentc2fbb66c81b5ed656fd03b1ef43ad1dc621ccbc4
random: use a tighter cap in credit_entropy_bits_safe()

[ Upstream commit 9f886f4d1d292442b2f22a0a33321eae821bde40 ]

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: Theodore Ts'o <tytso@mit.edu>
Reported-by: Chen Feng <puck.chen@hisilicon.com>
Cc: stable@vger.kernel.org
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
drivers/char/random.c