linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bryan O'Donoghue <pure.logic@nexus-software.ie>
To: horia.geanta@nxp.com, aymen.sghaier@nxp.com,
	linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: fabio.estevam@nxp.com, peng.fan@nxp.com, davem@davemloft.net,
	lukas.auer@aisec.fraunhofer.de, rui.silva@linaro.org,
	ryan.harkin@linaro.org,
	Bryan O'Donoghue <pure.logic@nexus-software.ie>,
	"# 4 . 12+" <stable@vger.kernel.org>
Subject: [PATCH v3 2/5] crypto: caam: Fix endless loop when RNG is already initialized
Date: Wed, 31 Jan 2018 02:00:37 +0000	[thread overview]
Message-ID: <1517364040-27607-3-git-send-email-pure.logic@nexus-software.ie> (raw)
In-Reply-To: <1517364040-27607-1-git-send-email-pure.logic@nexus-software.ie>

commit 1005bccd7a4a ("crypto: caam - enable instantiation of all RNG4 state
handles") introduces a control when incrementing ent_delay which contains
the following comment above it:

/*
 * If either SH were instantiated by somebody else
 * (e.g. u-boot) then it is assumed that the entropy
 * parameters are properly set and thus the function
 * setting these (kick_trng(...)) is skipped.
 * Also, if a handle was instantiated, do not change
 * the TRNG parameters.
 */

This is a problem observed when sec_init() has been run in u-boot and
and TrustZone is enabled. We can fix this by instantiating all rng state
handles in u-boot but, on the Kernel side we should ensure that this
non-terminating path is dealt with.

Fixes: 1005bccd7a4a ("crypto: caam - enable instantiation of all RNG4 state
handles")

Reported-by: Ryan Harkin <ryan.harkin@linaro.org>
Cc: "Horia Geantă" <horia.geanta@nxp.com>
Cc: Aymen Sghaier <aymen.sghaier@nxp.com>
Cc: Fabio Estevam <fabio.estevam@nxp.com>
Cc: Peng Fan <peng.fan@nxp.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Lukas Auer <lukas.auer@aisec.fraunhofer.de>
Cc: <stable@vger.kernel.org> # 4.12+
Signed-off-by: Bryan O'Donoghue <pure.logic@nexus-software.ie>
---
 drivers/crypto/caam/ctrl.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c
index 98986d3..0a1e96b 100644
--- a/drivers/crypto/caam/ctrl.c
+++ b/drivers/crypto/caam/ctrl.c
@@ -704,7 +704,10 @@ static int caam_probe(struct platform_device *pdev)
 					 ent_delay);
 				kick_trng(pdev, ent_delay);
 				ent_delay += 400;
+			} else if (ctrlpriv->rng4_sh_init && inst_handles) {
+				ent_delay += 400;
 			}
+
 			/*
 			 * if instantiate_rng(...) fails, the loop will rerun
 			 * and the kick_trng(...) function will modfiy the
-- 
2.7.4

  parent reply	other threads:[~2018-01-31  2:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-31  2:00 [PATCH v3 0/5] Enable CAAM on i.MX7s fix TrustZone issues Bryan O'Donoghue
2018-01-31  2:00 ` [PATCH v3 1/5] crypto: caam: Fix null dereference at error path Bryan O'Donoghue
2018-01-31  2:00 ` Bryan O'Donoghue [this message]
2018-02-01 12:16   ` [PATCH v3 2/5] crypto: caam: Fix endless loop when RNG is already initialized Horia Geantă
2018-02-02 11:20     ` Bryan O'Donoghue
2018-02-02 12:54       ` Auer, Lukas
2018-02-05  8:45         ` Horia Geantă
2018-02-05  9:15           ` [PATCH] crypto: caam - fix endless loop when DECO acquire fails Horia Geantă
2018-02-05 13:54           ` [PATCH v3 2/5] crypto: caam: Fix endless loop when RNG is already initialized Auer, Lukas
2018-01-31  2:00 ` [PATCH v3 3/5] crypto: caam: do not use mem and emi_slow clock for imx7x Bryan O'Donoghue
2018-01-31  2:00 ` [PATCH v3 4/5] clk: imx7d: add CAAM clock Bryan O'Donoghue
2018-02-01 14:53   ` Fabio Estevam
2018-01-31  2:00 ` [PATCH v3 5/5] ARM: dts: imx7s: add CAAM device node Bryan O'Donoghue
2018-02-01 11:44   ` Horia Geantă

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=1517364040-27607-3-git-send-email-pure.logic@nexus-software.ie \
    --to=pure.logic@nexus-software.ie \
    --cc=aymen.sghaier@nxp.com \
    --cc=davem@davemloft.net \
    --cc=fabio.estevam@nxp.com \
    --cc=horia.geanta@nxp.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukas.auer@aisec.fraunhofer.de \
    --cc=peng.fan@nxp.com \
    --cc=rui.silva@linaro.org \
    --cc=ryan.harkin@linaro.org \
    --cc=stable@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).