From patchwork Tue Jan 15 13:43:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 155665 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4907083jaa; Tue, 15 Jan 2019 05:44:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN7GpMfCKLNuaQ2w52gPWJ+MWI6YU5URXTLEv1Sot4R6552mQa6gZy3bwYy2vwWXSf1zbUIF X-Received: by 2002:a63:3e05:: with SMTP id l5mr3745641pga.96.1547559842192; Tue, 15 Jan 2019 05:44:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547559842; cv=none; d=google.com; s=arc-20160816; b=wbgf/N/d0/IJ7VxZtgsRhhY+zb26XLFZgx/jFu1wm0FOxTirkqo3OSyjl6lPCrCAbc MsLxp+Sohhhz10Kh8ciDDWL8qlNefsRK5tVj24XTI3YeG621Et0iXCyxmbEmliv18mfH Kf8/WzAcE88zaaRxdyFO5021A2vnOS01Yg1YTSWlt+jTzl9NAvBLJ0ylvSQOIa4BSCtR b8gcW+m+rAP/TIh6taKXF7QaEB028VSoMVoUdWa9mKLejF579xmFat06zuxTWrtDGYu8 BX6cDaunIutj/zgKFVkFqpEh6rU1XimqmIJhmwj33q8kPL/jzLUjnEZ/msb8EW9aqXi4 fm3w== 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=YMkA2O+1SjXE7a0G/vCnA6dYImm8sYTUf2i8Pj/htP8=; b=EE+TrI70IYwHpxn//3O4Oz9HAEzDDGdh+8JLrdNqZ8/2wT53lSpfKlRx1nZqN3VGfr gCPAAy+lQNUoUd1gXEnae081X7386VD/CHc7YGLIX5RuEOogpRKN7QHcCfVb59H7ux2E PDqWihxlz0MHKwXy7LTDKGDqJNYKFKrL+Eaj5nKrukWWLocFTAVHrmMQNGyjFfLFU3O0 1rg1dQqb16dZJwIXtJKFHG30RBThsy7gibVvaclz1DfvxIOLSkmn/vv/QkEjol8VyRRZ WMlzBbgh9Nag80opxrfh8ejKFqle6/+Vp0oAFyQbwMFBXLTmoCuuzs9xbp4DaY8EIcT8 WmQg== 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 l17si2945844pfd.236.2019.01.15.05.44.01; Tue, 15 Jan 2019 05:44:02 -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; 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 S1729924AbfAONnu (ORCPT + 31 others); Tue, 15 Jan 2019 08:43:50 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:50760 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729901AbfAONnq (ORCPT ); Tue, 15 Jan 2019 08:43:46 -0500 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 4A3EFA78; Tue, 15 Jan 2019 05:43:46 -0800 (PST) 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 BEA853F70D; Tue, 15 Jan 2019 05:43:44 -0800 (PST) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" Cc: stable@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/7] crypto: ccree: unmap buffer before copying IV Date: Tue, 15 Jan 2019 15:43:15 +0200 Message-Id: <20190115134318.28712-6-gilad@benyossef.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190115134318.28712-1-gilad@benyossef.com> References: <20190115134318.28712-1-gilad@benyossef.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We were copying the last ciphertext block into the IV field for CBC before removing the DMA mapping of the output buffer with the result of the buffer sometime being out-of-sync cache wise and were getting intermittent cases of bad output IV. Fix it by moving the DMA buffer unmapping before the copy. Signed-off-by: Gilad Ben-Yossef Fixes: 00904aa0cd59 ("crypto: ccree - fix iv handling") Cc: --- drivers/crypto/ccree/cc_cipher.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c index cc92b031fad1..98ea53524250 100644 --- a/drivers/crypto/ccree/cc_cipher.c +++ b/drivers/crypto/ccree/cc_cipher.c @@ -652,6 +652,8 @@ static void cc_cipher_complete(struct device *dev, void *cc_req, int err) unsigned int ivsize = crypto_skcipher_ivsize(sk_tfm); unsigned int len; + cc_unmap_cipher_request(dev, req_ctx, ivsize, src, dst); + switch (ctx_p->cipher_mode) { case DRV_CIPHER_CBC: /* @@ -681,7 +683,6 @@ static void cc_cipher_complete(struct device *dev, void *cc_req, int err) break; } - cc_unmap_cipher_request(dev, req_ctx, ivsize, src, dst); kzfree(req_ctx->iv); skcipher_request_complete(req, err);