Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp1343373ybj; Fri, 20 Sep 2019 08:59:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqwlGnBBWkfI/gHovAA5eKlS5P4/k20jNYJtajSLlXYLqkJpLXFvOAu9fw4lMIXKppBQF4II X-Received: by 2002:a05:6402:120e:: with SMTP id c14mr22596717edw.272.1568995150615; Fri, 20 Sep 2019 08:59:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568995150; cv=none; d=google.com; s=arc-20160816; b=CknGdd37PZhHTNG7j2fHDB1Xbe80COm632uH+viLx5rqyosALll/nbyM4/ATYL5YbL QxgMiC/3eWSPkazkNVMOFVR5EC2uWgS2owZJ/Asdi796YgLrre9AjVp6oF5xxHoPfp6K bkdE65LaqBo3xUV7HcfB9hm/IrKShp9Ndtbfjw/kSIa9FqLLL4dogG6xfT+aUBcGmt4Z MZt9lPfLCZslbFdTf9Oh/xLLL8MZpwemHO9qMuRLsy7Q3NUba10FrFf24r7uzHvxZhQg gPyB43e0vLDeygqvD8VbN2RlI3P75HoV+wjDrCWLYEABJVn63YsBRgYERYlw5H6ZrLUI Y6OA== 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=+psE+B3db73MVJrNE1K8OqfI7Vvcva/zxMKjnKjukJA=; b=KxMu4P1VxaSg04y9BnegysbctLiXhRNmJYD0oZJxozq7ENY+v9SS2SajZMBoEsmyQO p5RqQK2BJJIxayOMGM9mdmQwFqGNc3S3n+ZkjMH7uQUM/+cZHnmcZgq1IUK5U6m8FCUG hjXtp/6sVLkEqDHeOOtssIFOEu/5Lnn6qJh09gLlO53Orr8Owkew8q0DFP3gex0y4ujK 9pBLV3oZhLlSBxUCTLFmFmlhE3IR4F52uKJ2clMZtZ9crzV43VQFxOKaZCixGZejvM+Z f3JjZO99+m+CcMcw/WEIcNeugWcTK6Hc8+dYLjuMeR0AjnNnzsEL3Ugm8oBvXSpZjBGP s/fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=b0Icf6lT; 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 r2si1276267ejp.57.2019.09.20.08.58.47; Fri, 20 Sep 2019 08:59:10 -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=b0Icf6lT; 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 S2394189AbfISW0Y (ORCPT + 99 others); Thu, 19 Sep 2019 18:26:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:37414 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406830AbfISWWY (ORCPT ); Thu, 19 Sep 2019 18:22:24 -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 DC4D1217D6; Thu, 19 Sep 2019 22:22:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568931743; bh=oodeJ+0d7shrMwu2VCOzA6cipo4DbmkAS4qiVyyugnE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b0Icf6lTNWqF3E+PoyalGZQi6Wv/bwnNyb66nSPRQNX2X0T8AlbtySVlUBTtL8SIo 01n1OLsN6KLq9Ri3c6HT52T9c/ruVzs26fu+m5ET/cyi/ZbHcuGwJHpTTz86Q2ldtM pC4R8Yblb3qMYIAwBB0j7B5t9FoZxZujWMS0E+SQ= 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.4 23/56] crypto: talitos - check data blocksize in ablkcipher. Date: Fri, 20 Sep 2019 00:04:04 +0200 Message-Id: <20190919214754.861255842@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919214742.483643642@linuxfoundation.org> References: <20190919214742.483643642@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 @@ -1641,6 +1641,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); @@ -1658,6 +1666,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);