Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4789269imu; Tue, 15 Jan 2019 06:06:35 -0800 (PST) X-Google-Smtp-Source: ALg8bN6UvwQsNzlY3O52M1V0vaMAjozQiruhThhLgMknfLdQ6+Hz2qOQfsW5aswx7OUfvK4I4irx X-Received: by 2002:a63:b24a:: with SMTP id t10mr3861173pgo.223.1547561194882; Tue, 15 Jan 2019 06:06:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547561194; cv=none; d=google.com; s=arc-20160816; b=PA6PJfSawdo94HBrczdKVc+IjhR2y1icyeFeXRa1mMx6KRo0Ly+4LaFqRNHSo6suxU vaRWHxbd9bPSLiGY75KxKYyjh2RKhiIinUcYrk/J5TTb1ft2zCHMmO35BDXmE6pQPRNL 08j/+NF9wF7GjGgwE5ECjSNgazT8i05I/hBoQ6aPiyvTEJWS2GQ71WiZtVqe0Xv3XxWm rfafSAmSB7qs/xSEyWDQbb6hNF9dUHRS77skd26cjR9xChG/2cqHqQXZLbGC+dxgiyl8 yQseWn0plugAi5exjMoR50Ak27G2QTFxsvDQW5YqUl/bXXgNJgDVkxiKsqw/6k182QPr ZgKw== 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 s71si3477730pfk.105.2019.01.15.06.06.13; Tue, 15 Jan 2019 06:06:34 -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 S1729920AbfAONnu (ORCPT + 99 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 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 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(-) 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); -- 2.20.1