Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp961834ybm; Tue, 21 May 2019 06:36:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqxRdWUbHopLOosTzdX+8LU086sswZ5jYj0QZUe2+WScJ3CMVZUcYC0yJiFaJvkSy1gIHb+g X-Received: by 2002:a63:6f0b:: with SMTP id k11mr81466771pgc.342.1558445789809; Tue, 21 May 2019 06:36:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558445789; cv=none; d=google.com; s=arc-20160816; b=P8KfFgPzLJtcGjaQgcCDyjodblkWwA5o87MnTVE0nwfrVFJnRaCvx4oe2qnLm0Q660 c4CURwrnq5diuaOi2zw/i3j0g3ELxPDS6omg/isYqBHvIXy9SFTT+g1HZ3EUtPHhWyGh ngtOQRTzK/3jxTX2FzqJGdRfxvB+EAtOOHJuOF6bkQpwPfCdRIEi+xgPtLMRx15SVCry VtzrnatbC321hDfEXKC8Ekk/VL0GUowEWmY5lOEWwG7PsIfsREhDw6AktviE5BREdaKo ENuut7VVb0Mz0KgXWOV8uvKhkH+e3dHBdhAHUhqnoeMqY9X3AOp1kcNG48DLJiWJDp3N Xg1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id:dkim-signature; bh=zYNSnTdBI2zlv+nNU1YJCYKZt0d8+sVXOHJ4QyhBzhk=; b=lOM4/oabo87FtWe3jEU4FBMQ7TsxDex9SWsFs9XnKcKhFSakdz8VG5eWOYw2xefgy7 570z910nyzj4HR6C+xXEyloR9q/bQ0fer1NeaJ/PY8fLAHHK6rqMzmsSmanzBazzhcIv zZemyIfIwiF7R0sCYxS0tYZCtc/5lSWyBlUiRd1dyptht17fj0VWvwib4UkHfRwQAHtl kBaXOQ9Z7lFoIDwgchY3inkznwhUD/cua6m3udQiGR9CxVg2q0WfNSNOO+RjOceJVgv8 KXCvfHXUntlsZS+TC2o2YXAABiWL/o73d/XurJG0Q/KPGa7s/1ZnysejBjr2FDtx9CZB cPoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@c-s.fr header.s=mail header.b=wDmkV30Z; 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 z7si16214535pgp.208.2019.05.21.06.36.14; Tue, 21 May 2019 06:36:29 -0700 (PDT) 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; dkim=pass header.i=@c-s.fr header.s=mail header.b=wDmkV30Z; 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 S1728517AbfEUNeX (ORCPT + 99 others); Tue, 21 May 2019 09:34:23 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:12175 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728476AbfEUNeT (ORCPT ); Tue, 21 May 2019 09:34:19 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 457cDm01ylz9v2Xb; Tue, 21 May 2019 15:34:16 +0200 (CEST) Authentication-Results: localhost; dkim=pass reason="1024-bit key; insecure key" header.d=c-s.fr header.i=@c-s.fr header.b=wDmkV30Z; dkim-adsp=pass; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id K3dGGqH2eHck; Tue, 21 May 2019 15:34:15 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 457cDl65YDz9v2XY; Tue, 21 May 2019 15:34:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=c-s.fr; s=mail; t=1558445655; bh=zYNSnTdBI2zlv+nNU1YJCYKZt0d8+sVXOHJ4QyhBzhk=; h=In-Reply-To:References:From:Subject:To:Cc:Date:From; b=wDmkV30Z25a7KCNIbqmuyroCCzdpnZqFNkvTW/i3AeXvb+NsDzUq8rXvfPNtj9jzE 6Rk9nqBL9MU2u3aKtT6fTX2ydZApXMH5EjAh5DWifgCnqnGnUHFuI/Eos07/ktc1ct noZH3G9x2fjWRzJjbM2ddga97ma8EuYAxSmtrtGs= Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 47A368B80E; Tue, 21 May 2019 15:34:17 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id X8v_1FalQceD; Tue, 21 May 2019 15:34:17 +0200 (CEST) Received: from po16846vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 210998B803; Tue, 21 May 2019 15:34:17 +0200 (CEST) Received: by po16846vm.idsi0.si.c-s.fr (Postfix, from userid 0) id DF3A868458; Tue, 21 May 2019 13:34:12 +0000 (UTC) Message-Id: In-Reply-To: References: From: Christophe Leroy Subject: [PATCH v1 06/15] crypto: talitos - check data blocksize in ablkcipher. To: Herbert Xu , "David S. Miller" , horia.geanta@nxp.com Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Tue, 21 May 2019 13:34:12 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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") --- drivers/crypto/talitos.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index 8b9a529f1b66..1e5410f92166 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c @@ -1756,6 +1756,14 @@ static int ablkcipher_encrypt(struct ablkcipher_request *areq) 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); @@ -1773,6 +1781,14 @@ static int ablkcipher_decrypt(struct ablkcipher_request *areq) 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); -- 2.13.3