From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 989DBC4360F for ; Fri, 22 Mar 2019 12:35:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5EA562070D for ; Fri, 22 Mar 2019 12:35:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553258142; bh=jIImtb19x6wdiJJzDnn77niy0v4N6aOnTJ29y0YOIWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=A2l5ATcQGGAjpG2Ma8lgeCMAAjWpnEzwhtU4J9jd9tioBvxecX8d++4H7zAIPvBa7 CDsB+jpIDyo6ckTSm2oRKn3xkgTdqmU40857nQdlYydc8Ia3kEv6UIxxRpbKIAj6qM 2lrqBV03SgtvDfl2Rp1vOr69N0fAgmr33S7QbGgc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389192AbfCVMMF (ORCPT ); Fri, 22 Mar 2019 08:12:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:50270 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388968AbfCVMMD (ORCPT ); Fri, 22 Mar 2019 08:12:03 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AE74220830; Fri, 22 Mar 2019 12:12:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553256723; bh=jIImtb19x6wdiJJzDnn77niy0v4N6aOnTJ29y0YOIWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qh3QGcoCG6Q3HpIImrhxeOHVKkIB2HNkzcU2wOA8Rfd70L+/Lqh46WTMmr9gCLlQu diiDlyKS5XLl6b+ZVC8eXPzOIoyiBvk79jBc9t+fAUoMc5Ex7xeIy6u+w92FR3l9O/ ob8Sdiy6xH2aoMM0hOpGxEtbfhz1p3w8phuq581Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gilad Ben-Yossef , Herbert Xu Subject: [PATCH 5.0 018/238] crypto: ccree - dont copy zero size ciphertext Date: Fri, 22 Mar 2019 12:13:57 +0100 Message-Id: <20190322111259.245385243@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111258.383569278@linuxfoundation.org> References: <20190322111258.383569278@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org 5.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Gilad Ben-Yossef commit 2b5ac17463dcb2411fed506edcf259a89bb538ba upstream. 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 Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/ccree/cc_cipher.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/crypto/ccree/cc_cipher.c +++ b/drivers/crypto/ccree/cc_cipher.c @@ -801,7 +801,8 @@ static int cc_cipher_decrypt(struct skci 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.