]> git.baikalelectronics.ru Git - kernel.git/commit
random: do not sign extend bytes for rotation when mixing
authorJason A. Donenfeld <Jason@zx2c4.com>
Fri, 24 Dec 2021 18:17:58 +0000 (19:17 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 30 May 2022 07:29:00 +0000 (09:29 +0200)
commit013ee627e77ead8decd794fb9ae356e1c11d340e
tree78d6ead8de6e4cf6ca7e2f0c889edef8ca9c79b9
parentac2ce5de41b4e8f1b8d7304021a25f0acc90b865
random: do not sign extend bytes for rotation when mixing

commit ee23e1dbf69516500f97c452fb8626e45e13c3c2 upstream.

By using `char` instead of `unsigned char`, certain platforms will sign
extend the byte when `w = rol32(*bytes++, input_rotate)` is called,
meaning that bit 7 is overrepresented when mixing. This isn't a real
problem (unless the mixer itself is already broken) since it's still
invertible, but it's not quite correct either. Fix this by using an
explicit unsigned type.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/random.c