From patchwork Tue Jan 15 13:43:17 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: 155663 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4906946jaa; Tue, 15 Jan 2019 05:43:53 -0800 (PST) X-Google-Smtp-Source: ALg8bN7iLiVJqE77cdBDV3iM4fkCzB1/f3VsdnPLmrYTfvDie/8HPUEySn+V4Ci7onA9gvRRLOov X-Received: by 2002:a63:1f4e:: with SMTP id q14mr3816521pgm.88.1547559833023; Tue, 15 Jan 2019 05:43:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547559833; cv=none; d=google.com; s=arc-20160816; b=c7L78lME0KLUFfUic8qgQ68oQvvjmDwpIs2ZIv0dBvxl3vhfGJcvoP8vWzvN+3Ovfb uSC8QJCaZdNLYoEvowXCszkz0vqFNN2FoFtpMZCQ+Gc1t3Ouvfy6K0hGkYzKcmrJWRwC B1SHvIFFHNxLYAXcRzNFOmBg1BI3NmxKe6Vm+7X4ADxTfTLtv1iFrjWFYOxH9Omh0BJk emnfEFwnYe+JMmfsW74hwXoZ+byuCFQ/oz9ApQHe/BxUFbtArd67wptdFURQzVNZ+NoY D1Vpwsbx4Bkac7yVEcxIre++MedFft+tlxm5+QAB1uCql33/sF0mPuc2KuHN7PrxJe+v Sz1g== 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=DkkOFLCRY1Rs0mC8ft4dBl/ezNUqYq/LhcW9/oOEYh4=; b=ZRnJ1QIyIGdpEF5rdsO8tecrn+r2udpw5qGJy82YPHk6V1O+cT1xZe/WRXf7RL9m4C Yzi5/G9uIx3O+YxvUeY9LaE5QtE6N2Ijw9p2VaGlPrmq0VPd/3tRbX+fs/HBVFUGSIVc qiA/iyaDgRYpA1WY+cP229pRCKwTNfrKZxPzKKcjtuTdiGfVZLXpL1Xfs60zN9fpU7Lb q8cvoayex7mscCS1MQn2x/jDY8BXr35ZQbAXlp/uRhzhMdeQUUqEek3gGBHwDeJ/+MTV cUjIw5wfCPP0oKjVge9F+cCp+bDxsxOPZukzZDKXH9fmvh9l+jMxzeigy29OEuhNzE54 4+7A== 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 x1si3284248pfn.111.2019.01.15.05.43.52; Tue, 15 Jan 2019 05:43:53 -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 S1729932AbfAONnv (ORCPT + 3 others); Tue, 15 Jan 2019 08:43:51 -0500 Received: from foss.arm.com ([217.140.101.70]:50774 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729925AbfAONnv (ORCPT ); Tue, 15 Jan 2019 08:43:51 -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 14C87A78; Tue, 15 Jan 2019 05:43:51 -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 893773F70D; Tue, 15 Jan 2019 05:43:49 -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 7/7] crypto: ccree: don't copy zero size ciphertext Date: Tue, 15 Jan 2019 15:43:17 +0200 Message-Id: <20190115134318.28712-8-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-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org For decryption in CBC mode we need to save the last ciphertext block for use as the next IV. However, we were trying to do this also with zero sized ciphertext resulting in a panic. Fix this by only doing the copy if the ciphertext length is at least of IV size. Signed-off-by: Gilad Ben-Yossef Cc: stable@vger.kernel.org --- 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 98ea53524250..e202d7c7ea00 100644 --- a/drivers/crypto/ccree/cc_cipher.c +++ b/drivers/crypto/ccree/cc_cipher.c @@ -800,7 +800,8 @@ static int cc_cipher_decrypt(struct skcipher_request *req) memset(req_ctx, 0, sizeof(*req_ctx)); - if (ctx_p->cipher_mode == DRV_CIPHER_CBC) { + if ((ctx_p->cipher_mode == DRV_CIPHER_CBC) && + (req->cryptlen >= ivsize)) { /* Allocate and save the last IV sized bytes of the source, * which will be lost in case of in-place decryption.