Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp221323pxb; Mon, 13 Sep 2021 17:32:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJypnLNO+CZ5F+4hTOf+qBos8hjf8CjOAisJ1L1lOcIyxlWoLOyUM3cztSmixJ05C2ZI4/EZ X-Received: by 2002:a05:6638:268f:: with SMTP id o15mr10432600jat.94.1631579522503; Mon, 13 Sep 2021 17:32:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631579522; cv=none; d=google.com; s=arc-20160816; b=vqEHdglgIUwyMKCmdBXMVpQvwfWiFnJQ3H76MAoUqUs5Wj1whuC6SEIrMQ7ICZySWi FfNI3KoO1XXh2IAK8aoTL8YVP0MoC+w/+N7eopg7kLeyUL+dnx7paF+Oq4hgIVwoeiAv My5bGc5pgs4uMVYBZC0XzH/to86WiwF53xgOyee8FrMXisKU/RurDn4cxXwMaykc+LbL 7QAgY9f+DDwm6lQbbPbIQzH6WRuaM+fCdL71R5c6nC/ReOlCbFqBwgkpbqADlzu5uoyO /WSsX/1R1qrZyjqaaqf7/KT6mAZ63FvijeN9rRFIgiwoqMYH4TA1ytfJPz9Fx+8OPZp0 G78w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=IBVrUNzowBxVepR4rvOo/nAP16i5but25gtuz2rB7Fk=; b=DMa+ld+tGin8NW9UcIKaJxw/3ofMHRZqbwCcpiFH9iK5vN5M3lQPxePJF/YNIEMmho t34rTpX/KGn5oxeepKw416ZuZoLlR2KERN/qPJcy3IYPE3GQ+vO3mljt1DqjTpGkKZjm VOMp+WevIg4LDlXOqJXKZfhF7AecxlBAeQOkc711D/ZTHZSaVu8b66vKTo0A1lR6naF/ +FpWBSVV4VzTKjnLIlnwMEX0BAfHh/1iD382CvzinOpahx9P8pw7h+HkqW/Cfw+qU/1T mqFXGsTVotDY7LxxSFqsKWHLxPOGHTHNqsZpkpftRTCvuViKJUL6tgqn+qZ30R9nbSct qs4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cyYBVS1i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u20si8714268jao.113.2021.09.13.17.31.51; Mon, 13 Sep 2021 17:32:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cyYBVS1i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344731AbhIMOZn (ORCPT + 99 others); Mon, 13 Sep 2021 10:25:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:41882 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345925AbhIMOU1 (ORCPT ); Mon, 13 Sep 2021 10:20:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 21812610A6; Mon, 13 Sep 2021 13:46:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631540792; bh=HpDrTH5dFqfXuhuMC5F+a3DrZqroMthUZD0oSwhxfGA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cyYBVS1iEJCtEPUy4kc+LPMFB+FCUnfnNyM7CPNTeQSUocLLiqNa/9fe2J2zb16Lr TqGjCZPm7S7z9zOOpDfOWaSOkkveJrUbtOvaDiI/okuYXKLPqtn1oVZ0empwWnXhWP mtMXyxneXhPT5rMHHf9eBEqdVubvC7CRjwlKf6R8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tianjia Zhang , Vitaly Chikunov , Herbert Xu , Sasha Levin Subject: [PATCH 5.14 037/334] crypto: tcrypt - Fix missing return value check Date: Mon, 13 Sep 2021 15:11:31 +0200 Message-Id: <20210913131114.679526860@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131113.390368911@linuxfoundation.org> References: <20210913131113.390368911@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tianjia Zhang [ Upstream commit 7b3d52683b3a47c0ba1dfd6b5994a3a795b06972 ] There are several places where the return value check of crypto_aead_setkey and crypto_aead_setauthsize were lost. It is necessary to add these checks. At the same time, move the crypto_aead_setauthsize() call out of the loop, and only need to call it once after load transform. Fixee: 53f52d7aecb4 ("crypto: tcrypt - Added speed tests for AEAD crypto alogrithms in tcrypt test suite") Signed-off-by: Tianjia Zhang Reviewed-by: Vitaly Chikunov Signed-off-by: Herbert Xu Signed-off-by: Sasha Levin --- crypto/tcrypt.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index f8d06da78e4f..6863e57b088d 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c @@ -290,6 +290,11 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs, } ret = crypto_aead_setauthsize(tfm, authsize); + if (ret) { + pr_err("alg: aead: Failed to setauthsize for %s: %d\n", algo, + ret); + goto out_free_tfm; + } for (i = 0; i < num_mb; ++i) if (testmgr_alloc_buf(data[i].xbuf)) { @@ -315,7 +320,7 @@ static void test_mb_aead_speed(const char *algo, int enc, int secs, for (i = 0; i < num_mb; ++i) { data[i].req = aead_request_alloc(tfm, GFP_KERNEL); if (!data[i].req) { - pr_err("alg: skcipher: Failed to allocate request for %s\n", + pr_err("alg: aead: Failed to allocate request for %s\n", algo); while (i--) aead_request_free(data[i].req); @@ -567,13 +572,19 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, sgout = &sg[9]; tfm = crypto_alloc_aead(algo, 0, 0); - if (IS_ERR(tfm)) { pr_err("alg: aead: Failed to load transform for %s: %ld\n", algo, PTR_ERR(tfm)); goto out_notfm; } + ret = crypto_aead_setauthsize(tfm, authsize); + if (ret) { + pr_err("alg: aead: Failed to setauthsize for %s: %d\n", algo, + ret); + goto out_noreq; + } + crypto_init_wait(&wait); printk(KERN_INFO "\ntesting speed of %s (%s) %s\n", algo, get_driver_name(crypto_aead, tfm), e); @@ -611,8 +622,13 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, break; } } + ret = crypto_aead_setkey(tfm, key, *keysize); - ret = crypto_aead_setauthsize(tfm, authsize); + if (ret) { + pr_err("setkey() failed flags=%x: %d\n", + crypto_aead_get_flags(tfm), ret); + goto out; + } iv_len = crypto_aead_ivsize(tfm); if (iv_len) @@ -622,15 +638,8 @@ static void test_aead_speed(const char *algo, int enc, unsigned int secs, printk(KERN_INFO "test %u (%d bit key, %d byte blocks): ", i, *keysize * 8, bs); - memset(tvmem[0], 0xff, PAGE_SIZE); - if (ret) { - pr_err("setkey() failed flags=%x\n", - crypto_aead_get_flags(tfm)); - goto out; - } - sg_init_aead(sg, xbuf, bs + (enc ? 0 : authsize), assoc, aad_size); -- 2.30.2