Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp563075pxb; Fri, 13 Aug 2021 00:56:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGCpO5NwD3X5R3TGkPiqKkfsk2VpHB2IBQS0f+ncEnwS9a60TB8wes4UMn1G/rQ/SBgbZ2 X-Received: by 2002:aa7:c40a:: with SMTP id j10mr1452820edq.133.1628841400866; Fri, 13 Aug 2021 00:56:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628841400; cv=none; d=google.com; s=arc-20160816; b=G+S6/zOt6rdneDuquuNJYr9m6tZ2mKPt8gBWT1gs01gCloktLHRFHAciYWwLcLBYxI vA/bOEhvKR3tiNJ0PZDjjp1WQY8571PnS+J9qSejAwWb2QKujhUItrnN9ECs2UxeGwAu i8tPE8SV4ymq9oDn2Eeo4xie/VOPFxBsZKlBSo+fty87uwBF70iG+r0GXIVfr2AP4wQk xfJnYmf7LvZft1t+B3nchJHgQcCrAL/ntC7DNEJXIiDi1bg1IlIna2cylFTweizPLpdj t7H4V10ZPqiydnchTVD2tKSaRvx3qIQFzOCGmaAWZrrv/53GnLihdkAnKNRQtACJwwA3 jwaQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=m+nqkfL0KvyCXhLPdWgSY8IY0TWP7lg1GwvBPVCy5AU=; b=uu5SnxJdbOZnKkeqZpcM51BC/dYgW564Bz0TfOvCBtRDeKDkPpGc0WJGmy+iZIuVc/ mqPDMI/rlmvumXwhhcLlR+JNTxubf4MW2ObuoLjubq+yqqdS2erI+i22y05eZaUMGD7c eg7U1NXwhprO3Y+0IicmtVHRTMtiptOc9HxHMaxjEqMmyqKCeowSZ1ohSmtzXi3tFa4t Mka9grArdMXRMnMRjzl6lDnBsjHRZG7XaoapzwC3chw1HcvjQP8OpSfEClLV3xS0qhNv 4rMYlUnw3+YEm/zLVX+4HCykikM8Pdq561pElU0NwqO3vcCLStaAQmcePDfho5l+Jcwm npcA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n25si1064102edd.157.2021.08.13.00.56.16; Fri, 13 Aug 2021 00:56:40 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239528AbhHMHzi (ORCPT + 99 others); Fri, 13 Aug 2021 03:55:38 -0400 Received: from out30-45.freemail.mail.aliyun.com ([115.124.30.45]:55670 "EHLO out30-45.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232642AbhHMHzh (ORCPT ); Fri, 13 Aug 2021 03:55:37 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R751e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=alimailimapcm10staff010182156082;MF=tianjia.zhang@linux.alibaba.com;NM=1;PH=DS;RN=11;SR=0;TI=SMTPD_---0UisBCNm_1628841309; Received: from localhost(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0UisBCNm_1628841309) by smtp.aliyun-inc.com(127.0.0.1); Fri, 13 Aug 2021 15:55:09 +0800 From: Tianjia Zhang To: 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" Cc: Tianjia Zhang Subject: [PATCH v2 1/3] crypto: tcrypt - Fix missing return value check Date: Fri, 13 Aug 2021 15:55:06 +0800 Message-Id: <20210813075508.98854-2-tianjia.zhang@linux.alibaba.com> X-Mailer: git-send-email 2.19.1.3.ge56e4f7 In-Reply-To: <20210813075508.98854-1-tianjia.zhang@linux.alibaba.com> References: <20210813075508.98854-1-tianjia.zhang@linux.alibaba.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org 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 --- 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