2009-12-02 12:51:25

by Ian Molton

[permalink] [raw]
Subject: [PATCH] hw_random: prevent too-small buffer sizes

This patch prevents the hw_random core using too small of a buffer
on machines with small cacheline sizes.

Signed-off-by: Ian Molton <[email protected]>
---
drivers/char/hw_random/core.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c
index 5c2d13c..8b7d56a 100644
--- a/drivers/char/hw_random/core.c
+++ b/drivers/char/hw_random/core.c
@@ -53,7 +53,8 @@ static struct hwrng *current_rng;
static LIST_HEAD(rng_list);
static DEFINE_MUTEX(rng_mutex);
static int data_avail;
-static u8 rng_buffer[SMP_CACHE_BYTES] __cacheline_aligned;
+static u8 rng_buffer[SMP_CACHE_BYTES < 32 ? 32 : SMP_CACHE_BYTES]
+ __cacheline_aligned;

static inline int hwrng_init(struct hwrng *rng)
{
--
1.6.5


2009-12-03 05:51:00

by Herbert Xu

[permalink] [raw]
Subject: Re: [PATCH] hw_random: prevent too-small buffer sizes

On Wed, Dec 02, 2009 at 12:50:38PM +0000, Ian Molton wrote:
> This patch prevents the hw_random core using too small of a buffer
> on machines with small cacheline sizes.
>
> Signed-off-by: Ian Molton <[email protected]>

Applied to cryptodev-2.6. Thanks Ian.
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt