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.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 1E6AFC4CEC9 for ; Wed, 18 Sep 2019 06:26:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E51FC218AF for ; Wed, 18 Sep 2019 06:26:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568788011; bh=BBrli+y3f8EF3fr4Z8ZFQrePScdKL2Ig7+3G/ewg78g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ZIz+COlk4D1T0QvFrvFZ0p34cGFTbUM/vPpNZMv42Yi2wjdWGpDX1HVN2lihuScfm h9DVbSvA4nuSuqkX3SFJOUCD6D8XLxoWzElkL2N0+rMmlamDU+xzafK+Q3iVVZhOxp 5cOONirLj/qRHhxdrS8qykjGoTJ4KkPyJYO/04KU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730393AbfIRG0u (ORCPT ); Wed, 18 Sep 2019 02:26:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:48354 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729091AbfIRG0r (ORCPT ); Wed, 18 Sep 2019 02:26:47 -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 E780D21929; Wed, 18 Sep 2019 06:26:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568788006; bh=BBrli+y3f8EF3fr4Z8ZFQrePScdKL2Ig7+3G/ewg78g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fe9yNGgNR/Qe330sJE0qODVNYi4kkughjAwjPpUael6JYI5blxmp+skowjvIDiL4a qGEdD1CAz52Rt2M+FGJ6xjrLRcl0SX4uD5ORbclDZ6ViGCzuq5PXyDbxc9CqPDHWE3 Qbeyaj0F2OHmwA607YHoUJE5GsWtnS+BEpQdf/KA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe Leroy , Herbert Xu Subject: [PATCH 5.2 65/85] crypto: talitos - check data blocksize in ablkcipher. Date: Wed, 18 Sep 2019 08:19:23 +0200 Message-Id: <20190918061237.473569019@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190918061234.107708857@linuxfoundation.org> References: <20190918061234.107708857@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Christophe Leroy commit ee483d32ee1a1a7f7d7e918fbc350c790a5af64a upstream. When data size is not a multiple of the alg's block size, the SEC generates an error interrupt and dumps the registers. And for NULL size, the SEC does just nothing and the interrupt is awaited forever. This patch ensures the data size is correct before submitting the request to the SEC engine. Signed-off-by: Christophe Leroy Fixes: 4de9d0b547b9 ("crypto: talitos - Add ablkcipher algorithms") Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/talitos.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -1725,6 +1725,14 @@ static int ablkcipher_encrypt(struct abl struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq); struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher); struct talitos_edesc *edesc; + unsigned int blocksize = + crypto_tfm_alg_blocksize(crypto_ablkcipher_tfm(cipher)); + + if (!areq->nbytes) + return 0; + + if (areq->nbytes % blocksize) + return -EINVAL; /* allocate extended descriptor */ edesc = ablkcipher_edesc_alloc(areq, true); @@ -1742,6 +1750,14 @@ static int ablkcipher_decrypt(struct abl struct crypto_ablkcipher *cipher = crypto_ablkcipher_reqtfm(areq); struct talitos_ctx *ctx = crypto_ablkcipher_ctx(cipher); struct talitos_edesc *edesc; + unsigned int blocksize = + crypto_tfm_alg_blocksize(crypto_ablkcipher_tfm(cipher)); + + if (!areq->nbytes) + return 0; + + if (areq->nbytes % blocksize) + return -EINVAL; /* allocate extended descriptor */ edesc = ablkcipher_edesc_alloc(areq, false);