Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp630519rwb; Fri, 18 Nov 2022 06:19:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf5oM/UfaKXkMR/sy+w3kN6GAQZY/fhoX0rOW9i8p2h5AhZaXae1EaPZuxEp5JMtgrhrfyU8 X-Received: by 2002:a17:902:efd2:b0:186:c372:8e09 with SMTP id ja18-20020a170902efd200b00186c3728e09mr7935363plb.74.1668781170733; Fri, 18 Nov 2022 06:19:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668781170; cv=none; d=google.com; s=arc-20160816; b=0Rt9FIgngq7Fb6fhJ0FV81qniYynN1s+m/OeDS8FKVEKI3TwTnzM24b1piOZvp1je1 538TYcOjU9b7FC+RwDuX4SFZknylt6AZIzMYn3cp4lQj1meN8sYVh3iIkhvhujlmIT4z RQBRymNzo4aWYOf1WBr/oJdn9im4kaa2Jk68xoLL1+wMOrW3jyDW5KtxcxGBCfYvXX4J w48hPC0MxY7Ppz3W/5otZuOwsSf3oclJ5n/q0W/4M6IjNDKyvEkXG3PXYEIkixSjvR2h sJESXFl0ufB0HJXorXGbtOB6Lg+ikyAizRs9hjzkzafNk5pEq0Gp+ZPY4lJc1/0lWPUT jE/g== 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:dkim-signature; bh=kZ58kSNPkg2axHTVODVsT4bVIql8VHmIU+fBPlfAvdk=; b=fHYk1RnP61ZE3mK7szv5DSm3tLSlO2Mj/SN8cGhwGYNiegHXJJ8x6QJvt8uXhKHWab TMI2GCRBP5Bi1Rpuv/1tMuFIxZthx2+6PgrJNb1+Uk9i19B1WvPManbKtHj3KWK+hlXv FT4A0teaiG+8khornGbbFJUL+A3f2QarsG2K81Uzxr8dDKLg+tWmRbSILDg43mfOUsxQ r23AUS8/pC9fq9AkO6V6u95Ew6/QmTZPzN3hBRoQxfKpysIo8PtJ8rHIE7zw6gzT1lbb oq8ud1+8F/lEyhNHE/T6cMdA1IdYcCXHeomxW1MnkZTUL1UvNSWWGeN8OaxVg+s8nGLu TkAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=p3lzwGcZ; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h9-20020a170902704900b00188fead22f3si1604255plt.104.2022.11.18.06.19.06; Fri, 18 Nov 2022 06:19:30 -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; dkim=pass header.i=@suse.com header.s=susede1 header.b=p3lzwGcZ; 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=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242344AbiKROR6 (ORCPT + 99 others); Fri, 18 Nov 2022 09:17:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242364AbiKRORb (ORCPT ); Fri, 18 Nov 2022 09:17:31 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A0776E572; Fri, 18 Nov 2022 06:16:53 -0800 (PST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 253C11FABB; Fri, 18 Nov 2022 14:16:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1668781012; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=kZ58kSNPkg2axHTVODVsT4bVIql8VHmIU+fBPlfAvdk=; b=p3lzwGcZoFIPOO8U6H5tkUoGie6Ga+jjn1bs45YnUt9ie9/ZFUuEvHKsdBa7BghVCez2Fc BZkmlBTfI1druGJj0hWdMBlsWH29+AodUdWsiHY0HnNklwYxTJ14Xe5iJJL9MEQdvBZY58 SpN+qSLHeJKYzMx/O9w02yfgbketBhw= Received: from suse.cz (unknown [10.100.201.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id EBF712C141; Fri, 18 Nov 2022 14:16:51 +0000 (UTC) Date: Fri, 18 Nov 2022 15:16:49 +0100 From: Petr Mladek To: "Jason A. Donenfeld" Cc: linux-efi@vger.kernel.org, linux-crypto@vger.kernel.org, Ard Biesheuvel , Lennart Poettering , Mike Galbraith , Sebastian Andrzej Siewior Subject: Re: [PATCH RFC v1 2/6] vsprintf: initialize siphash key using notifier Message-ID: References: <20221116161642.1670235-1-Jason@zx2c4.com> <20221116161642.1670235-3-Jason@zx2c4.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221116161642.1670235-3-Jason@zx2c4.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 Wed 2022-11-16 17:16:38, Jason A. Donenfeld wrote: > Rather than polling every second, use the new notifier to do this at > exactly the right moment. Great news! > --- a/lib/vsprintf.c > +++ b/lib/vsprintf.c > @@ -752,26 +753,21 @@ early_param("debug_boot_weak_hash", debug_boot_weak_hash_enable); > > static bool filled_random_ptr_key __read_mostly; > static siphash_key_t ptr_key __read_mostly; > -static void fill_ptr_key_workfn(struct work_struct *work); > -static DECLARE_DELAYED_WORK(fill_ptr_key_work, fill_ptr_key_workfn); > > -static void fill_ptr_key_workfn(struct work_struct *work) > +static int fill_ptr_key(struct notifier_block *nb, unsigned long action, void *data) > { > - if (!rng_is_initialized()) { > - queue_delayed_work(system_unbound_wq, &fill_ptr_key_work, HZ * 2); > - return; > - } > - > get_random_bytes(&ptr_key, sizeof(ptr_key)); > > /* Pairs with smp_rmb() before reading ptr_key. */ > smp_wmb(); > WRITE_ONCE(filled_random_ptr_key, true); > + return 0; I believe that we should rather return NOTIFY_DONE here. It is rather a formal change. The value is 0 as well. That said, I have never really understood the difference between NOTIFY_OK and NOTIFY_DONE. > } > > static int __init vsprintf_init_hashval(void) > { > - fill_ptr_key_workfn(NULL); > + static struct notifier_block fill_ptr_key_nb = { .notifier_call = fill_ptr_key }; > + notify_on_rng_initialized(&fill_ptr_key_nb); > return 0; > } > subsys_initcall(vsprintf_init_hashval) Anyway, the code looks good to me: Reviewed-by: Petr Mladek Best Regards, Petr