Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2938706iog; Mon, 20 Jun 2022 07:54:03 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vmRI+Vxek0WTo93muwsnVTwMY6aZxDy4WwI7Po3Y4Cf6XIZzywIzGCcQlaqEoTuSfbuiri X-Received: by 2002:a05:6a00:1705:b0:51c:26ae:569c with SMTP id h5-20020a056a00170500b0051c26ae569cmr24933122pfc.28.1655736842719; Mon, 20 Jun 2022 07:54:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655736842; cv=none; d=google.com; s=arc-20160816; b=lCtDvealrAWlmkJu57IhG9lFVwhCC9nlXBmMuV/O2mfYoX6xwdxKWnNSUYFJRfhWNd W0g9onDLXZ78/lWnhnHexWLKAoB1AyK1cToDQWKzKUS/RrA3v9tEBcC9ofCSadWngaaV lNZz3u0aKnedVRqUyEJXHuV3SOB5pKUrmsevfWXzs68cQQKVmLoe8lrpwEyOV12Iyiml hS/GOmnrOfK360yR/nyfmdEIv5Zit0CS+FCRMtB9fxZu7ksoTFgrVVUxW2jL12A9U61e SUYt7TSbau9l5HSVoF4gfCUc0SzMmEeGhZx+qaQDhj2uT2BYjErw4LsmKW+q4tYRf8i2 JytQ== 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=DNG5qYuvQ22zl2ks3EyYZWv1hZ84OBDrCwYGb8SkzTM=; b=lvKNH+ZBlwDXNs0xRdlJBOU0smzJX4+F1vd1IHMiYx3VKDky5j0Kx7ptYg30ea8P74 nCTp7tIEDye6JGLoUJcfu7Ma6IbnM2J6FJGLxwWewcjUzX3DVAusgFJLoPo43lnMqHT2 5jrEELYcicp9KfyI92w7fZQAnqptVtMNSexkhXovD/5hQ7c4mTMKnuCI2OYw6LyDjkP1 5xoWLz9LM7qttGLMl+j1PhTk7Em3qnIDp9oFqUEwr5tOEoKgqF4Mw38NwMSEdYBOXGnc Q3oPFaoINXRzdXSfUlDUy3Lkh74bR+htBLz+55Pdchx4vZx3/HfRxl3Sxkdaf4Rv2+bw ++KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XPZPaPFR; 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 bv3-20020a056a00414300b00505fd3b3dcbsi13874685pfb.164.2022.06.20.07.53.48; Mon, 20 Jun 2022 07:54:02 -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=XPZPaPFR; 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 S245136AbiFTNui (ORCPT + 99 others); Mon, 20 Jun 2022 09:50:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348867AbiFTNsF (ORCPT ); Mon, 20 Jun 2022 09:48:05 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17B302F00E; Mon, 20 Jun 2022 06:17:43 -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 7F0E2B811A0; Mon, 20 Jun 2022 13:17:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB656C3411C; Mon, 20 Jun 2022 13:17:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655731058; bh=YAaAnfdN5DGX6izEPZPLbxRmKyDvGykDk8xyS2lO+OE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XPZPaPFRuxbHbAWO0rX8oU+xPbUXuv/HkF1CTsHJ1+iIW7Vhe36bCHLCET6jyv15l s0RsmER1Q4VK41CJtJWoxC04XPnsxjMqWL8I3D29LquOCan5j4NfFS3DOn+kvbs/sR egCbvS6KWIpc/L0BA8g66Iuk4eXSfTll/3TAQQ2M= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Gleixner , Arnd Bergmann , "Russell King (Oracle)" , "Jason A. Donenfeld" Subject: [PATCH 5.4 139/240] arm: use fallback for random_get_entropy() instead of zero Date: Mon, 20 Jun 2022 14:50:40 +0200 Message-Id: <20220620124743.036424435@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220620124737.799371052@linuxfoundation.org> References: <20220620124737.799371052@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: "Jason A. Donenfeld" commit ff8a8f59c99f6a7c656387addc4d9f2247d75077 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 Reviewed-by: Russell King (Oracle) Signed-off-by: Jason A. Donenfeld Signed-off-by: Greg Kroah-Hartman --- arch/arm/include/asm/timex.h | 1 + 1 file changed, 1 insertion(+) --- a/arch/arm/include/asm/timex.h +++ b/arch/arm/include/asm/timex.h @@ -11,5 +11,6 @@ typedef unsigned long cycles_t; #define get_cycles() ({ cycles_t c; read_current_timer(&c) ? 0 : c; }) +#define random_get_entropy() (((unsigned long)get_cycles()) ?: random_get_entropy_fallback()) #endif