linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephan Mueller <smueller@chronox.de>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: linux-crypto@vger.kernel.org
Subject: Re: [PATCH 1/2] crypto: Jitter RNG SP800-90B compliance
Date: Thu, 16 Apr 2020 08:56:38 +0200	[thread overview]
Message-ID: <2920846.pNu1SyRcjk@tauon.chronox.de> (raw)
In-Reply-To: <20200416061529.GB19267@gondor.apana.org.au>

Am Donnerstag, 16. April 2020, 08:15:29 CEST schrieb Herbert Xu:

Hi Herbert,

> On Sat, Apr 11, 2020 at 09:35:03PM +0200, Stephan Müller wrote:
> > @@ -142,7 +143,47 @@ static int jent_kcapi_random(struct crypto_rng *tfm,
> > 
> >  	int ret = 0;
> >  	
> >  	spin_lock(&rng->jent_lock);
> > 
> > +
> > +	/* Return a permanent error in case we had too many resets in a row. 
*/
> > +	if (rng->reset_cnt > (1<<10)) {
> > +		ret = -EFAULT;
> > +		goto out;
> > +	}
> > +
> > 
> >  	ret = jent_read_entropy(rng->entropy_collector, rdata, dlen);
> > 
> > +
> > +	/* Reset RNG in case of health failures */
> > +	if (ret < -1) {
> > +		pr_warn_ratelimited("Reset Jitter RNG due to health test 
failure: %s
> > failure\n", +				    (ret == -2) ? "Repetition 
Count Test" :
> > +						  "Adaptive Proportion Test");
> > +
> > +		rng->reset_cnt++;
> > +
> > +		ret = jent_entropy_init();
> > +		if (ret) {
> > +			pr_warn_ratelimited("Jitter RNG self-tests failed: 
%d\n",
> > +					    ret);
> > +			ret = -EFAULT;
> > +			goto out;
> > +		}
> > +		jent_entropy_collector_free(rng->entropy_collector);
> > +		rng->entropy_collector = jent_entropy_collector_alloc(1, 0);
> 
> You can't do a GFP_KERNEL allocation inside spin-locks.

Of course, thanks for pointing that out. I will send an update shortly.

Ciao
Stephan



  reply	other threads:[~2020-04-16  6:56 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-11 19:34 [PATCH 0/2] crypto: Jitter RNG SP800-90B compliance Stephan Müller
2020-04-11 19:35 ` [PATCH 1/2] " Stephan Müller
2020-04-16  6:15   ` Herbert Xu
2020-04-16  6:56     ` Stephan Mueller [this message]
2020-04-11 19:35 ` [PATCH 2/2] crypto: DRBG always seeded with SP800-90B compliant noise source Stephan Müller

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=2920846.pNu1SyRcjk@tauon.chronox.de \
    --to=smueller@chronox.de \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    /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).