Received: by 2002:ac2:464d:0:0:0:0:0 with SMTP id s13csp1998054lfo; Sat, 28 May 2022 13:13:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJye0JCudVmi/IbYJA2A+g50ucoIdIrEqNcrcc540iiMjSV3SKUsryihWqytz4kGmn1c2jHS X-Received: by 2002:a63:b57:0:b0:3fb:2369:2298 with SMTP id a23-20020a630b57000000b003fb23692298mr11117006pgl.524.1653768808108; Sat, 28 May 2022 13:13:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653768808; cv=none; d=google.com; s=arc-20160816; b=nqewRr6YJ9gRDA6e2HTiHsO8WgElTFmC3AUC3L14p5QiVq0tgGiUY5NKWiVyW/8dVk 7Y6IBnKFpiYho5MxGvDzbV603wiAdxqh+pQiQFakk+UOZKydzsEeMJIPNdnIXPSIRler 8RL7L8hyf91hAvAmgncLDbUgFGFE76R3YVsx2MOGaTGWZNApnUN5Elm79tCs1k3uM7Vn J9VtOujszGEmeVJk6YJKw1ANqZZ2TEMd8a7MRIJRwdajlyLGpiZ7Dyb2q9bUqYoDE/Ar iwuH8mt3/az2s7prdT69uonBJ530xSXTvwbe2kRgVccaWISZsTfF+2XDT0y28FJDVqdZ sx0g== 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=rhj3NgqfzsERYbkjG0tEixtEQPPI3IPRPdSL4GJiBPo=; b=zKsvEn9HqWWOYq6QZACHTEalc4Q/+Fh9zYUg45a5SKwpUY3ti3XQRv6rwpQOBrZLLp AyOP3g23XzcTRIeX9x4aRulsaVeBzyEbDyabvazm+Zk9N4UldMThb9v0Sm9GYNyxB+CN yU9ronHULQuWKmGpT6VRcqYwYCVlO5fCwqjdZDH37yhCqpFep8gHl7h2zNoZHPR0yQGX aXyahTDcKF6Qu/bHhAggFndBcL2ax/9MNQb1jpUAZpu0latLcLIiKitOWYy9wa25HBKN JWOzdk2nYeTM9x24tglFLJHjmi+Gdz1W9du2QTgyPt4p3Hx10pMyV3JEJCldWqh9Cjjm Qhhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Fx2aPQ8d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id n18-20020a170903111200b0015ef71934fdsi10846628plh.180.2022.05.28.13.13.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 May 2022 13:13:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Fx2aPQ8d; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7B7FD50459; Sat, 28 May 2022 12:25:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243716AbiE0Iww (ORCPT + 99 others); Fri, 27 May 2022 04:52:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350064AbiE0IwJ (ORCPT ); Fri, 27 May 2022 04:52:09 -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 9819B5BE7A; Fri, 27 May 2022 01:52:00 -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 2B45761D3D; Fri, 27 May 2022 08:52:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 030D7C36AE5; Fri, 27 May 2022 08:51:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653641519; bh=bYGVN7kfmeQdES4CFzs8Cvo+1Ksjh/MOcCcr62PeBgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fx2aPQ8dBcfxCUrq9DKg2BJhBu250l/5zlDNC59ZP4J35N6l4plDjd7DwmKlvoP8O mQcw2heXbTD/zGKR+OHr1nQIydAWi2qEUb+FpJw72qRoNwkcrV4V4NvvCFFKuI2JxD eTMLhVEWmHB4ZPObT3cISs7bzzzkZ5Mrw7rvKM+o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Gleixner , Arnd Bergmann , Dinh Nguyen , "Jason A. Donenfeld" Subject: [PATCH 5.18 15/47] nios2: use fallback for random_get_entropy() instead of zero Date: Fri, 27 May 2022 10:49:55 +0200 Message-Id: <20220527084803.834731142@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220527084801.223648383@linuxfoundation.org> References: <20220527084801.223648383@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=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: "Jason A. Donenfeld" commit c04e72700f2293013dab40208e809369378f224c upstream. In the event that random_get_entropy() can't access a cycle counter or similar, falling back to returning 0 is really not the best we can do. Instead, at least calling random_get_entropy_fallback() would be preferable, because that always needs to return _something_, even falling back to jiffies eventually. It's not as though random_get_entropy_fallback() is super high precision or guaranteed to be entropic, but basically anything that's not zero all the time is better than returning zero all the time. Cc: Thomas Gleixner Cc: Arnd Bergmann Acked-by: Dinh Nguyen Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- arch/nios2/include/asm/timex.h | 3 +++ 1 file changed, 3 insertions(+) --- a/arch/nios2/include/asm/timex.h +++ b/arch/nios2/include/asm/timex.h @@ -8,5 +8,8 @@ typedef unsigned long cycles_t; extern cycles_t get_cycles(void); +#define get_cycles get_cycles + +#define random_get_entropy() (((unsigned long)get_cycles()) ?: random_get_entropy_fallback()) #endif