Commit 5a4829b5 authored by Linus Torvalds's avatar Linus Torvalds

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()
parents f2197649 9dfa7bba
...@@ -1097,12 +1097,16 @@ static void add_interrupt_bench(cycles_t start) ...@@ -1097,12 +1097,16 @@ static void add_interrupt_bench(cycles_t start)
static __u32 get_reg(struct fast_pool *f, struct pt_regs *regs) static __u32 get_reg(struct fast_pool *f, struct pt_regs *regs)
{ {
__u32 *ptr = (__u32 *) regs; __u32 *ptr = (__u32 *) regs;
unsigned long flags;
if (regs == NULL) if (regs == NULL)
return 0; return 0;
local_irq_save(flags);
if (f->reg_idx >= sizeof(struct pt_regs) / sizeof(__u32)) if (f->reg_idx >= sizeof(struct pt_regs) / sizeof(__u32))
f->reg_idx = 0; 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) void add_interrupt_randomness(int irq, int irq_flags)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment