Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp6239183ybe; Tue, 17 Sep 2019 23:35:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwBjDaHoZKKPl/DgX2Vym1cMD75R6rE2k5Tg8KvF/X6u81jcChnykP9X1hElvZVNNNqGNJP X-Received: by 2002:a50:b501:: with SMTP id y1mr8476986edd.167.1568788554334; Tue, 17 Sep 2019 23:35:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568788554; cv=none; d=google.com; s=arc-20160816; b=OiO8O3ONnq7m6fS5aq7KUpViROYkPtFnqeTVkqd8OjAmz4EhM6sXiFt7NSwFspTzU/ T6Jb+U8X1O4MyEEuEh+2Y46uA+uSauOdVpVDvlpHHhrhkwFTQzOl7SLVeRDvvTfDfX+T v8Uy4pVivu9JKGYhjFd4oW8sNav71Wikwjc8+Vrwb94TT5tUH1551xQUyBci6hXLH0Qm GX+4RuVQh564Y6e4+Ufiiom1JdPI7QOFSLfVlIeyXUkxIIXSdk6BJVtjsSYAxmqYVzoh gvtBGCJGaY10cwrs5bq6d815YrnkRfFEi55zZOpb/aeHYJq7vP0ZkVtYlP2gBX8Q/b0b HkxA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CqoVOkYpqN/CmXNkGJQRZENC/3LyZ0667zq2GeddUsI=; b=WW8mKB5q5GMv0kFCpjsECKLapDcizCR+/WXQTbs/ZL3K6VR3pw1o7ApevRGnDPSF5m i+h+AIWTB4tdrpkfBAto6gUPk9DU4ZDPOrcpbKnul9Khy9bwSmntWv7Tizrc6RKKfeEW wPwRvuhq02agomhLeLJ/A2l3ahvwcmLRX0KzLhNTQeZ6B06ubdhW2mwnE2BD9tT85q2o FkRlmAQdDOkWGR/l7uWchIkvC2ZTD3JAztSa6iKYacJqmn5KlBp/4RQc1GskWiSIp76E ZtX24yaDSn1hggVKXtl+4RQ1jKF+giT0yLuHhWEoXWwWG56EGLR0zIqyn7O0auaPwgWj REuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KqbJ+Q5l; 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 b26si2352861ejb.291.2019.09.17.23.35.30; Tue, 17 Sep 2019 23:35:54 -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=@kernel.org header.s=default header.b=KqbJ+Q5l; 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 S1729584AbfIRGXX (ORCPT + 99 others); Wed, 18 Sep 2019 02:23:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:43414 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727542AbfIRGXM (ORCPT ); Wed, 18 Sep 2019 02:23:12 -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 94AA221920; Wed, 18 Sep 2019 06:23:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568787792; bh=Fq2fkoFSAcVTjHQtKzIz3yYAqH2AFm1WloMqH9Y8xp0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KqbJ+Q5lci8w58asNexeYfXjsNxKrJV5eJnFzvakqLamwAKjPM7isqm10t0dJYXGb wFS1pH9bjJHNOKBRdGwKBiUQk2nrCHLAAWgXxYOLMm0YcnvWO9gTkvgW3FT0E1ZdT0 3zRfeat4anC/zokaYV9rxtGlVHAwB6DAosgCbok8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe Leroy , Herbert Xu Subject: [PATCH 4.19 36/50] crypto: talitos - check data blocksize in ablkcipher. Date: Wed, 18 Sep 2019 08:19:19 +0200 Message-Id: <20190918061227.285930559@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190918061223.116178343@linuxfoundation.org> References: <20190918061223.116178343@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 @@ -1672,6 +1672,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); @@ -1689,6 +1697,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);