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()
Unified · Split
| @@ -1097,12 +1097,16 @@ static void add_interrupt_bench(cycles_t start) · 1096 unmodified lines | ||
| 1097 | 1097 | static __u32 get_reg(struct fast_pool *f, struct pt_regs *regs) |
| 1098 | 1098 | { |
| 1099 | 1099 | __u32 *ptr = (__u32 *) regs; |
| 1100 | + unsigned long flags; | |
| 1100 | 1101 | |
| 1101 | 1102 | if (regs == NULL) |
| 1102 | 1103 | return 0; |
| 1104 | + local_irq_save(flags); | |
| 1103 | 1105 | if (f->reg_idx >= sizeof(struct pt_regs) / sizeof(__u32)) |
| 1104 | 1106 | f->reg_idx = 0; |
| 1105 | − return *(ptr + f->reg_idx++); | |
| 1107 | + ptr += f->reg_idx++; | |
| 1108 | + local_irq_restore(flags); | |
| 1109 | + return *ptr; | |
| 1106 | 1110 | } |
| 1107 | 1111 | |
| 1108 | 1112 | void add_interrupt_randomness(int irq, int irq_flags) |