Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp603695pxb; Fri, 13 Aug 2021 02:08:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJV7xrtf44rS07geeS+X4rCVFXbYYJ0JJGw4nKf23uzpcMTlxDV9wpdMTGh7ZiLtaqg3iK X-Received: by 2002:aa7:d3cf:: with SMTP id o15mr1812208edr.98.1628845682477; Fri, 13 Aug 2021 02:08:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628845682; cv=none; d=google.com; s=arc-20160816; b=X3n+kAbIx6XzHvaAoykmB75ZsLav1mcNjA8UMVpQy17n3Kybxow9cTkSW+nGyoqgi5 qv/nUm0hJc5zb2zd4xgPgNtVGJ6SC1SzSxABE8cjrCdU0sWj5AnMEY7JQGatlTPNlbvc SK2bZ/AQOuOzK+PYCSTuvFvC4nqJXV8UM/R9D+BovDCbfqSroQsct+TUsx4o+zajN44o UYlgIIVEUIyJAlUwKP63oANqeKATfmoBMBIwy6q+6x+XinL6A3S/myZvV2QVUobrA+mU JZb4fcIzfJfxi2/zysMF0U+mfeEIyKnOiq/xB5JU5g1YIC43m6QOvJ9HUfGWihvHcLfs y4fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=uq04dXNjU1WQXlnTmwYgAdy/737zBkc8XkN/4mXo/6Y=; b=V9xDwTouMKtm1Cst6rI8LTivStBX+2XTkQKPvM+QO/TOqIku0dTVW9ZBT6r0hFs4+H 5OAn8z28KRPRWK/2Ldi4Em0vhuw2OkfASwmqoemPnuGeTKv0HmtXIcSli3DzKfaGjZ8l s7qR1BWbzxKkmX+Iah8W7ANIpMsVJSLxTDgPXn6hvMSjbiS/LU9dza4GZ59xSdk72he4 ohu4QliTIVtNoFj08jN3kAxp2x2DGMuyAN5NKzI3uktwvQ5b7lxOVjpmRAcZOaclo5rn yasYDG22MEx1Y0nMJtR9onlP9Ws2xnbdJk7cs7DIyh3OJ0esJLmrsta7mrQuDHSHbcEo hPzg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u1si1167874edo.320.2021.08.13.02.07.31; Fri, 13 Aug 2021 02:08:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239235AbhHMJD4 (ORCPT + 99 others); Fri, 13 Aug 2021 05:03:56 -0400 Received: from vmicros1.altlinux.org ([194.107.17.57]:55968 "EHLO vmicros1.altlinux.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238823AbhHMJDz (ORCPT ); Fri, 13 Aug 2021 05:03:55 -0400 Received: from imap.altlinux.org (imap.altlinux.org [194.107.17.38]) by vmicros1.altlinux.org (Postfix) with ESMTP id D879D72C8FB; Fri, 13 Aug 2021 12:03:27 +0300 (MSK) Received: from altlinux.org (sole.flsd.net [185.75.180.6]) by imap.altlinux.org (Postfix) with ESMTPSA id B63664A46F2; Fri, 13 Aug 2021 12:03:27 +0300 (MSK) Date: Fri, 13 Aug 2021 12:03:27 +0300 From: Vitaly Chikunov To: Tianjia Zhang Cc: Herbert Xu , "David S. Miller" , Eric Biggers , Eric Biggers , Gilad Ben-Yossef , Ard Biesheuvel , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Jia Zhang , "YiLin . Li" Subject: Re: [PATCH v2 1/3] crypto: tcrypt - Fix missing return value check Message-ID: <20210813090327.g6x5gi2hoale5kjg@altlinux.org> References: <20210813075508.98854-1-tianjia.zhang@linux.alibaba.com> <20210813075508.98854-2-tianjia.zhang@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <20210813075508.98854-2-tianjia.zhang@linux.alibaba.com> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Fri, Aug 13, 2021 at 03:55:06PM +0800, Tianjia Zhang wrote: > 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 Thanks, > --- > crypto/tcrypt.c | 29 +++++++++++++++++++---------- > 1 file changed, 19 insertions(+), 10 deletions(-) > > diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c > index d73a42fdaa9b..170102e92f7d 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.19.1.3.ge56e4f7