Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp615418ybl; Wed, 29 Jan 2020 06:38:50 -0800 (PST) X-Google-Smtp-Source: APXvYqxooB1o1ATvyhhNaNPbwVAVBw3nEnbNUmTtmRQqmUoepWTPZta3KI2nVCL1Epr/v1AKgy0g X-Received: by 2002:a05:6830:2015:: with SMTP id e21mr17162099otp.106.1580308730768; Wed, 29 Jan 2020 06:38:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580308730; cv=none; d=google.com; s=arc-20160816; b=q8P506GfPtq4h1DvQ2QclXSYlfGyWHJOgaCW4TzKbnXW0mYtGq/zK5bck3NDVWb1AV OzwXQQlTmHhhz87PXfGkCMpKrTEIrPVknYtVkp1X6TwiODsHX6C1kw9z/K/GxLiqd9gd lKpkmuiSKRXaRcsSZOwoslgIomXR7VmthEJM9eRxo2yXDjC2YLhtsjo8mZScQS3V65zr Xh0GBUhyrS2mnm8qpsbYRPBsXs5ph/Bw5ESOVZkKr7AbeIK+4rmdHozQZsnyyU+bO5v+ afLCPV4JKpPmSZvo7mccAWcE+wha4zv6213h/Nv3YRVzn8pALbjng4vA4BbV3M4Zi2rx U1hw== 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=gpkGZQMn1/nXKUiZn/c3Yw+7Baj9+tbkRm4H1XT4BSs=; b=DGupezMHLaCRuZ03qreg3X/TnbXgWPQ+Z265hoXrid11kqteVzrszOvNRd/Yx3DP8p bUCEqbsRDV80Rr7p8FBp7YW6J/xOPBKEVGTKNhEC2XgiVpi3VrtYhCMZvWi4ndrOjMxH wlsiyPGxJFed3Rygtkp0ivFYXw66yARrj422Pujsd7nDBoIfcyGayBG2pR28409feeyy UYmRs7soGgVcAxS1SzhEh6rmmD58C2+ckoqHpevUdSeChMVavRISeN+InQEOvsPb+Rkb MxaD6IP2oBMEp33W9gYlVgWDk4secNhON6HZ2iKBCkZvfYrWYbICML8lm7USrwosQNtJ Cpaw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-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 w11si1187092oic.62.2020.01.29.06.38.39; Wed, 29 Jan 2020 06:38:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-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-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726715AbgA2OiL (ORCPT + 99 others); Wed, 29 Jan 2020 09:38:11 -0500 Received: from foss.arm.com ([217.140.110.172]:41970 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726261AbgA2OiK (ORCPT ); Wed, 29 Jan 2020 09:38:10 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 81E9E31B; Wed, 29 Jan 2020 06:38:10 -0800 (PST) Received: from e110176-lin.kfn.arm.com (unknown [10.50.4.146]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DDA743F52E; Wed, 29 Jan 2020 06:38:08 -0800 (PST) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" Cc: Ofir Drang , Geert Uytterhoeven , stable@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] crypto: ccree - only try to map auth tag if needed Date: Wed, 29 Jan 2020 16:37:55 +0200 Message-Id: <20200129143757.680-3-gilad@benyossef.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200129143757.680-1-gilad@benyossef.com> References: <20200129143757.680-1-gilad@benyossef.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Make sure to only add the size of the auth tag to the source mapping for encryption if it is an in-place operation. Failing to do this previously caused us to try and map auth size len bytes from a NULL mapping and crashing if both the cryptlen and assoclen are zero. Reported-by: Geert Uytterhoeven Tested-by: Geert Uytterhoeven Signed-off-by: Gilad Ben-Yossef Cc: stable@vger.kernel.org # v4.19+ --- drivers/crypto/ccree/cc_buffer_mgr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/ccree/cc_buffer_mgr.c b/drivers/crypto/ccree/cc_buffer_mgr.c index b938ceae7ae7..885347b5b372 100644 --- a/drivers/crypto/ccree/cc_buffer_mgr.c +++ b/drivers/crypto/ccree/cc_buffer_mgr.c @@ -1109,9 +1109,11 @@ int cc_map_aead_request(struct cc_drvdata *drvdata, struct aead_request *req) } size_to_map = req->cryptlen + areq_ctx->assoclen; - if (areq_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_ENCRYPT) + /* If we do in-place encryption, we also need the auth tag */ + if ((areq_ctx->gen_ctx.op_type == DRV_CRYPTO_DIRECTION_ENCRYPT) && + (req->src == req->dst)) { size_to_map += authsize; - + } if (is_gcm4543) size_to_map += crypto_aead_ivsize(tfm); rc = cc_map_sg(dev, req->src, size_to_map, DMA_BIDIRECTIONAL, -- 2.25.0