Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5964351ybi; Wed, 31 Jul 2019 06:11:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqz3/CpIoZYmwHvq+BcvgfNSLCdhUyb25X0thTVS6RPMxKi1+umuWRFgHVoxhVn4RrtYPLbm X-Received: by 2002:aa7:8108:: with SMTP id b8mr48300610pfi.197.1564578693550; Wed, 31 Jul 2019 06:11:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564578693; cv=none; d=google.com; s=arc-20160816; b=yuDgezOsjECCMiH1BFKSzU6ddkHvHoNjCKKm55dTaVGMBrmy0l+Eyzff4sqqd+pE97 idg8H1zJ4/BtMGvoXXsq8XTBQJ45dGrsPxFEoIan60I2vVGkRE6eTQV4YpBzeNUbJRLy 6ElndDLLp390eb6YFxBTDHNwUvvfn1P1EjjoZ8/9poWWhP3Nvg0eViQ1GaY5YZ4mC8/g hTxp6iUUWJRBU5l2SacQemtLAC6BBZGfnO3H8sy3/ZFoOwJHCC3PP9viva4FG32V1rBh oZBi6M5eGK7K7bO6wT3NFqH4QjuavEctr33qIcQiDmOZAPQIZa/a46aiDl99aWPuudUx qpTA== 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=V8WoM0H1RRM7CtpX84MYn66gYIclTbI7mXjH3EsXUf8=; b=BJVToM6Q3q8rERQNEfLY1/+Q33IGmnrhSLPua1pcQTiCIk9MaaqXf0rzamKi/Evrc2 i3or9dpFoDJzi3xRUBWfd9x8h+t1Hh3UnCgLnl8Zli8o5XldLvRdjhUvezq+Vo1m35qj KEL7EI3xwpm4IGogyeFaWZxLFAHM1Ba1VKZNQjHX+WeaMMgvNaKB/ArjT3eRw3+jPLAN Lebgcscjr40N+EtzdLLpAxk42ySfqGnk+9lRZbZITaefhB7z8sCNlFCUrypAXHaxsBVa HsmZtQc9wTnlHAFdmOvgGiSSvj0ht9o5xMZALQ7lEf97WDONeDYW7s6MYyrc6WzCWOUu +ZAw== 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 g90si30531288plb.282.2019.07.31.06.11.19; Wed, 31 Jul 2019 06:11:33 -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 S2388108AbfGaNJG (ORCPT + 99 others); Wed, 31 Jul 2019 09:09:06 -0400 Received: from inva020.nxp.com ([92.121.34.13]:35198 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729249AbfGaNIZ (ORCPT ); Wed, 31 Jul 2019 09:08:25 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id A362D1A09D8; Wed, 31 Jul 2019 15:08:23 +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 971A61A09D1; Wed, 31 Jul 2019 15:08:23 +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 4C63C205F3; Wed, 31 Jul 2019 15:08:23 +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 v5 07/14] crypto: caam - check zero-length input Date: Wed, 31 Jul 2019 16:08:08 +0300 Message-Id: <1564578495-9883-8-git-send-email-iuliana.prodan@nxp.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1564578495-9883-1-git-send-email-iuliana.prodan@nxp.com> References: <1564578495-9883-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 f832491..21e30de 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 2158020..e63b2f7 100644 --- a/drivers/crypto/caam/caamalg_qi.c +++ b/drivers/crypto/caam/caamalg_qi.c @@ -1445,6 +1445,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 0aed1e6..d112975 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