Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2504360ybt; Sun, 21 Jun 2020 23:16:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3InYaQkRcYeFHJqK4AlVp5Zc5gfMUHG1inEhEyq3i4pPg2DMqmtguAPFdqEtVhe/X/pLS X-Received: by 2002:a17:906:1496:: with SMTP id x22mr13774862ejc.161.1592806573002; Sun, 21 Jun 2020 23:16:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592806572; cv=none; d=google.com; s=arc-20160816; b=w4y55VShRm9MZlLTVJlxi3IUnaeeAPPWPAB9MHp7FwAumP9Ox+NhURCD0VbTx1J2ET U6NtxDQ3f9D4W3bSCno+ObMtNJLuxR0676uwJbEFjQoPVxRfXDMF4OUIQUAhpwoRGZOZ WQ5Stk/xGlVR38/gCKLGYSFCOl2Fhom+HTVN5M4xQfW5Loz/bAh80iwG/oDh28aFJPkN 48R0ytgOed90oXMY6qG9Bd6izvtYbpFJk8U1oYMghjgU7rqGVlWZX3R2cuChI8RdoIpr v0H1OuNL1vhDiwF9GKCh8VJYd8e3nJDIiiAjo/Mbe7JB8lBOQD4mAXb7q2U6CsFKo2Gq pgZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:to:from; bh=GrGtfpGdpa7XIvnuE9Xg3Wow913qc+L7xXg37OjrAwU=; b=iOHw0rtIDH0bFUqRh2/eku4fRY8nL8k349oyO+h/1ssShQAtd4uIKmaElNgf32mpYT GTzR4Bc1HTarBaaD5Z7fkrGgV+5jp1pzoIjKa+Ao9DfxPr/EvtmyDVEXDP+DIrNH0Lyj wpTLvV8w+epdw3UoRZrSGjMU5lgSFJcHi8c2vwPRrELmN4SeMjQA2UGCzuu04SNLCpGY 8GWR/gl4uN67N9LgrSIiGVMhd14WW5hpIvSt2s2XKgkNQd/zRtgTXZbuNQNZ2JX7HkoD cMCccwIs14jz1tsTSoHVf+dt24yIHiabzoqOK5rWrkfYL4EcAEazUNhk/dO8gOUoKrBn k4DA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n1si7829565edq.483.2020.06.21.23.15.50; Sun, 21 Jun 2020 23:16:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731211AbgFVGPU (ORCPT + 99 others); Mon, 22 Jun 2020 02:15:20 -0400 Received: from alexa-out-sd-01.qualcomm.com ([199.106.114.38]:62533 "EHLO alexa-out-sd-01.qualcomm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731231AbgFVGPS (ORCPT ); Mon, 22 Jun 2020 02:15:18 -0400 Received: from unknown (HELO ironmsg-SD-alpha.qualcomm.com) ([10.53.140.30]) by alexa-out-sd-01.qualcomm.com with ESMTP; 21 Jun 2020 23:15:16 -0700 Received: from sivaprak-linux.qualcomm.com ([10.201.3.202]) by ironmsg-SD-alpha.qualcomm.com with ESMTP; 21 Jun 2020 23:15:13 -0700 Received: by sivaprak-linux.qualcomm.com (Postfix, from userid 459349) id E301E218BE; Mon, 22 Jun 2020 11:45:11 +0530 (IST) From: Sivaprakash Murugesan To: herbert@gondor.apana.org.au, davem@davemloft.net, stanimir.varbanov@linaro.org, ardb@kernel.org, sivaprak@codeaurora.org, cotequeiroz@gmail.com, ebiggers@google.com, horia.geanta@nxp.com, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] crypto: qce: re-initialize context on import Date: Mon, 22 Jun 2020 11:45:05 +0530 Message-Id: <1592806506-23978-3-git-send-email-sivaprak@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1592806506-23978-1-git-send-email-sivaprak@codeaurora.org> References: <1592806506-23978-1-git-send-email-sivaprak@codeaurora.org> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org crypto testmgr deliberately corrupts the request context while passing vectors to the import. This is to make sure that drivers do not rely on request but they take all the necessary input from io vec passed to it. qce casts the request context from request parameter, since it is corrupted the sub squent hash request fails and qce hangs. To avoid this re-initialize request context on import. The qce import API alreasy takes care of taking the input vectors from passed io vec. Signed-off-by: Sivaprakash Murugesan --- drivers/crypto/qce/sha.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/qce/sha.c b/drivers/crypto/qce/sha.c index ed82520203f9..9e54a667d72f 100644 --- a/drivers/crypto/qce/sha.c +++ b/drivers/crypto/qce/sha.c @@ -203,10 +203,18 @@ static int qce_import_common(struct ahash_request *req, u64 in_count, static int qce_ahash_import(struct ahash_request *req, const void *in) { - struct qce_sha_reqctx *rctx = ahash_request_ctx(req); - unsigned long flags = rctx->flags; - bool hmac = IS_SHA_HMAC(flags); - int ret = -EINVAL; + struct qce_sha_reqctx *rctx; + unsigned long flags; + bool hmac; + int ret; + + ret = qce_ahash_init(req); + if (ret) + return ret; + + rctx = ahash_request_ctx(req); + flags = rctx->flags; + hmac = IS_SHA_HMAC(flags); if (IS_SHA1(flags) || IS_SHA1_HMAC(flags)) { const struct sha1_state *state = in; -- 2.7.4