[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFArEyWsuvEMFQ-CpTeawBbDY1egDzXf1HaOyd9z-uKcbSCq=Q@mail.gmail.com>
Date: Fri, 15 Feb 2019 14:03:06 -0800
From: Sultan Alsawaf <sultan@...neltoast.com>
To: tytso@....edu
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH] random: fix inconsistent spinlock usage
All users of the struct entropy_store spinlock use the irqsave spinlock variant.
Spinlock users of the same lock should use be consistent in their use of a
certain spinlock primitive, which makes add_interrupt_randomness()'s spinlock
usage incorrect.
Fix the inconsistency by converting add_interrupt_randomness()'s spinlocks to
use the irqsave primitive.
Signed-off-by: Sultan Alsawaf <sultan@...neltoast.com>
---
drivers/char/random.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/char/random.c b/drivers/char/random.c
index 38c6d1af6..1365017a7 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -1239,6 +1239,7 @@ void add_interrupt_randomness(int irq, int irq_flags)
__u64 ip;
unsigned long seed;
int credit = 0;
+ unsigned long flags;
if (cycles == 0)
cycles = get_reg(fast_pool, regs);
@@ -1269,7 +1270,7 @@ void add_interrupt_randomness(int irq, int irq_flags)
return;
r = &input_pool;
- if (!spin_trylock(&r->lock))
+ if (!spin_trylock_irqsave(&r->lock, flags))
return;
fast_pool->last = now;
@@ -1285,7 +1286,7 @@ void add_interrupt_randomness(int irq, int irq_flags)
__mix_pool_bytes(r, &seed, sizeof(seed));
credit = 1;
}
- spin_unlock(&r->lock);
+ spin_unlock_irqrestore(&r->lock, flags);
fast_pool->count = 0;
--
2.20.1
Powered by blists - more mailing lists