Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10945017ybi; Thu, 25 Jul 2019 07:26:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqya4vDOU5h3QvIG38g62Rh8Byvj3IwGgH0ld7Jv2vEAEzJKqD8C1vzfPHkcUaookL2ybSxM X-Received: by 2002:a65:464d:: with SMTP id k13mr78005320pgr.99.1564064788440; Thu, 25 Jul 2019 07:26:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564064788; cv=none; d=google.com; s=arc-20160816; b=ksPzUiUR9tjPCo2a11xtzTPBv0OkGSr3qaPh/EZ49zmEscYAdLZEqSaX0vKpORYo1O vss8tsJTEj66zCIYWa6pkKsEDO2ps1KM3c++2EWsGKiE7vkVAPWZX2wo21h3+iaM79gA TsKpj7DiN3+0Q7JN8CKjJg7metWo8mH3fGF8EcCLaFMFSjLIbh+fXbGv74P6SHdTkw1w 0MGQlNQsXopkHXYy712rzOWCEe+RLc0lVYYwjkQyaoe45KgnfBEhhBdmJXvw1gTBH9wO NV0cR7KinPE7kvyITwqsSh2GA5jm9wzyugXs76VtwsDMV4DzoM5i8YW3wUh6pKr+7Zkv wXwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=bIxamHU4joOBH810gDYHRFd9sPsUPmvjx100g0chLBY=; b=OAlmdu6u2ydb0VwT8GNtzaDZ42lpFh09mrU5sr+kEQR3DGq2LJop4OQqyMhnlId+Gy sTejjBIFjQS1RZ5NyJfV/eEyNOi3bmM+XO5DOaJTX8h/T2GzskZUOA8lfE+XXDRz5XMa p5Z59b4fRxl6AuETWlNxNQeTOTtjbXtB5fVZqLeDHgcv0Hnf52GHHjQWfx46gazI5+DJ EwRZlN2IJ2UpnY2qBED+P0HShITEziXUsxPmXd4oH8+uMEQjfky7Vogkuy1QeezMsxvI xCLHY+c44j8ULGor+IywL+XcEhANEVxsKagF6x4rrBQIOS0Xl0yeyfEJ8EBuTqAWQOhL qJig== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c62si20465796pga.441.2019.07.25.07.26.14; Thu, 25 Jul 2019 07:26:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404608AbfGYN7a (ORCPT + 99 others); Thu, 25 Jul 2019 09:59:30 -0400 Received: from inva020.nxp.com ([92.121.34.13]:48974 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404261AbfGYN6k (ORCPT ); Thu, 25 Jul 2019 09:58:40 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 39A5F1A071A; Thu, 25 Jul 2019 15:58:39 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 2C9A51A0715; Thu, 25 Jul 2019 15:58:39 +0200 (CEST) Received: from lorenz.ea.freescale.net (lorenz.ea.freescale.net [10.171.71.5]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id D66C4205E8; Thu, 25 Jul 2019 15:58:38 +0200 (CEST) From: Iuliana Prodan To: Herbert Xu , Horia Geanta , Aymen Sghaier Cc: "David S. Miller" , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-imx Subject: [PATCH v3 07/14] crypto: caam - check zero-length input Date: Thu, 25 Jul 2019 16:58:19 +0300 Message-Id: <1564063106-9552-8-git-send-email-iuliana.prodan@nxp.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1564063106-9552-1-git-send-email-iuliana.prodan@nxp.com> References: <1564063106-9552-1-git-send-email-iuliana.prodan@nxp.com> X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Check zero-length input, for skcipher algorithm, to solve the extra tests. This is a valid operation, therefore the API will return no error. Signed-off-by: Iuliana Prodan Reviewed-by: Horia Geanta --- drivers/crypto/caam/caamalg.c | 6 ++++++ drivers/crypto/caam/caamalg_qi.c | 3 +++ drivers/crypto/caam/caamalg_qi2.c | 5 +++++ 3 files changed, 14 insertions(+) diff --git a/drivers/crypto/caam/caamalg.c b/drivers/crypto/caam/caamalg.c index a5fcc31..b14a13b 100644 --- a/drivers/crypto/caam/caamalg.c +++ b/drivers/crypto/caam/caamalg.c @@ -1884,6 +1884,9 @@ static int skcipher_encrypt(struct skcipher_request *req) u32 *desc; int ret = 0; + if (!req->cryptlen) + return 0; + /* allocate extended descriptor */ edesc = skcipher_edesc_alloc(req, DESC_JOB_IO_LEN * CAAM_CMD_SZ); if (IS_ERR(edesc)) @@ -1918,6 +1921,9 @@ static int skcipher_decrypt(struct skcipher_request *req) u32 *desc; int ret = 0; + if (!req->cryptlen) + return 0; + /* allocate extended descriptor */ edesc = skcipher_edesc_alloc(req, DESC_JOB_IO_LEN * CAAM_CMD_SZ); if (IS_ERR(edesc)) diff --git a/drivers/crypto/caam/caamalg_qi.c b/drivers/crypto/caam/caamalg_qi.c index b8de0a8..452467c 100644 --- a/drivers/crypto/caam/caamalg_qi.c +++ b/drivers/crypto/caam/caamalg_qi.c @@ -1443,6 +1443,9 @@ static inline int skcipher_crypt(struct skcipher_request *req, bool encrypt) struct caam_ctx *ctx = crypto_skcipher_ctx(skcipher); int ret; + if (!req->cryptlen) + return 0; + if (unlikely(caam_congested)) return -EAGAIN; diff --git a/drivers/crypto/caam/caamalg_qi2.c b/drivers/crypto/caam/caamalg_qi2.c index fb6c757..c1eca99 100644 --- a/drivers/crypto/caam/caamalg_qi2.c +++ b/drivers/crypto/caam/caamalg_qi2.c @@ -1498,6 +1498,9 @@ static int skcipher_encrypt(struct skcipher_request *req) struct caam_request *caam_req = skcipher_request_ctx(req); int ret; + if (!req->cryptlen) + return 0; + /* allocate extended descriptor */ edesc = skcipher_edesc_alloc(req); if (IS_ERR(edesc)) @@ -1526,6 +1529,8 @@ static int skcipher_decrypt(struct skcipher_request *req) struct caam_request *caam_req = skcipher_request_ctx(req); int ret; + if (!req->cryptlen) + return 0; /* allocate extended descriptor */ edesc = skcipher_edesc_alloc(req); if (IS_ERR(edesc)) -- 2.1.0