Jiri Kosina 10b3a32d29 random: fix accounting race condition with lockless irq entropy_count update
Commit 902c098a3663 ("random: use lockless techniques in the interrupt
path") turned IRQ path from being spinlock protected into lockless
cmpxchg-retry update.

That commit removed r->lock serialization between crediting entropy bits
from IRQ context and accounting when extracting entropy on userspace
read path, but didn't turn the r->entropy_count reads/updates in
account() to use cmpxchg as well.

It has been observed, that under certain circumstances this leads to
read() on /dev/urandom to return 0 (EOF), as r->entropy_count gets
corrupted and becomes negative, which in turn results in propagating 0
all the way from account() to the actual read() call.

Convert the accounting code to be the proper lockless counterpart of
what has been partially done by 902c098a3663.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Cc: Theodore Ts'o <tytso@mit.edu>
Cc: Greg KH <greg@kroah.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-05-24 16:22:52 -07:00
..
2013-03-15 12:23:48 -07:00
2013-05-05 00:11:29 -04:00
2013-02-22 23:31:31 -05:00
2013-02-22 23:31:31 -05:00
2013-05-05 00:12:29 -04:00
2013-05-05 00:12:29 -04:00
2012-10-16 18:07:12 -07:00
2012-11-21 12:55:19 -08:00
2011-03-31 11:26:23 -03:00
2013-05-07 20:16:25 -07:00
2013-02-22 23:31:31 -05:00
2012-03-28 18:30:03 +01:00
2012-10-07 07:22:32 -07:00
2013-02-22 23:31:31 -05:00
2013-02-22 23:31:31 -05:00
2013-02-22 23:31:31 -05:00
2011-01-10 08:51:44 -08:00
2013-02-22 23:31:31 -05:00