Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1851978pxb; Mon, 13 Sep 2021 06:57:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8emM0tsYgCFCVnWyFkkHOvrfupHqx0MKh9exCOomLSJeAq8DDLmu7lwRUpLv3RXiVuV2Q X-Received: by 2002:a17:906:4cc1:: with SMTP id q1mr12349702ejt.415.1631541436864; Mon, 13 Sep 2021 06:57:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631541436; cv=none; d=google.com; s=arc-20160816; b=yJCZOCrmFcS+xPbF6+Yz9qgGcXgbK1AJ02R7eoipuEzGI6NK0fOHL3xFbLL7KeO4AL qJP4xsmZ0NzJsbAS1CZDCryNfSj0wwOQshZ7aVbirrbkhK1TZ2HssNEoFcsFrfgrQ4ZM UGZ89SsA2GveV1VJExg59ckJL+ibqBk2quv8IOuji20ovsnHBmaU4cCcmFZCCRxGAZ9C xug9XAUiFDVlw259V+iilqYO/6bKaJDFJBsqsIFZ0q1HviTFXzEA+Duy444XK5O9v0C7 5nKd7CQlm3UKuCDRNedP5YqRSKqzJX4KeX7MfIO8BrxbFWqQGc373G6UiecQZvJroIgx QNFg== 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=RTkC6NLIdiuNvRKi3eGtQgV5h0sy6TknidTy2ThP24I=; b=Gg9MKWDqxOWald+5PWV3/mpe+IFxCMEiY0xMWaqV9ztnqxsU3lZuhmk5vdUuv4J8Zi Ju1mavUDqW3QA55D9HEoDnS+hSg0O6zIGb6ZKao+K2vnbrAi6Bfg6QWIs2UNGBa/fEhF avKzqv/rk3QWrejsOmtZrbbvN738fQTVyhZcVqe/DHEwBz3pmvLIlVCdoJBBMAifEaSD W7gVTQqx10dakoF+rIkbCTgQTaL6LLEKadIfl6QWzsPLt9uYjDZZA/1omeibHAwJocQ6 YGOpIOviacBlUp1sfh1EOEe3Pf5M1P69XmVc/UM/jfoMOZKLVXzonxHnIHRS2SxYgRp1 +R8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2kU+smX3; 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 x14si6734875ede.481.2021.09.13.06.56.50; Mon, 13 Sep 2021 06:57:16 -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=2kU+smX3; 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 S244859AbhIMNzt (ORCPT + 99 others); Mon, 13 Sep 2021 09:55:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:34352 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244057AbhIMNwo (ORCPT ); Mon, 13 Sep 2021 09:52:44 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B5F06617E1; Mon, 13 Sep 2021 13:34:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631540066; bh=ApwTNw57Xn5wd0hDAzN4+R9h7oL8Q3f2/lpZI7iL3iA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2kU+smX3Ag7NRofRVmUVHdVa4n70zn0wT6Rs0/1mKMdLFBMhOidiV1ELWhmy2J7W8 zUaq/e/ylpT/b8hwH0Zp81qOA+SGUa2tg7/YeXyJgfU2C0x1y3qE1z65MKHMgBgQVB DNDOHDzd9ZQDjX74wm39OzMD5L8UaOLFW8l0Exw8= 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.13 037/300] crypto: tcrypt - Fix missing return value check Date: Mon, 13 Sep 2021 15:11:38 +0200 Message-Id: <20210913131110.577991902@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131109.253835823@linuxfoundation.org> References: <20210913131109.253835823@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 6b7c158dc508..f9c00875bc0e 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