Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2904942ybi; Thu, 18 Jul 2019 17:00:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqxGtHkddcPsZRAk9ernql9tnbjILjAD4ZwKyuTggprdSi2pWNpy3FGzlxm8lQYy6cZ9ixik X-Received: by 2002:a63:5d45:: with SMTP id o5mr51196671pgm.40.1563494410148; Thu, 18 Jul 2019 17:00:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563494410; cv=none; d=google.com; s=arc-20160816; b=anM1J4MQZxgSxuSHWkRE1aFM0FZTTqejAsQ78GuAgWhu8YSM+WyOTjsADYf5AISPe8 BM4c/e+6qMkepJf+3hzEI0LAmo1hZpmE8w4RKOflv3FfaClag/nT8ZBKUzBoQrVtKac1 8Cx4aKHorFU+358XYAFJJlEG2Wdfz4AQQP4VXdNhj9jIinFRks7vZezq0QjpXSo3xGjx K2IdfNwzSK/4cO0lKeCOWlq3QFTuQBRFP/GmtkNuan7YPlpEpQt/M608LpGkgfjNfoFE 4C6yjgQA1FvFx1TgfXbPdudMYeUGdNPYRxhhAcHLAQJLUE2QouPVHogiPSRcQvrFHjNp yTyg== 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=AYeSl/6hzJ0gXD5o135n8S7FyG21SD44N9kERg9I2mM=; b=khtjmJQ7Ax1MmD49+AVKaLDvyxG9TElzETfJmKZX4hM8o2FdqHPYSYmNBhUQAa7yIt ue3ttGGKIEmTCW4cYSe6sFeWNX5D6+HUfpv65MjHUWTxD5XSB9416s/DHaT7KfG4NjgP yDMl+yCR5OcXvFnAqgPYoXGp5USRxg9DcYI4/kqqLHMGlF9QKPQ0tbvGvCh1+R+C62l5 6LStzHgm78JDSTEwo3c+VXp/RB9oV+WLlmEo+YuAEtkWZnHDRIIOho8lQJ58/cOY99/1 /BCP5rlHPrw1i8pJ78QupcXG0LTrdF2a/WpfCRKxj816Md6cj+A4EELi/7RV1UQyrefr I4XQ== 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 t22si846685pgh.582.2019.07.18.16.59.56; Thu, 18 Jul 2019 17:00:10 -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 S1726290AbfGRX6Q (ORCPT + 99 others); Thu, 18 Jul 2019 19:58:16 -0400 Received: from inva020.nxp.com ([92.121.34.13]:54556 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726211AbfGRX6Q (ORCPT ); Thu, 18 Jul 2019 19:58:16 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id EE9BA1A0369; Fri, 19 Jul 2019 01:58:14 +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 E1CF61A0365; Fri, 19 Jul 2019 01:58:14 +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 979A7205D1; Fri, 19 Jul 2019 01:58:14 +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 v2 07/14] crypto: caam - check zero-length input Date: Fri, 19 Jul 2019 02:57:49 +0300 Message-Id: <1563494276-3993-8-git-send-email-iuliana.prodan@nxp.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1563494276-3993-1-git-send-email-iuliana.prodan@nxp.com> References: <1563494276-3993-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 --- 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 6b9937c..9a7bb06 100644 --- a/drivers/crypto/caam/caamalg.c +++ b/drivers/crypto/caam/caamalg.c @@ -1891,6 +1891,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)) @@ -1925,6 +1928,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 69cc657..b2dd4f3 100644 --- a/drivers/crypto/caam/caamalg_qi.c +++ b/drivers/crypto/caam/caamalg_qi.c @@ -1450,6 +1450,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 da3452b..285e3c9 100644 --- a/drivers/crypto/caam/caamalg_qi2.c +++ b/drivers/crypto/caam/caamalg_qi2.c @@ -1499,6 +1499,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)) @@ -1527,6 +1530,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