diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-06-03 02:19:47 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-06-03 02:19:47 +0300 |
commit | 5a4829b564d2f69574dc55bba2ada3ee72022187 (patch) | |
tree | e27a16b2a564ef9a2263ca7cef83165664912dea /drivers | |
parent | f219764920c3d235713566013375cc01decd3d49 (diff) | |
parent | 9dfa7bba35ac08a63565d58c454dccb7e1bb0a08 (diff) | |
download | linux-5a4829b564d2f69574dc55bba2ada3ee72022187.tar.xz |
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()
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/char/random.c | 6 |
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) |