1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00

Make __getrandom_nocancel set errno and add a _nostatus version

The __getrandom_nocancel function returns errors as negative values
instead of errno.  This is inconsistent with other _nocancel functions
and it breaks "TEMP_FAILURE_RETRY (__getrandom_nocancel (p, n, 0))" in
__arc4random_buf.  Use INLINE_SYSCALL_CALL instead of
INTERNAL_SYSCALL_CALL to fix this issue.

But __getrandom_nocancel has been avoiding from touching errno for a
reason, see BZ 29624.  So add a __getrandom_nocancel_nostatus function
and use it in tcache_key_initialize.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Signed-off-by: Andreas K. Hüttel <dilfridge@gentoo.org>
This commit is contained in:
Xi Ruoyao
2024-01-04 21:41:20 +08:00
committed by Andreas K. Hüttel
parent f2b65a4471
commit 5a85786a90
4 changed files with 19 additions and 2 deletions

View File

@ -3139,7 +3139,9 @@ static uintptr_t tcache_key;
static void
tcache_key_initialize (void)
{
if (__getrandom_nocancel (&tcache_key, sizeof(tcache_key), GRND_NONBLOCK)
/* We need to use the _nostatus version here, see BZ 29624. */
if (__getrandom_nocancel_nostatus (&tcache_key, sizeof(tcache_key),
GRND_NONBLOCK)
!= sizeof (tcache_key))
{
tcache_key = random_bits ();