lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250428123554-5071c41c-5189-4087-80ca-488948365010@linutronix.de>
Date: Mon, 28 Apr 2025 12:37:57 +0200
From: Thomas Weißschuh <thomas.weissschuh@...utronix.de>
To: Willy Tarreau <w@....eu>
Cc: Thomas Weißschuh <linux@...ssschuh.net>, 
	Shuah Khan <shuah@...nel.org>, linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org
Subject: Re: [PATCH 05/15] tools/nolibc: add getrandom()

On Sat, Apr 26, 2025 at 12:31:58PM +0200, Willy Tarreau wrote:
> Hi Thomas,
> 
> On Wed, Apr 23, 2025 at 05:01:35PM +0200, Thomas Weißschuh wrote:
> > --- /dev/null
> > +++ b/tools/include/nolibc/sys/random.h
> > @@ -0,0 +1,32 @@
> > +/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
> > +/*
> > + * random definitions for NOLIBC
> > + * Copyright (C) 2025 Thomas Weißschuh <thomas.weissschuh@...utronix.de>
> > + */
> > +
> 
> Note: don't forget to add your nolibc include here from the other series.

Ack. This series was sent before I got the idea about moving "#include nolibc.h".
I'll fix it up for v2.

> > +#ifndef _NOLIBC_SYS_RANDOM_H
> > +#define _NOLIBC_SYS_RANDOM_H
> > +
> > +#include "../arch.h"
> > +#include "../sys.h"
> (...)
> 
> > diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
> > index abe0ae794208762f6d91ad81e902fbf77253a1c1..95d08e9ccf5b3be924548100e9621cd47f39e8c2 100644
> > --- a/tools/testing/selftests/nolibc/nolibc-test.c
> > +++ b/tools/testing/selftests/nolibc/nolibc-test.c
> (...)
> > +int test_getrandom(void)
> > +{
> > +	uint64_t rng = 0;
> > +	ssize_t ret;
> > +
> > +	ret = getrandom(&rng, sizeof(rng), 0);
> > +	if (ret != sizeof(rng))
> > +		return ret;
> > +
> > +	if (!rng) {
> > +		errno = EINVAL;
> > +		return -1;
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> 
> Just a thought about this one: in a not-so-distant past, getrandom()
> could hang forever when lacking entropy (classical problem when booting
> a headless machine having no RNG), and since a recent kernel it turned
> to "only" multiple seconds. I'm not seeing any easy solution to this,
> but we need to keep an eye on this one, and in case of bad reports,
> maybe have this test as an opt-in or something like this. Anyway the
> best way to know is to have it right now and wait for reports to
> arrive.

What about using GRND_NONBLOCK and mark the test as skipped if no entropy is
available?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ