Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4963788imu; Tue, 15 Jan 2019 08:52:21 -0800 (PST) X-Google-Smtp-Source: ALg8bN5/T82d6GxLcGBRGZI6p2gIMRLaA31eRbU1HtN9h/2rqAvOAblvmKMARWa9gfqZi8niJK0+ X-Received: by 2002:a63:61c1:: with SMTP id v184mr3802852pgb.54.1547571141842; Tue, 15 Jan 2019 08:52:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547571141; cv=none; d=google.com; s=arc-20160816; b=NBNUaBuC44YfHmb9ofOB7tg1BAsHy6LvGPlXnX9Jjxm4jI2EwpqeiEPJ/JP9eOEgte 7VsAZhQ5YGTbkBO5YmErmuGJ3XZunEkNZMnBkZeDwjwrunI+34RHi78IwN7cblqJuSuH XU7ffqXMEcN4aLnNWsEJ74XGiFPgFfnAG0mL7pjG0BOm2/jdM/a1zhLiU9aoiOtZdCQv rUWdFPC8PY+WARZNpXgMMIEOe7mFuX1jVrOV1WyU60Jkf2mu7WQSth1Q/R53QWCC9J2T BLajb5klZf6KoLompb6ZgEtpLEww8R5jSg5RpL5AIfStT/do0s7S5rb3MEuusl/tQ7Uu nOjA== 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=L6MpkQiKiM++VueBdzxbeHaWCKuffTzDKfp8n1ywC4Ceuc2GR1fe5WlMjIJhdCK3c6 82/8sEcNKJ8ebXHXZX2RyZPVhh9E8Br+gk4BCsiNIk+5kNpqLl3tV3VzGxozOJpqzTwj ICWZXb2eH2HYZOcHNfgyJKO+Se/sgNf8pgeLBXDKGnWvG1v6odtuJlff5sM5XtMxaxfG ImklKBUuAgk3Hc65hYYHM3E2XxGeeFjwLJ3GTBeUvVVDY9pPUlpsJGSGfq54CsQylvk4 BuEtZBs0wZSdqPW9dQo3QxNwT6fQj4Lxk6GKkTCyqLl0O+c8wAlYXn7s7zC70JwvgHG2 LeSA== 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 q2si3766474plh.261.2019.01.15.08.52.03; Tue, 15 Jan 2019 08:52:21 -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 S1729957AbfAONnx (ORCPT + 99 others); Tue, 15 Jan 2019 08:43:53 -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 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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(-) 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. -- 2.20.1