Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp6844997iob; Wed, 11 May 2022 06:38:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYYg8TKqB/yQ5Qu+4P+K2Gyu0uNMqLxkrCvRW+rpxxJVra7Y9xSPKVijibu84cW4vFH3oM X-Received: by 2002:a17:907:968d:b0:6f4:9f9e:3e5f with SMTP id hd13-20020a170907968d00b006f49f9e3e5fmr25141523ejc.540.1652276297333; Wed, 11 May 2022 06:38:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652276297; cv=none; d=google.com; s=arc-20160816; b=efNO2EbYXQIzpSO8CSvIFGS9FDrBbbvfUofwMALIbOsrIHuke5pCMVezGu63exqMSU h9VezahuJ+OJ7eorolG2D+FOZ7ci77lo9xen8J0fl6wPaXnSEQOtmPRav1K9MBJGtDJg eBAh9ieb2gZEGtag5TqUBL8iW1GR7lt1rdK1x5bUga/HtvUnbLXNy5C8f5FADU0gmcu4 zDYlluTy7j4AQUXyb2OVnOsIUjbNllYM5vNSegpGmisqR0PZE5YEAnKIaFZoONiQRogB u5w+/+9P4qKhp0Y5JyPECZHCEnYQN611BiCjeuaSCd/U9MhPF7Nki0xays1/i8pHVnaA YwFw== 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=0eZFVr0R7tr8pw1d+4up9u7mZ3WWk1zMsEZIi4198wM=; b=r1Fdy3wt0RsknntNEfKxn3yR4t9UZvyhur3D6RmfFQmeh9Z0bz8wceZfJI/9vdfJk5 ErSTsF0EFAdI51m2bf3uPw2/KyjNO05V0xhHWvqMCmuPqzQ81lOMBAShPeiKe/WnokAk 4kzNGMkEpQAvfT72smFpSkv30OzOKUj7jhzeuyGXIfEpgoQi/2nRdcu8epKB564Tf/Bi HvanO27ZTckQsEaEma1cRgsNYNTVd8VoKey204RqNNWBLaf072f5OViFNczOrQl0wNZ5 iucARMC2Oosv7NdOt1mo2Csxh0WkCEpTx08MRjjF6xKNslUGQNzP7moU0RYwq+dWrm6P 862g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=LoYM1Glt; 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=NONE sp=NONE dis=NONE) header.from=zx2c4.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb40-20020a1709076da800b006e85a385741si2739142ejc.376.2022.05.11.06.37.51; Wed, 11 May 2022 06:38:17 -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; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b=LoYM1Glt; 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=NONE sp=NONE dis=NONE) header.from=zx2c4.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235818AbiEKLly (ORCPT + 99 others); Wed, 11 May 2022 07:41:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241269AbiEKLlg (ORCPT ); Wed, 11 May 2022 07:41:36 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6A896221F; Wed, 11 May 2022 04:41:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 821D3B82215; Wed, 11 May 2022 11:41:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 649A8C340F2; Wed, 11 May 2022 11:41:31 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="LoYM1Glt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1652269289; h=from:from:reply-to:subject:subject: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=0eZFVr0R7tr8pw1d+4up9u7mZ3WWk1zMsEZIi4198wM=; b=LoYM1GltXCzbdsQ/25CVajZQVoSqUAN8UhoOsZiWg0Kq6Bi1/kBG7KibB4PZCjJRpmx3fW UgdAsOkclk+7raS2ozM4dbiF98xnRpB3RJ9oeo30PrnSCa3xmI3mZ24OWL+A1Oda83vcBi wT4anzX9ubyzD6Vdfvg0q2W6EF9o/is= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 28e7ee18 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Wed, 11 May 2022 11:41:29 +0000 (UTC) Date: Wed, 11 May 2022 13:41:27 +0200 From: "Jason A. Donenfeld" To: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org Cc: Theodore Ts'o , Dominik Brodowski , Steven Rostedt , Ard Biesheuvel Subject: Re: [PATCH RFC v1] random: use static branch for crng_ready() Message-ID: References: <20220503134052.646325-1-Jason@zx2c4.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20220503134052.646325-1-Jason@zx2c4.com> X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,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 On Tue, May 03, 2022 at 03:40:52PM +0200, Jason A. Donenfeld wrote: > +static bool crng_ready_slowpath(void) > +{ > + if (crng_init <= 1) > + return false; > + if (in_atomic() || irqs_disabled() || cmpxchg(&crng_init, 2, 3) != 2) > + return true; Nobody chimed in here, but for posterity I thought I should point out that this approach actually won't work, since in_atomic() doesn't work with CONFIG_PREEMPT_COUNT=n kernels. So back to the drawing board in trying to figure out the best way to do this... Jason