Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp524942rwr; Wed, 26 Apr 2023 02:43:26 -0700 (PDT) X-Google-Smtp-Source: AKy350YYxT6bfjggHVP7yVGeShRSvV0fv5M1CPVORfDFgkC9MybOizlBHXFt4AE0NCFr4fyO4bdn X-Received: by 2002:a17:90a:1d0:b0:240:cf04:c997 with SMTP id 16-20020a17090a01d000b00240cf04c997mr18224399pjd.2.1682502206118; Wed, 26 Apr 2023 02:43:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682502206; cv=none; d=google.com; s=arc-20160816; b=ozJZWmaSZgwsUeoqpqAN1FPg81/Fg6fCH0sFm+hHkOb2r9NWjIm4eKdT++OtlAhVCW SsCkawLPRUJZVmIM820J/7kkxtja8qdROaia37jwsTlxd8J7MTTFURIFIh4UKThnAzr3 kAj5Hb68eoIrtfe3sKVVUMcot9eFq78VWXJGFh/2IdmJXrqR3RWCaOOIpk1AbMERMxD/ O3JRPqmf3AGEM1+K6PneCCgY0NmWTf0nGnRJLSrV1K0bdeoojqfsZTInhtSxn3i3+HTa WD2c8QvemrFN3ZfChKA51pRsig7q5900SvVGNLHNh+sKBM0p5W/tVJuV6MBgpVEl5dJS 6Fdw== 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:cc:to :subject; bh=PkWRx9zAFR3vF3Fm1wv1UVvYrcxCqgumCtftcdclCy0=; b=Rl1c7kTapVKcfAAuknXZBrfKAiJeTUPUOfKLAk+XQd1R0V6pECd6yfNQ3QZNdvDat8 GE5h8kQ5XbZU4ZO7m3KXLyBFREAgDDdUlZyWGwBQKjorcP3N9JKxpcUMyH83t6Oe9Q3p 2CqSU8qq1tb8BjLy5MsG9fhTOOQTpZ//roLxvnUc4pGzKge/tMc0/di0oinv7xoFrLqm L0bZPSuPc3bQ3aiIQ8XnbhHu3BPd+GpHAPTPSeIKBp1S/cA3OnX+K0Tpki62u99gNizv gtElTxqaArmioug+J1mVLsXpTZKZsz/+j53njkD9KYpvgzszzwzuw/sMkIE0LFSguUnt bgJg== 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 gd17-20020a17090b0fd100b002308ac7a1b0si15751681pjb.117.2023.04.26.02.43.10; Wed, 26 Apr 2023 02:43:26 -0700 (PDT) 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 S239544AbjDZJkh (ORCPT + 99 others); Wed, 26 Apr 2023 05:40:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240095AbjDZJke (ORCPT ); Wed, 26 Apr 2023 05:40:34 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C303E2121 for ; Wed, 26 Apr 2023 02:40:32 -0700 (PDT) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Q5tV26P97zpTFp; Wed, 26 Apr 2023 17:14:18 +0800 (CST) Received: from [10.67.110.176] (10.67.110.176) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Wed, 26 Apr 2023 17:18:11 +0800 Subject: Re: [PATCH -next] crypto: jitter - change module_init(jent_mod_init) to subsys_initcall(jent_mod_init) To: Herbert Xu , CC: , References: <20230425125709.39470-1-cuigaosheng1@huawei.com> From: cuigaosheng Message-ID: Date: Wed, 26 Apr 2023 17:18:11 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.110.176] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-5.6 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 Thanks for taking time to review this patch. We have not used subsystem initialisation ordering to guarantee the order of registration since commit adad556efcdd ("crypto: api - Fix built-in testing dependency failures"),but this patch is not a bugfix, it's not merged into the earlier stable branch. For example,on linux-5.10-y, when they are built into the kernel, ecdh will test failed on earlier kernel, we can enable fips=1, the calltrace like below: alg: ecdh: test failed on vector 2, err=-14 Kernel panic - not syncing: alg: self-tests for ecdh-generic (ecdh) failed in fips mode! Call Trace: dump_stack+0x57/0x6e panic+0x109/0x2ca alg_test+0x414/0x420 ? __switch_to_asm+0x3a/0x60 ? __switch_to_asm+0x34/0x60 ? __schedule+0x263/0x640 ? crypto_acomp_scomp_free_ctx+0x30/0x30 cryptomgr_test+0x22/0x40 kthread+0xf9/0x130 ? kthread_park+0x90/0x90 ret_from_fork+0x22/0x30 Merging the commit adad556efcdd ("crypto: api - Fix built-in testing dependency failures") into linux-5.10-y can fix it, but we have to merge more patch before it, such as: https://www.spinics.net/lists/linux-crypto/msg57562.html Otherwise this patch will introduce new problems. It might make sense to keep the timing, on the other hand, we can use it to fix the dependency problem of earlier kernel. Thanks. Gaosheng. On 2023/4/26 16:45, Herbert Xu wrote: > On Tue, Apr 25, 2023 at 08:57:09PM +0800, Gaosheng Cui wrote: >> The ecdh-nist-p256 algorithm will depend on jitterentropy_rng, >> and when they are built into kernel, the order of registration >> should be done such that the underlying algorithms are ready >> before the ones on top are registered. >> >> Now ecdh is initialized with subsys_initcall but jitterentropy_rng >> is initialized with module_init. >> >> This patch will change module_init(jent_mod_init) to >> subsys_initcall(jent_mod_init), so jitterentropy_rng will be >> registered before ecdh-nist-p256 when they are built into kernel. >> >> Signed-off-by: Gaosheng Cui >> --- >> crypto/jitterentropy-kcapi.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/crypto/jitterentropy-kcapi.c b/crypto/jitterentropy-kcapi.c >> index b9edfaa51b27..563c1ea8c8fe 100644 >> --- a/crypto/jitterentropy-kcapi.c >> +++ b/crypto/jitterentropy-kcapi.c >> @@ -205,7 +205,7 @@ static void __exit jent_mod_exit(void) >> crypto_unregister_rng(&jent_alg); >> } >> >> -module_init(jent_mod_init); >> +subsys_initcall(jent_mod_init); > This is unnecessary because we now postpone the testing of all > algorithms until their first use. So unless something in the > kernel makes use of this before/during module_init, then we don't > need to move jent. > > Cheers,