Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp606697yba; Thu, 18 Apr 2019 06:45:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqzkEri3FMRAjZx614KtBWiks0vDprBI916AeuXiqOw/waMVLZDhpMs+6ed9zZjsEVqI5M36 X-Received: by 2002:a62:ac08:: with SMTP id v8mr95323296pfe.42.1555595100833; Thu, 18 Apr 2019 06:45:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555595100; cv=none; d=google.com; s=arc-20160816; b=c6w2TYooXFLwJ791VWhVZ9sndWMkxU0+jyAS5KktuOSdgakV9RcUITblHHbPbNdec+ xLmotkgBATLMNXBlor6uWOp+bi9VaS1cSA0aMsg2u8HdS0TCEENkBc/+RI+525hBg9UL 9UfOZ0RNnWaBf6dHO90hct3TpQr/iVqICKwDe5b1+zLM2jvhBTSnLXkGycQzhjhDtPrt EsJ6BD73cmR7cC9Zfd77JuVObuQH3YUAPmjbP+3QJUSOXAdqhL0WHSlpo8XdyiMdg5Wy dTf9QqkNiEObxldZflTvFt3XyCa8attMiYY3sPsFKs94OImRo4qD/2freGr3hs2r0Km5 noYA== 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; bh=hpd2kj9BRB4B1TNKDwRQ8KOwQ758CfUlG58kAOsgBDY=; b=Svo7KPprGW4R6LdN03Tz2Ka9v1Muh+Vw0J5nxSMD1h06L5nBpqSR66jfoGjOMYL1NI zEMnRV7d8DFnPXfqXkhAb3Zy9RK508brAOT6ZgphWjcgvkBCr0KPm+bwhwx0La5NzbCy uAe8kthmu7plyYPRdgF3ShjXzsBUIUKATg6iqDkg+GAkNFxxD2zCJRuFjyzWYuXy+/VN 8IrroPEWzscUKtHX9EO+xOevSAAZUCy6TL2QSuCJ5eL3hCNrU3alUBAl9iSvgPBIyriC X3rwItJ0J8bBpKXOeNkw9YPq7iQmmsp3NOM/gobj27+XqVTeG/DXJicA6h8M0dzWtYZe 0n+w== ARC-Authentication-Results: i=1; mx.google.com; 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 194si2508017pfu.48.2019.04.18.06.44.45; Thu, 18 Apr 2019 06:45:00 -0700 (PDT) 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; 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 S2389452AbfDRNlw (ORCPT + 99 others); Thu, 18 Apr 2019 09:41:52 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:33718 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388375AbfDRNlt (ORCPT ); Thu, 18 Apr 2019 09:41:49 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 15CD880D; Thu, 18 Apr 2019 06:41:49 -0700 (PDT) Received: from e110176-lin.kfn.arm.com (e110176-lin.kfn.arm.com [10.50.4.178]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6D42C3F5AF; Thu, 18 Apr 2019 06:41:47 -0700 (PDT) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" Cc: Ofir Drang , stable@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 26/35] crypto: ccree: zap entire sg on aead request unmap Date: Thu, 18 Apr 2019 16:39:01 +0300 Message-Id: <20190418133913.9122-27-gilad@benyossef.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190418133913.9122-1-gilad@benyossef.com> References: <20190418133913.9122-1-gilad@benyossef.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We were trying to be clever zapping out of the cache only the required length out of scatter list on AEAD request completion and getting it wrong. As Knuth said: "when in douby, use brute force". Zap the whole length of the scatter list. Signed-off-by: Gilad Ben-Yossef Cc: stable@vger.kernel.org # v4.19+ --- drivers/crypto/ccree/cc_buffer_mgr.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/crypto/ccree/cc_buffer_mgr.c b/drivers/crypto/ccree/cc_buffer_mgr.c index fa625bdde3f9..09dceec7d828 100644 --- a/drivers/crypto/ccree/cc_buffer_mgr.c +++ b/drivers/crypto/ccree/cc_buffer_mgr.c @@ -517,9 +517,7 @@ void cc_unmap_aead_request(struct device *dev, struct aead_request *req) { struct aead_req_ctx *areq_ctx = aead_request_ctx(req); unsigned int hw_iv_size = areq_ctx->hw_iv_size; - struct crypto_aead *tfm = crypto_aead_reqtfm(req); struct cc_drvdata *drvdata = dev_get_drvdata(dev); - u32 size_to_unmap = 0; if (areq_ctx->mac_buf_dma_addr) { dma_unmap_single(dev, areq_ctx->mac_buf_dma_addr, @@ -576,19 +574,12 @@ void cc_unmap_aead_request(struct device *dev, struct aead_request *req) dev_dbg(dev, "Unmapping src sgl: req->src=%pK areq_ctx->src.nents=%u areq_ctx->assoc.nents=%u assoclen:%u cryptlen=%u\n", sg_virt(req->src), areq_ctx->src.nents, areq_ctx->assoc.nents, areq_ctx->assoclen, req->cryptlen); - size_to_unmap = areq_ctx->assoclen + req->cryptlen; - if (areq_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_ENCRYPT) - size_to_unmap += areq_ctx->req_authsize; - if (areq_ctx->is_gcm4543) - size_to_unmap += crypto_aead_ivsize(tfm); - dma_unmap_sg(dev, req->src, sg_nents_for_len(req->src, size_to_unmap), - DMA_BIDIRECTIONAL); + dma_unmap_sg(dev, req->src, sg_nents(req->src), DMA_BIDIRECTIONAL); if (req->src != req->dst) { dev_dbg(dev, "Unmapping dst sgl: req->dst=%pK\n", sg_virt(req->dst)); - dma_unmap_sg(dev, req->dst, - sg_nents_for_len(req->dst, size_to_unmap), + dma_unmap_sg(dev, req->dst, sg_nents(req->dst), DMA_BIDIRECTIONAL); } if (drvdata->coherent && -- 2.21.0