Messages in this thread Patch in this message | | | From | "Luck, Tony" <> | Subject | RE: [PATCH 01/11] random: don't feed stack data into pool when interrupt regs NULL | Date | Mon, 30 Sep 2013 20:51:43 +0000 |
| |
> In this case fast_mix would use two uninitialized ints from the stack > and mix it into the pool.
Is the concern here is that an attacker might know (or be able to control) what is on the stack - and so get knowledge of what is being mixed into the pool?
> In this case set the input to 0.
And the fix is to guarantee that everyone knows what is being mixed in? (!)
Wouldn't it be better to adjust the "nbytes" parameter to
fast_mix(..., ..., sizeof (input));
to only mix in the part of input[] that we successfully initialized?
Untested patch below.
Signed-off-by: Tony Luck <tony.luck@intel.com>
---
diff --git a/drivers/char/random.c b/drivers/char/random.c index 7737b5bd26af..5c4ec0abb702 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -745,16 +745,19 @@ void add_interrupt_randomness(int irq, int irq_flags) struct pt_regs *regs = get_irq_regs(); unsigned long now = jiffies; __u32 input[4], cycles = get_cycles(); + int nbytes; input[0] = cycles ^ jiffies; input[1] = irq; + nbytes = 2 * sizeof(input[0]); if (regs) { __u64 ip = instruction_pointer(regs); input[2] = ip; input[3] = ip >> 32; + nbytes += 2 * sizeof(input[0]); } - fast_mix(fast_pool, input, sizeof(input)); + fast_mix(fast_pool, input, nbytes); if ((fast_pool->count & 1023) && !time_after(now, fast_pool->last + HZ))
| |