From: Willy Tarreau <w@1wt.eu>
To: "Thomas Weißschuh" <thomas.weissschuh@linutronix.de>
Cc: "Thomas Weißschuh" <linux@weissschuh.net>,
"Shuah Khan" <shuah@kernel.org>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [PATCH 05/15] tools/nolibc: add getrandom()
Date: Sat, 26 Apr 2025 12:31:58 +0200 [thread overview]
Message-ID: <20250426103158.GB17549@1wt.eu> (raw)
In-Reply-To: <20250423-nolibc-misc-v1-5-a925bf40297b@linutronix.de>
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@linutronix.de>
> + */
> +
Note: don't forget to add your nolibc include here from the other series.
> +#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.
Willy
next prev parent reply other threads:[~2025-04-26 10:32 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-23 15:01 [PATCH 00/15] tools/nolibc: various new functions Thomas Weißschuh
2025-04-23 15:01 ` [PATCH 01/15] tools/nolibc: add strstr() Thomas Weißschuh
2025-04-23 15:01 ` [PATCH 02/15] tools/nolibc: add %m printf format Thomas Weißschuh
2025-04-23 15:01 ` [PATCH 03/15] tools/nolibc: add more stat() variants Thomas Weißschuh
2025-04-23 15:01 ` [PATCH 04/15] tools/nolibc: add mremap() Thomas Weißschuh
2025-04-23 15:01 ` [PATCH 05/15] tools/nolibc: add getrandom() Thomas Weißschuh
2025-04-26 10:31 ` Willy Tarreau [this message]
2025-04-28 10:37 ` Thomas Weißschuh
2025-04-23 15:01 ` [PATCH 06/15] tools/nolibc: add abs() and friends Thomas Weißschuh
2025-04-23 15:01 ` [PATCH 07/15] tools/nolibc: add support for access() and faccessat() Thomas Weißschuh
2025-04-23 15:01 ` [PATCH 08/15] tools/nolibc: add clock_getres(), clock_gettime() and clock_settime() Thomas Weißschuh
2025-04-23 15:01 ` [PATCH 09/15] tools/nolibc: add timer functions Thomas Weißschuh
2025-04-23 15:01 ` [PATCH 10/15] tools/nolibc: add timerfd functionality Thomas Weißschuh
2025-04-26 10:33 ` Willy Tarreau
2025-04-23 15:01 ` [PATCH 11/15] tools/nolibc: add difftime() Thomas Weißschuh
2025-04-26 10:45 ` Willy Tarreau
2025-04-28 10:41 ` Thomas Weißschuh
2025-04-23 15:01 ` [PATCH 12/15] tools/nolibc: add namespace functionality Thomas Weißschuh
2025-04-26 10:48 ` Willy Tarreau
2025-04-23 15:01 ` [PATCH 13/15] tools/nolibc: add fopen() Thomas Weißschuh
2025-04-26 10:58 ` Willy Tarreau
2025-04-23 15:01 ` [PATCH 14/15] tools/nolibc: implement fall back to sys_clock_gettime() in gettimeofday() Thomas Weißschuh
2025-04-23 15:01 ` [PATCH 15/15] tools/nolibc: implement wait() in terms of waitpid() Thomas Weißschuh
2025-04-26 11:01 ` [PATCH 00/15] tools/nolibc: various new functions Willy Tarreau
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250426103158.GB17549@1wt.eu \
--to=w@1wt.eu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=shuah@kernel.org \
--cc=thomas.weissschuh@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox