git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 12/12] config.mak.uname: add a note about CSPRNG_METHOD for Linux
@ 2025-03-15  2:49 Ramsay Jones
  2025-03-16  0:28 ` brian m. carlson
  0 siblings, 1 reply; 10+ messages in thread
From: Ramsay Jones @ 2025-03-15  2:49 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: GIT Mailing-list, Patrick Steinhardt, Adam Dinwoodie


Commit 05cd988dce ("wrapper: add a helper to generate numbers from a
CSPRNG", 2022-01-17) added a csprng_bytes() function which used one
of several interfaces to provide a source of cryptographically secure
pseudorandom numbers. The CSPRNG_METHOD make variable was provided to
determine the choice of available 'backends' for the source of random
bytes.

Commit 05cd988dce did not set CSPRNG_METHOD in the Linux section of
the config.mak.uname file, so it defaults to using '/dev/urandom' as
the source of random bytes. The 'backend' values which could be used
on Linux, in order of preference, are 'arc4random', 'getrandom' or
'getentropy' ('openssl' is an option, but seems to be discouraged).

The arc4random routines (ar4random_buf() is the one actually used) were
added to glibc in version 2.36, while both getrandom() and getentropy()
were included in 2.25. So, some of the more up-to-date distributions of
Linux (eg Debian 12, Ubuntu 24.04) would be able to use the preferred
'arc4random' setting.

If the meson build system is used on a newer platform, then they will be
configured to use 'arc4random', whereas the make build will currently
default to using '/dev/urandom'. Add a note to the config.mak.uname file,
in the Linux section, to prompt make users to override CSPRNG_METHOD in
the config.mak file, if appropriate.

Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
---
 config.mak.uname | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/config.mak.uname b/config.mak.uname
index 4f6770a5f4..1a897bd022 100644
--- a/config.mak.uname
+++ b/config.mak.uname
@@ -50,6 +50,8 @@ ifeq ($(uname_S),Linux)
 	HAVE_ALLOCA_H = YesPlease
 	# override in config.mak if you have glibc >= 2.38
 	NO_STRLCPY = YesPlease
+	# set to arc4random (in config.mak) if you have glibc >= 2.36
+	CSPRNG_METHOD =
 	HAVE_PATHS_H = YesPlease
 	LIBC_CONTAINS_LIBINTL = YesPlease
 	HAVE_DEV_TTY = YesPlease
-- 
2.49.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2025-03-20 16:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-15  2:49 [PATCH 12/12] config.mak.uname: add a note about CSPRNG_METHOD for Linux Ramsay Jones
2025-03-16  0:28 ` brian m. carlson
2025-03-16 20:41   ` Junio C Hamano
2025-03-16 21:57     ` Ramsay Jones
2025-03-19 13:30     ` Patrick Steinhardt
2025-03-20  1:28       ` Ramsay Jones
2025-03-20  5:20         ` Patrick Steinhardt
2025-03-20 16:41           ` Ramsay Jones
2025-03-16 21:51   ` Ramsay Jones
2025-03-16 23:52     ` brian m. carlson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).