Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4611821ybi; Tue, 30 Jul 2019 05:10:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqz06Hu8u+4KzNqW/p8aOeWXn02Zuu4O8Fv3ZqoQNN8yXmgkRomRcLvgaPHTU2d3vWp7r/yB X-Received: by 2002:a62:754d:: with SMTP id q74mr40460442pfc.211.1564488646486; Tue, 30 Jul 2019 05:10:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564488646; cv=none; d=google.com; s=arc-20160816; b=xLyrg2Ayac3iwyhy+1VTy525un0f1Zgl6potp1u98svlcZ2/jIiKvZyoKxZDWegxtl WScXShwvYcZf9NXcM9EaoXZfJouP8SFaMzsuPVMgkNS6wrLGA8SOcWOg+/laDnR1MUXM 7hAgqCQwpA76DAYjaiuRzL8JKypECHgi1jVV7n9/3QUnSaMsUHbZEIr2wXKddXz89Bfm nzzSm+oC2j7BAdJnlI3yuR5bdiSWHRiJOC3cAbN3lwvzbssRoMc+oTCDI5YCgJ3m1mrZ AOZw/PahmbZl/t0frSxGvCo6bXTwoOkHTIF1OugpwPYIS9nmZGeHlEVpX9VEI4KTbbI4 i8NQ== 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=v5GWvuVcdsNzh+RyhZFGnMH6vS6fE7f2mjkm2FITIpg=; b=wRbX0wcfk0vf4GO10YF0g3WjjMnJ/4yKQCoXMmgqB0l5kgJ7M+nrM1zZCd2gebti3Q YCZ14c0DddTwHgPObU8mkIjJbKshFE47rHeDCXHAzpxUKoLHx6LD9IdGTkvKDLmfT7V7 O/P/TxxiXIbgzzFWvsqXssC0LBWqUeTjDUzpN+8vHtyTJEd3/CVPFq7YqpeDh4wfqxoq pRgqQNYhB3Hp5H3ZHIGq+fwiqI4YM59V6QYylc9dJ2AMC8lyJEz48Fnny6sx6BEBpw// HqPXHU6eiZOmrpAVEkANMVtQU4tclgrTX5RdkL+WYe1Rw6smszUszjiAKSKVvQ29CEmo W0uA== 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 a13si29373549pgw.81.2019.07.30.05.10.33; Tue, 30 Jul 2019 05:10:46 -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 S1730669AbfG3LHs (ORCPT + 99 others); Tue, 30 Jul 2019 07:07:48 -0400 Received: from inva021.nxp.com ([92.121.34.21]:55612 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726713AbfG3LGx (ORCPT ); Tue, 30 Jul 2019 07:06:53 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 0DA2920067D; Tue, 30 Jul 2019 13:06:52 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 01C1C20067A; Tue, 30 Jul 2019 13:06:52 +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 99D4C204D6; Tue, 30 Jul 2019 13:06:51 +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 v4 07/14] crypto: caam - check zero-length input Date: Tue, 30 Jul 2019 14:06:38 +0300 Message-Id: <1564484805-28735-8-git-send-email-iuliana.prodan@nxp.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1564484805-28735-1-git-send-email-iuliana.prodan@nxp.com> References: <1564484805-28735-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 47e61c0..9f83b55 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 794d155d..5ba620d 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 5fd6529..d5f6517 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