[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1516805435-15034-3-git-send-email-pure.logic@nexus-software.ie>
Date: Wed, 24 Jan 2018 14:50:31 +0000
From: Bryan O'Donoghue <pure.logic@...us-software.ie>
To: horia.geanta@....com, aymen.sghaier@....com,
linux-crypto@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: fabio.estevam@....com, peng.fan@....com,
herbert@...dor.apana.org.au, davem@...emloft.net,
lukas.auer@...ec.fraunhofer.de, rui.silva@...aro.org,
ryan.harkin@...aro.org,
Bryan O'Donoghue <pure.logic@...us-software.ie>
Subject: [RESEND PATCH 2/6] crypto: caam: Fix endless loop when RNG is already initialized
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.
*/
The problem is if u-boot has already instantiated the RNG and TEE/OPTEE is
running then instantiate_rng() will always return -EAGAIN and ent_delay
will never increment causing the loop to never break.
This patch fixes commit 1005bccd7a4a ("crypto: caam - enable instantiation
of all RNG4 state handles") by always incrementing ent_delay if and only if
both rng4_sh_init and inst_handles are non-zero for a given loop.
This should allow the current behavior to continue while allowing the loop
to break should (rng4_sh_init=1 && inst_handles 1) be true and
instantiate_rng() return -EAGAIN forever.
Fixes: 1005bccd7a4a ("crypto: caam - enable instantiation of all RNG4 state
handles")
Reported-by: Ryan Harkin <ryan.harkin@...aro.org>
Signed-off-by: Bryan O'Donoghue <pure.logic@...us-software.ie>
Cc: "Horia Geantă" <horia.geanta@....com>
Cc: Aymen Sghaier <aymen.sghaier@....com>
Cc: Fabio Estevam <fabio.estevam@....com>
Cc: Peng Fan <peng.fan@....com>
Cc: Herbert Xu <herbert@...dor.apana.org.au>
Cc: "David S. Miller" <davem@...emloft.net>
Cc: Lukas Auer <lukas.auer@...ec.fraunhofer.de>
---
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
Powered by blists - more mailing lists