2008-03-14 09:30:51

by Martin Schwidefsky

[permalink] [raw]
Subject: [patch 1/2] hw_random: allow rng_dev_read() to return hardware errors.

From: Ralph Wuerthner <[email protected]>

The api for hardware random number generators is currently limited to
devices that never fail. If the hardware is registered as a source for
random numbers it has to work. This prevents the use of i/o based
random number devices where the i/o might fail.

Add a check for errors after the read from a hardware random number device.

This patch is required to support large random numbers retrieved
from the CEX2C cards on System z.

Signed-off-by: Ralph Wuerthner <[email protected]>
Signed-off-by: Martin Schwidefsky <[email protected]>
---

drivers/char/hw_random/core.c | 4 ++++
1 file changed, 4 insertions(+)

Index: quilt-2.6/drivers/char/hw_random/core.c
===================================================================
--- quilt-2.6.orig/drivers/char/hw_random/core.c
+++ quilt-2.6/drivers/char/hw_random/core.c
@@ -116,6 +116,10 @@ static ssize_t rng_dev_read(struct file
err = -EAGAIN;
if (!bytes_read && (filp->f_flags & O_NONBLOCK))
goto out;
+ if (bytes_read < 0) {
+ err = bytes_read;
+ goto out;
+ }

err = -EFAULT;
while (bytes_read && size) {

--
blue skies,
Martin.

"Reality continues to ruin my life." - Calvin.



2008-03-31 14:19:51

by Herbert Xu

[permalink] [raw]
Subject: Re: [patch 1/2] hw_random: allow rng_dev_read() to return hardware errors.

On Fri, Mar 14, 2008 at 09:25:24AM +0000, Martin Schwidefsky wrote:
> From: Ralph Wuerthner <[email protected]>
>
> The api for hardware random number generators is currently limited to
> devices that never fail. If the hardware is registered as a source for
> random numbers it has to work. This prevents the use of i/o based
> random number devices where the i/o might fail.
>
> Add a check for errors after the read from a hardware random number device.
>
> This patch is required to support large random numbers retrieved
> from the CEX2C cards on System z.
>
> Signed-off-by: Ralph Wuerthner <[email protected]>
> Signed-off-by: Martin Schwidefsky <[email protected]>

Thanks for the patch. I'll pick this up in cryptodev-2.6.

Cheers,
--
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