summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-06-02 16:19:47 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2017-06-02 16:19:47 -0700
commit5a4829b564d2f69574dc55bba2ada3ee72022187 (patch)
treee27a16b2a564ef9a2263ca7cef83165664912dea
parentf219764920c3d235713566013375cc01decd3d49 (diff)
parent9dfa7bba35ac08a63565d58c454dccb7e1bb0a08 (diff)
downloadlinux-5a4829b564d2f69574dc55bba2ada3ee72022187.tar.gz
linux-5a4829b564d2f69574dc55bba2ada3ee72022187.tar.bz2
linux-5a4829b564d2f69574dc55bba2ada3ee72022187.zip
Merge tag 'random_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random
Pull /dev/random bug fix from Ted Ts'o: "Fix a race on architectures with prioritized interrupts (such as m68k) which can causes crashes in drivers/char/random.c:get_reg()" * tag 'random_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/random: fix race in drivers/char/random.c:get_reg()
-rw-r--r--drivers/char/random.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 0ab024918907..a561f0c2f428 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1097,12 +1097,16 @@ static void add_interrupt_bench(cycles_t start)
static __u32 get_reg(struct fast_pool *f, struct pt_regs *regs)
{
__u32 *ptr = (__u32 *) regs;
+ unsigned long flags;
if (regs == NULL)
return 0;
+ local_irq_save(flags);
if (f->reg_idx >= sizeof(struct pt_regs) / sizeof(__u32))
f->reg_idx = 0;
- return *(ptr + f->reg_idx++);
+ ptr += f->reg_idx++;
+ local_irq_restore(flags);
+ return *ptr;
}
void add_interrupt_randomness(int irq, int irq_flags)