Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp6046826iog; Thu, 23 Jun 2022 10:12:27 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sICs7hxMmRWF4WG4yZDAJADFzPDJ3W5PWKoIZVnOPahQzvivkJr17cLHAl8ZzziBI7ym9T X-Received: by 2002:a17:907:1623:b0:722:ef86:e25c with SMTP id hb35-20020a170907162300b00722ef86e25cmr9532308ejc.461.1656004346853; Thu, 23 Jun 2022 10:12:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656004346; cv=none; d=google.com; s=arc-20160816; b=r2I0FaZkj95i1fpkmwu3I+fyRmAAp40ioMI6m3DKrJ8kLjB5WFAQqClW1HwMiTvStG YHHhoDOAd/5nFnmjLDK980ZYGQZJGTdz802kgtGcsIGKLvi8gKYnPd5bI0X09IOE5Ex8 eORGxvmfIIw1yZT15vs1ga0T1SZApucOO52wOQJwTKPCxhsl3iw2htuVEOqWdLjTDoNr VU840/x/MetNDXGdLVsQE/wRYaHdIm81lp6rr0mVKJk0NVMajj92Yb6bzI68ZgVit4Pn tDws4C7al899e8vRmo8Ma1yKZouwrvSznQolejmK/yg9LXEwygKKzZ1SGKvB5EKBm+4Y IfbA== 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=I8Cn2aPM7gLk0zXh94sAAZ98lrhjCkuRY2xL98Eb67s=; b=dy8TpOlcHD9CoNSL1Rb4aV7KGhINoe9atpJs2qR3jD6PYweDIzRFPxZ01ZLix2/YoN oT6b6GSQDg9EXji0P/qkMw4Nvq+vRTPBaNKVOwVVsfXfVGgEOEqC11ZFgAIylYkWt9g6 JylIsjY1/QNSzVksv/zcwij+gkQKpeOPRGRKC28CluDpp02yRcS5dlJzSU+HTDX06L/+ y7hIvNexZlFxoF3aZJofv3n4b+KFyA58N/npLZHjWXT1JXTO69OYCAb7yYxHhvUnkmyX kaQ5v3rTaLStXkic+N4pSJh0fvX18cJqtt30Poy6kH0NEzAdi8dZ5LbnWrBlI4+8XJcN /ELQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="fTF91/B6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g13-20020a50ee0d000000b0042bdb036342si96618eds.398.2022.06.23.10.11.58; Thu, 23 Jun 2022 10:12:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b="fTF91/B6"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S232229AbiFWQqC (ORCPT + 99 others); Thu, 23 Jun 2022 12:46:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232420AbiFWQp5 (ORCPT ); Thu, 23 Jun 2022 12:45:57 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5560748E44; Thu, 23 Jun 2022 09:45:55 -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 dfw.source.kernel.org (Postfix) with ESMTPS id E055C61F91; Thu, 23 Jun 2022 16:45:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3D6BC3411B; Thu, 23 Jun 2022 16:45:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656002754; bh=yQX9uP7Qi3xmNcgIDslJRU/lmTA01+Fbl3y0OPRwIJ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fTF91/B6anuKOUi0t7lVdw1UYhjzCOOGNyxUiYt6yXsaqfcEaTlIO/1pmNyNXdYhl rZlKpV+Xdv1MUggz3Qq3sJutIBteNpd0tEMSx8GU7rP/VC0YndxzhrPmdK1dnY8R+b D3KXJgC4keGUh92XzYclmkeUvOKnyJpu4MMOCqoI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Jason A. Donenfeld" , Sebastian Andrzej Siewior , Theodore Tso Subject: [PATCH 4.9 015/264] random: reorder READ_ONCE() in get_random_uXX Date: Thu, 23 Jun 2022 18:40:08 +0200 Message-Id: <20220623164344.496193971@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220623164344.053938039@linuxfoundation.org> References: <20220623164344.053938039@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-kernel@vger.kernel.org From: Sebastian Andrzej Siewior commit 72e5c740f6335e27253b8ff64d23d00337091535 upstream. Avoid the READ_ONCE in commit 4a072c71f49b ("random: silence compiler warnings and fix race") if we can leave the function after arch_get_random_XXX(). Cc: Jason A. Donenfeld Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Theodore Ts'o Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- drivers/char/random.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/char/random.c +++ b/drivers/char/random.c @@ -2161,7 +2161,7 @@ static DEFINE_PER_CPU(struct batched_ent u64 get_random_u64(void) { u64 ret; - bool use_lock = READ_ONCE(crng_init) < 2; + bool use_lock; unsigned long flags = 0; struct batched_entropy *batch; static void *previous; @@ -2177,6 +2177,7 @@ u64 get_random_u64(void) warn_unseeded_randomness(&previous); + use_lock = READ_ONCE(crng_init) < 2; batch = &get_cpu_var(batched_entropy_u64); if (use_lock) read_lock_irqsave(&batched_entropy_reset_lock, flags); @@ -2196,7 +2197,7 @@ static DEFINE_PER_CPU(struct batched_ent u32 get_random_u32(void) { u32 ret; - bool use_lock = READ_ONCE(crng_init) < 2; + bool use_lock; unsigned long flags = 0; struct batched_entropy *batch; static void *previous; @@ -2206,6 +2207,7 @@ u32 get_random_u32(void) warn_unseeded_randomness(&previous); + use_lock = READ_ONCE(crng_init) < 2; batch = &get_cpu_var(batched_entropy_u32); if (use_lock) read_lock_irqsave(&batched_entropy_reset_lock, flags);