Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp5767229rwb; Tue, 22 Nov 2022 04:49:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf5KWt3sWu/ygHrzip7ggf0OS91jS4yyuqoUEnW/mowxK63jTwomVJ7KqoPP2SgzKD+Wi8uZ X-Received: by 2002:a17:902:e5c5:b0:185:4625:2a1f with SMTP id u5-20020a170902e5c500b0018546252a1fmr4243628plf.24.1669121386009; Tue, 22 Nov 2022 04:49:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669121386; cv=none; d=google.com; s=arc-20160816; b=UOaPL7mNvXecN8imwS8jaFL3gsUKJE+k1qMCatnOeU5A+VNKbjLEU7CRIpeHRoDJBk xlW1d78xe2tBMFmShEtrX1w6yfPDdvNanqwMoEtVqn2floSaIv5nEgvEFfhqpPY7XTmt bmGJg87LKIWAf1JYXEia3Yyt8EjtCvn52SRbiKi3FlLw0HRUvdknbgLWyulUTfs2jTKk +LSsG6SGLNo/iW3L67WSDAOEDdg7jWMlyEpjPa2rmBLkuPg87i+j7YEJ7cs7Wud7c/gX oH9ivWL1tFnN5ILr+RWRIG02683NhzGenbc+0sFpl4kgVe7Vr6qZfWbay7aR/sH+KZXt Dk8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:to:subject; bh=5+U+TkkhEaAmhugY3KtYb9ILsgAy9s02pMeycKSKKM4=; b=BeZM3bEO0b4QnLDgH+RXSG3GPuMEU3agqz8lMZoFdqki3W4pLO0At8uliTg4ZS0Kdx Y7pVwhP2d6ymSDUzW03/DSI5hOECY0pOZPHqW/P0Bc+FTGgB+518d6c+WO4sAEEUQLyM bXORhJ1HQUA2pHkCbwVtjEvzWu86dEzOoItJ7jWurKmPhSNicDyIplVdl68LBlIWb1xb +0Mh5eFWB1erkKT/wxscSMlcoELvMDDfTB9jpIB+zojrzV0hvGmgvC4Mc+abiXJTEhiK 904XoXVzYN+II4B+QKAAAK3MVWekPFrUi36S8o86eSSvXeF46RLnEH4KMbc18ruRk7fM v5tg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k188-20020a6324c5000000b004769f0fd662si15297509pgk.362.2022.11.22.04.49.25; Tue, 22 Nov 2022 04:49:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229750AbiKVMmN (ORCPT + 99 others); Tue, 22 Nov 2022 07:42:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232734AbiKVMmM (ORCPT ); Tue, 22 Nov 2022 07:42:12 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F1CF60365 for ; Tue, 22 Nov 2022 04:42:09 -0800 (PST) Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4NGkMc2cN1zJnQc for ; Tue, 22 Nov 2022 20:38:52 +0800 (CST) Received: from kwepemm600005.china.huawei.com (7.193.23.191) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 22 Nov 2022 20:42:07 +0800 Received: from [10.67.103.158] (10.67.103.158) by kwepemm600005.china.huawei.com (7.193.23.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Tue, 22 Nov 2022 20:42:06 +0800 Subject: Re: [PATCH] crypto: hisilicon/hpre - Use helper to set reqsize To: Herbert Xu , Linux Crypto Mailing List References: From: liulongfang Message-ID: <7b002294-07a3-7697-0839-3092b4a41ab4@huawei.com> Date: Tue, 22 Nov 2022 20:42:06 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.103.158] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600005.china.huawei.com (7.193.23.191) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On 2022/11/22 17:28, Herbert Xu wrote: > The value of reqsize must only be changed through the helper. > > Signed-off-by: Herbert Xu > > diff --git a/drivers/crypto/hisilicon/hpre/hpre_crypto.c b/drivers/crypto/hisilicon/hpre/hpre_crypto.c > index ef02dadd6217..5f6d363c9435 100644 > --- a/drivers/crypto/hisilicon/hpre/hpre_crypto.c > +++ b/drivers/crypto/hisilicon/hpre/hpre_crypto.c > @@ -740,6 +740,8 @@ static int hpre_dh_init_tfm(struct crypto_kpp *tfm) > { > struct hpre_ctx *ctx = kpp_tfm_ctx(tfm); > > + kpp_set_reqsize(tfm, sizeof(struct hpre_asym_request) + HPRE_ALIGN_SZ); > + > return hpre_ctx_init(ctx, HPRE_V2_ALG_TYPE); > } > > @@ -1165,6 +1167,9 @@ static int hpre_rsa_init_tfm(struct crypto_akcipher *tfm) > return PTR_ERR(ctx->rsa.soft_tfm); > } > > + akcipher_set_reqsize(tfm, sizeof(struct hpre_asym_request) + > + HPRE_ALIGN_SZ); > + > ret = hpre_ctx_init(ctx, HPRE_V2_ALG_TYPE); > if (ret) > crypto_free_akcipher(ctx->rsa.soft_tfm); > @@ -1617,6 +1622,8 @@ static int hpre_ecdh_nist_p192_init_tfm(struct crypto_kpp *tfm) > > ctx->curve_id = ECC_CURVE_NIST_P192; > > + kpp_set_reqsize(tfm, sizeof(struct hpre_asym_request) + HPRE_ALIGN_SZ); > + > return hpre_ctx_init(ctx, HPRE_V3_ECC_ALG_TYPE); > } > > @@ -1626,6 +1633,8 @@ static int hpre_ecdh_nist_p256_init_tfm(struct crypto_kpp *tfm) > > ctx->curve_id = ECC_CURVE_NIST_P256; > > + kpp_set_reqsize(tfm, sizeof(struct hpre_asym_request) + HPRE_ALIGN_SZ); > + > return hpre_ctx_init(ctx, HPRE_V3_ECC_ALG_TYPE); > } > > @@ -1635,6 +1644,8 @@ static int hpre_ecdh_nist_p384_init_tfm(struct crypto_kpp *tfm) > > ctx->curve_id = ECC_CURVE_NIST_P384; > > + kpp_set_reqsize(tfm, sizeof(struct hpre_asym_request) + HPRE_ALIGN_SZ); > + > return hpre_ctx_init(ctx, HPRE_V3_ECC_ALG_TYPE); > } > > @@ -1961,6 +1972,8 @@ static int hpre_curve25519_init_tfm(struct crypto_kpp *tfm) > { > struct hpre_ctx *ctx = kpp_tfm_ctx(tfm); > > + kpp_set_reqsize(tfm, sizeof(struct hpre_asym_request) + HPRE_ALIGN_SZ); > + > return hpre_ctx_init(ctx, HPRE_V3_ECC_ALG_TYPE); > } > > @@ -1981,7 +1994,6 @@ static struct akcipher_alg rsa = { > .max_size = hpre_rsa_max_size, > .init = hpre_rsa_init_tfm, > .exit = hpre_rsa_exit_tfm, > - .reqsize = sizeof(struct hpre_asym_request) + HPRE_ALIGN_SZ, > .base = { > .cra_ctxsize = sizeof(struct hpre_ctx), > .cra_priority = HPRE_CRYPTO_ALG_PRI, > @@ -1998,7 +2010,6 @@ static struct kpp_alg dh = { > .max_size = hpre_dh_max_size, > .init = hpre_dh_init_tfm, > .exit = hpre_dh_exit_tfm, > - .reqsize = sizeof(struct hpre_asym_request) + HPRE_ALIGN_SZ, > .base = { > .cra_ctxsize = sizeof(struct hpre_ctx), > .cra_priority = HPRE_CRYPTO_ALG_PRI, > @@ -2016,7 +2027,6 @@ static struct kpp_alg ecdh_curves[] = { > .max_size = hpre_ecdh_max_size, > .init = hpre_ecdh_nist_p192_init_tfm, > .exit = hpre_ecdh_exit_tfm, > - .reqsize = sizeof(struct hpre_asym_request) + HPRE_ALIGN_SZ, > .base = { > .cra_ctxsize = sizeof(struct hpre_ctx), > .cra_priority = HPRE_CRYPTO_ALG_PRI, > @@ -2031,7 +2041,6 @@ static struct kpp_alg ecdh_curves[] = { > .max_size = hpre_ecdh_max_size, > .init = hpre_ecdh_nist_p256_init_tfm, > .exit = hpre_ecdh_exit_tfm, > - .reqsize = sizeof(struct hpre_asym_request) + HPRE_ALIGN_SZ, > .base = { > .cra_ctxsize = sizeof(struct hpre_ctx), > .cra_priority = HPRE_CRYPTO_ALG_PRI, > @@ -2046,7 +2055,6 @@ static struct kpp_alg ecdh_curves[] = { > .max_size = hpre_ecdh_max_size, > .init = hpre_ecdh_nist_p384_init_tfm, > .exit = hpre_ecdh_exit_tfm, > - .reqsize = sizeof(struct hpre_asym_request) + HPRE_ALIGN_SZ, > .base = { > .cra_ctxsize = sizeof(struct hpre_ctx), > .cra_priority = HPRE_CRYPTO_ALG_PRI, > @@ -2064,7 +2072,6 @@ static struct kpp_alg curve25519_alg = { > .max_size = hpre_curve25519_max_size, > .init = hpre_curve25519_init_tfm, > .exit = hpre_curve25519_exit_tfm, > - .reqsize = sizeof(struct hpre_asym_request) + HPRE_ALIGN_SZ, > .base = { > .cra_ctxsize = sizeof(struct hpre_ctx), > .cra_priority = HPRE_CRYPTO_ALG_PRI, > Reviewed-by: Longfang Liu Thanks, Longfang.