linux-s390.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin Schwidefsky <schwidefsky@de.ibm.com>
To: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-s390@vger.kernel.org
Cc: Ralph Wuerthner <rwuerthn@de.ibm.com>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>
Subject: [patch 1/2] hw_random: allow rng_dev_read() to return hardware errors.
Date: Fri, 14 Mar 2008 10:25:24 +0100	[thread overview]
Message-ID: <20080314093046.656233449@de.ibm.com> (raw)
In-Reply-To: 20080314092523.147382820@de.ibm.com

[-- Attachment #1: 111-crypto-hwerrors.diff --]
[-- Type: text/plain, Size: 1220 bytes --]

From: Ralph Wuerthner <rwuerthn@de.ibm.com>

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 <rwuerthn@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
---

 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.

  reply	other threads:[~2008-03-14  9:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-14  9:25 [patch 0/2] CEX2C hardware random numbers Martin Schwidefsky
2008-03-14  9:25 ` Martin Schwidefsky [this message]
2008-03-31 14:19   ` [patch 1/2] hw_random: allow rng_dev_read() to return hardware errors Herbert Xu
2008-03-14  9:25 ` [patch 2/2] zcrypt: add support for large random numbers Martin Schwidefsky
2008-03-14 16:14   ` Randy Dunlap
2008-03-17  9:44     ` Martin Schwidefsky
2008-03-17 15:02       ` Randy Dunlap
2008-03-31 14:21   ` Herbert Xu
2008-03-31 14:39     ` Martin Schwidefsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080314093046.656233449@de.ibm.com \
    --to=schwidefsky@de.ibm.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=rwuerthn@de.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).