Received: by 10.223.176.46 with SMTP id f43csp846587wra; Wed, 24 Jan 2018 06:51:53 -0800 (PST) X-Google-Smtp-Source: AH8x224/pVkwjIAX66C5xYsoRqLuKYbNMOHx5wPWPmMuMgZive+rPpTH2SUIAK5sYpFor2Hu9J1q X-Received: by 2002:a17:902:42a5:: with SMTP id h34-v6mr8115081pld.265.1516805513162; Wed, 24 Jan 2018 06:51:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516805513; cv=none; d=google.com; s=arc-20160816; b=iSlEwOYmCe9eaRsZAGBvqbdubhf196qekif9aDBykcMJNB0IRGq3Zb3HnOO7qp/vLz fVycv/kTyEtRH1b+T/bxmhBN0LeYOz0cii87I/8zws8o9DDTijpHNT8twTrMyyFay231 7Zi3KFtaZ/+4WgoCEQU8nSZPlQcy+gI5pC1Xn9qIrgdXXYfFgF8nTzF9/7tOI8TBV2hU ShY2exYJEraioYJchewEiQBIDPXAXcE01MIb7pc5O+NwQU69iWZtUb1uAgCP4HMOVl2N NJrLNudQpRrEo59gqvvWzZD14ZZhLJq3GUxmqTvFxTNFfF40BGOLAjQhLWxZky38fUq2 +KVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=GOrsvsz2f1EeY7zQrBry8SttIygt+IkyddSksccoaJY=; b=Rj+oiiX4TufeaCB5BMHIHBJg/TIabzqecibKJk+MFxb4N4oc6tnc8osZICVNIAxCaI JKNqLxWrgFGlwSNY/jGmDM77aHoyhQKGsolMlPBbIqAdeb8qK28dWL7Cc5PhYfvH3wPD pfYupo5vnRO/JoXoTtOIjyTTx5iw9NIKTxzIvuFUEesTRzd54E6HBMmmXpLvTosVyidx KgoZo85ykZn+4w0TYknxYRaoAmNjmEXK013TRZ6iMHFxKwEbya61aXsWm3FAkIl2IfBs CgBQMYTr2irHjvEQtOsfYlaUdwtpHlscV/vNeDG8legs65AG7f3LCvnv1bFUPGs84Q4X H1iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nexus-software-ie.20150623.gappssmtp.com header.s=20150623 header.b=WQCaETfo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m184si3006175pfb.373.2018.01.24.06.51.39; Wed, 24 Jan 2018 06:51:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nexus-software-ie.20150623.gappssmtp.com header.s=20150623 header.b=WQCaETfo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934097AbeAXOuv (ORCPT + 99 others); Wed, 24 Jan 2018 09:50:51 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:42599 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934070AbeAXOup (ORCPT ); Wed, 24 Jan 2018 09:50:45 -0500 Received: by mail-wm0-f68.google.com with SMTP id r71so9038000wmd.1 for ; Wed, 24 Jan 2018 06:50:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexus-software-ie.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GOrsvsz2f1EeY7zQrBry8SttIygt+IkyddSksccoaJY=; b=WQCaETfom/6tqLoSv5c7SAlMvTKUnNoFJddKw5I4OMQw+S8JW7ZWuwQUzZi9kawBRq DuRxZVHRv4M+39MIdL+n0EqNbUAuFGzDzaTvhRqa2ktn4FvkaQ2Uu+Ahhc+nVvd0rzj7 /5BKbnL6aesj1WMK7QgB+c+XZtbG5Y3+9lVNjEQRZpdhlji+LLSfs7eWS88m2NYQcoUT FVppmxXjpqGMtrx2C2v23pw7iysU300ucCo3NB+8zH66oQSMqfo0Zj0o0QmC1GRGgPET c4SsYauzRv7gnAO/4D/a+RyDDcCDTJ5DxuGLgo6b2HAR7+Yte5Z+NTV46t09YRsajSTo JhJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GOrsvsz2f1EeY7zQrBry8SttIygt+IkyddSksccoaJY=; b=rN+E0M/15qRULlOmvMho0ZyRjhLMPkBdtO2cZT1ePkwpQI2gLHbiei8/xcy+VjWBvY MgOuHWySqg4u1/zgNiw7pRZsX/Lqe7ZkxJ+J94saNzvqZjr28kHYUWjSbrWRWHltLR7W PTFpJFL5FjSui8AFoCLV/mCzSmxzClEXMvhzSyIhw+F7Yy+Gm20Z1KrF0/+Z9gWUwuYq 4xDZJtlIRxw7z2Xc1yReQWv909feTRq7F60phuAPXZcP+rRztDNpWxGnOVWg6euQ6Wo4 +PDfB2J7Jf+DDOz1FIOUy0j3bXB0YNJ+m8cTlVYTSdXOeRB1oS57AHKWs5UZL906pBiq 2fWg== X-Gm-Message-State: AKwxytf9limZrG3VcwTMy616ZhvCfBtGOfnli2XXHE7Xov/2C4SzsZr5 PLEBi9DHkr/7ipvyjRHLpqZrwQ== X-Received: by 10.80.208.197 with SMTP id g5mr24919349edf.216.1516805444507; Wed, 24 Jan 2018 06:50:44 -0800 (PST) Received: from localhost.localdomain ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id p6sm324449edb.62.2018.01.24.06.50.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 24 Jan 2018 06:50:44 -0800 (PST) From: Bryan O'Donoghue 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, herbert@gondor.apana.org.au, davem@davemloft.net, lukas.auer@aisec.fraunhofer.de, rui.silva@linaro.org, ryan.harkin@linaro.org, Bryan O'Donoghue Subject: [RESEND PATCH 2/6] crypto: caam: Fix endless loop when RNG is already initialized Date: Wed, 24 Jan 2018 14:50:31 +0000 Message-Id: <1516805435-15034-3-git-send-email-pure.logic@nexus-software.ie> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516805435-15034-1-git-send-email-pure.logic@nexus-software.ie> References: <1516805435-15034-1-git-send-email-pure.logic@nexus-software.ie> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Bryan O'Donoghue Cc: "Horia Geantă" Cc: Aymen Sghaier Cc: Fabio Estevam Cc: Peng Fan Cc: Herbert Xu Cc: "David S. Miller" Cc: Lukas Auer --- 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