random: fix BUG_ON caused by accounting simplification
authorTheodore Ts'o <tytso@mit.edu>
Sat, 17 May 2014 01:40:41 +0000 (21:40 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Sat, 17 May 2014 02:18:22 +0000 (22:18 -0400)
commitf9c6d4987b23e0a514464bae6771933a48e4cd01
tree4470c1ccd9ade767d3c3928ebb2432e9c9d32546
parentd6d211db37e75de2ddc3a4f979038c40df7cc79c
random: fix BUG_ON caused by accounting simplification

Commit ee1de406ba6eb1 ("random: simplify accounting logic") simplified
things too much, in that it allows the following to trigger an
overflow that results in a BUG_ON crash:

dd if=/dev/urandom of=/dev/zero bs=67108707 count=1

Thanks to Peter Zihlstra for discovering the crash, and Hannes
Frederic for analyizing the root cause.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Reported-by: Peter Zijlstra <peterz@infradead.org>
Reported-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Cc: Greg Price <price@mit.edu>
drivers/char/random.c