Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp703128pxb; Wed, 13 Apr 2022 10:26:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJySFsczJ6hBAxcUdUtgrIjdWMzo1Ms0DIOBsjZO434bbbp6XXUTj9vHea8fYtYsPf29iV0m X-Received: by 2002:a50:9e61:0:b0:419:d8e5:6236 with SMTP id z88-20020a509e61000000b00419d8e56236mr44266615ede.327.1649870781219; Wed, 13 Apr 2022 10:26:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649870781; cv=none; d=google.com; s=arc-20160816; b=iuBr2MqSeR0YbAj0gEASyqLoy1kV6cIXONBYxjEqrGjG26Xs5x3ivdbTiAoeYH5/AY qbrz/aKUHFoy5U0zMDshjanHFqyuaqC9tAGN0n0CayfmQjlzilE+KYmTRU6AhLxGjmkg 2Rf9fzGbA+E5XjE6oWr5eFmGqH0BUtdffAIYzOxWzV1TzAE48xB5OVS2Kr8BlXCFk3ER 1/HTlM4oCALTxWT50OCx2N6iUbJpUDjdAhj5nfWc9KKBq8MZBrH42D6s+kwyFFQfCFXZ uhqE0TDeRXS3shOts+na1JIfIQ9kBtellYMj/iXwW75RcMXjQq0nb7yFejo4sIL0PpMs jYzA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IHzRJmPvA7OgZjJx+ZTbqcYHIM/uCZIijqXsNo6FZ2U=; b=LRuLALloKceZhfERKhSjmf/vFWasLJvZdwpGP6Uetja+ccqcdecEM1lgMmZwGkh2x8 51FAGeHH+afBLM4N3S/MBvsScM+YL9/K6v8iQM+MibfStfTaVlU+DPm1eJK6KFOIuZvN wo9PSHtlQu2SW5RKYGujDnHt4Hd7XhLMeP1Qc7l/vYhUJasHcxqt8mnDFZY7NocCvk6n 09lNdroZKXRAFg/VMY9t0ngkV/VYzvYlP9/o8hws06983no45SygmpqFE2SBGgRLECqT r/4fB057FqTBkem6dyt5Wd/9LUabsYxvYHDhYJ0b+Y5mfrDcVn7iiOSXl6eiCwtcuAsu JQlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@zx2c4.com header.s=20210105 header.b="C2i/j6CO"; 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 c15-20020a05640227cf00b0041d70be943fsi2426947ede.88.2022.04.13.10.25.50; Wed, 13 Apr 2022 10:26:21 -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="C2i/j6CO"; 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 S235387AbiDML61 (ORCPT + 99 others); Wed, 13 Apr 2022 07:58:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235391AbiDML5n (ORCPT ); Wed, 13 Apr 2022 07:57:43 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7465D31DC2; Wed, 13 Apr 2022 04:55:10 -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 0E93D61E00; Wed, 13 Apr 2022 11:55:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27237C385A4; Wed, 13 Apr 2022 11:55:06 +0000 (UTC) Authentication-Results: smtp.kernel.org; dkim=pass (1024-bit key) header.d=zx2c4.com header.i=@zx2c4.com header.b="C2i/j6CO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zx2c4.com; s=20210105; t=1649850905; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IHzRJmPvA7OgZjJx+ZTbqcYHIM/uCZIijqXsNo6FZ2U=; b=C2i/j6COYrH2Ir/9YfejGPtCEir9fLD3flKTNzWxM3qtFKGfSSvDfd7Id1ygvKepoM/pol Ki+JEztNXLkml4iO4CuGyueab/W/2Sh2YlsHRyldHvXhCd9zlKZyZklBEK6Qj8S9W7+Lc6 9hBIabkwBgsudPJcl+vU3Bd5hRFaD68= Received: by mail.zx2c4.com (ZX2C4 Mail Server) with ESMTPSA id 5b8e3e5e (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Wed, 13 Apr 2022 11:55:04 +0000 (UTC) From: "Jason A. Donenfeld" To: linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, tglx@linutronix.de, arnd@arndb.de Cc: "Jason A. Donenfeld" , Theodore Ts'o , Dominik Brodowski , Russell King , Catalin Marinas , Will Deacon , Geert Uytterhoeven , Thomas Bogendoerfer , Paul Walmsley , Palmer Dabbelt , Albert Ou , "David S . Miller" , Richard Weinberger , Anton Ivanov , Johannes Berg , Ingo Molnar , Borislav Petkov , Dave Hansen , "H . Peter Anvin" , Chris Zankel , Max Filippov , John Stultz , Stephen Boyd , Dinh Nguyen , linux-arm-kernel@lists.infradead.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, sparclinux@vger.kernel.org, linux-um@lists.infradead.org, x86@kernel.org, linux-xtensa@linux-xtensa.org Subject: [PATCH v4 04/11] mips: use fallback for random_get_entropy() instead of zero Date: Wed, 13 Apr 2022 13:54:04 +0200 Message-Id: <20220413115411.21489-5-Jason@zx2c4.com> In-Reply-To: <20220413115411.21489-1-Jason@zx2c4.com> References: <20220413115411.21489-1-Jason@zx2c4.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 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 Cc: Thomas Bogendoerfer Signed-off-by: Jason A. Donenfeld --- arch/mips/include/asm/timex.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/include/asm/timex.h b/arch/mips/include/asm/timex.h index b05bb70a2e46..abc60a6395e3 100644 --- a/arch/mips/include/asm/timex.h +++ b/arch/mips/include/asm/timex.h @@ -94,7 +94,7 @@ static inline unsigned long random_get_entropy(void) else if (likely(imp != PRID_IMP_R6000 && imp != PRID_IMP_R6000A)) return read_c0_random(); else - return 0; /* no usable register */ + return random_get_entropy_fallback(); /* no usable register */ } #define random_get_entropy random_get_entropy -- 2.35.1