b30ff9539f
Upstream commit: 4bdcc1963bc2b5ba5f8e319e402d9eb2cb6096c1 - manual: make setrlimit() description less ambiguous - manual/stdio: Clarify putc and putwc - malloc: add multi-threaded tests for aligned_alloc/calloc/malloc - malloc: avoid global locks in tst-aligned_alloc-lib.c - resolv: Track single-request fallback via _res._flags (bug 31476) - resolv: Do not wait for non-existing second DNS response after error (bug 30081) - resolv: Allow short error responses to match any query (bug 31890) - elf: Fix localplt.awk for DT_RELR-enabled builds (BZ 31978) - Fix usage of _STACK_GROWS_DOWN and _STACK_GROWS_UP defines [BZ 31989] - Linux: Make __rseq_size useful for feature detection (bug 31965) - elf: Make dl-rseq-symbols Linux only - nptl: fix potential merge of __rseq_* relro symbols - s390x: Fix segfault in wcsncmp [BZ #31934] - stdlib: fix arc4random fallback to /dev/urandom (BZ 31612) - math: Provide missing math symbols on libc.a (BZ 31781) - math: Fix isnanf128 static build (BZ 31774) - math: Fix i386 and m68k exp10 on static build (BZ 31775) - math: Fix i386 and m68k fmod/fmodf on static build (BZ 31488) - posix: Fix pidfd_spawn/pidfd_spawnp leak if execve fails (BZ 31695)
33 lines
1.2 KiB
Diff
33 lines
1.2 KiB
Diff
commit a03631124602f2dcef40d46660b96d2e51c44bfd
|
|
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
|
|
Date: Fri Apr 5 10:27:29 2024 -0300
|
|
|
|
stdlib: fix arc4random fallback to /dev/urandom (BZ 31612)
|
|
|
|
The __getrandom_nocancel used by __arc4random_buf uses
|
|
INLINE_SYSCALL_CALL (which returns -1/errno) and the loop checks for
|
|
the return value instead of errno to fallback to /dev/urandom.
|
|
|
|
The malloc code now uses __getrandom_nocancel_nostatus, which uses
|
|
INTERNAL_SYSCALL_CALL, so there is no need to use the variant that does
|
|
not set errno (BZ#29624).
|
|
|
|
Checked on x86_64-linux-gnu.
|
|
|
|
Reviewed-by: Xi Ruoyao <xry111@xry111.site>
|
|
(cherry picked from commit 184b9e530e6326e668709826903b6d30dc6cac3f)
|
|
|
|
diff --git a/stdlib/arc4random.c b/stdlib/arc4random.c
|
|
index 3ae8fc130234b04d..7818cb9cf66e0f3b 100644
|
|
--- a/stdlib/arc4random.c
|
|
+++ b/stdlib/arc4random.c
|
|
@@ -51,7 +51,7 @@ __arc4random_buf (void *p, size_t n)
|
|
n -= l;
|
|
continue; /* Interrupted by a signal; keep going. */
|
|
}
|
|
- else if (l == -ENOSYS)
|
|
+ else if (l < 0 && errno == ENOSYS)
|
|
break; /* No syscall, so fallback to /dev/urandom. */
|
|
arc4random_getrandom_failure ();
|
|
}
|