[PATCH 2/2] linux: use __getrandom_nocancel in getentropy

Cristian Rodríguez cristian@rodriguez.im
Sat Feb 8 17:05:19 GMT 2025


It must use the VDSO implementation if available instead of a raw
syscall.

Signed-off-by: Cristian Rodríguez <cristian@rodriguez.im>
---
 sysdeps/unix/sysv/linux/getentropy.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/getentropy.c b/sysdeps/unix/sysv/linux/getentropy.c
index a62c9fb099..2134a32ae4 100644
--- a/sysdeps/unix/sysv/linux/getentropy.c
+++ b/sysdeps/unix/sysv/linux/getentropy.c
@@ -21,7 +21,7 @@
 #include <errno.h>
 #include <unistd.h>
 #include <sysdep.h>
-
+#include <not-cancel.h>
 /* Write LENGTH bytes of randomness starting at BUFFER.  Return 0 on
    success and -1 on failure.  */
 int
@@ -42,7 +42,7 @@ getentropy (void *buffer, size_t length)
   while (buffer < end)
     {
       /* NB: No cancellation point.  */
-      ssize_t bytes = INLINE_SYSCALL_CALL (getrandom, buffer, end - buffer, 0);
+      ssize_t bytes = __getrandom_nocancel (buffer, end - buffer, 0);
       if (bytes < 0)
         {
           if (errno == EINTR)
-- 
2.48.1



More information about the Libc-alpha mailing list