linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.apana.org.au>
To: "Stephan Müller" <smueller@chronox.de>
Cc: linux-crypto@vger.kernel.org
Subject: Re: [PATCH 1/2] crypto: Jitter RNG SP800-90B compliance
Date: Thu, 16 Apr 2020 16:15:29 +1000	[thread overview]
Message-ID: <20200416061529.GB19267@gondor.apana.org.au> (raw)
In-Reply-To: <4128830.EzT7ouGoCQ@positron.chronox.de>

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.

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

  reply	other threads:[~2020-04-16  6:15 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 [this message]
2020-04-16  6:56     ` Stephan Mueller
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=20200416061529.GB19267@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=smueller@chronox.de \
    /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).