1feee8
commit 7187efd0aa270c83c428ea6cd0e1cffc34b41a74
1feee8
Author: Florian Weimer <fweimer@redhat.com>
1feee8
Date:   Mon Aug 1 15:49:07 2022 +0200
1feee8
1feee8
    malloc: Use __getrandom_nocancel during tcache initiailization
1feee8
    
1feee8
    Cancellation currently cannot happen at this point because dlopen
1feee8
    as used by the unwind link always performs additional allocations
1feee8
    for libgcc_s.so.1, even if it has been loaded already as a dependency
1feee8
    of the main executable.  But it seems prudent not to rely on this
1feee8
    quirk.
1feee8
    
1feee8
    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
1feee8
1feee8
diff --git a/malloc/malloc.c b/malloc/malloc.c
1feee8
index 2edb469d5dbf1203..375f50f5db13e234 100644
1feee8
--- a/malloc/malloc.c
1feee8
+++ b/malloc/malloc.c
1feee8
@@ -256,6 +256,7 @@
1feee8
 /* For tcache double-free check.  */
1feee8
 #include <random-bits.h>
1feee8
 #include <sys/random.h>
1feee8
+#include <not-cancel.h>
1feee8
 
1feee8
 /*
1feee8
   Debugging:
1feee8
@@ -3025,7 +3026,7 @@ static uintptr_t tcache_key;
1feee8
 static void
1feee8
 tcache_key_initialize (void)
1feee8
 {
1feee8
-  if (__getrandom (&tcache_key, sizeof(tcache_key), GRND_NONBLOCK)
1feee8
+  if (__getrandom_nocancel (&tcache_key, sizeof(tcache_key), GRND_NONBLOCK)
1feee8
       != sizeof (tcache_key))
1feee8
     {
1feee8
       tcache_key = random_bits ();