]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
malloc: Use __getrandom_nocancel during tcache initiailization
authorFlorian Weimer <fweimer@redhat.com>
Mon, 1 Aug 2022 13:49:07 +0000 (15:49 +0200)
committerFlorian Weimer <fweimer@redhat.com>
Mon, 1 Aug 2022 13:50:09 +0000 (15:50 +0200)
Cancellation currently cannot happen at this point because dlopen
as used by the unwind link always performs additional allocations
for libgcc_s.so.1, even if it has been loaded already as a dependency
of the main executable.  But it seems prudent not to rely on this
quirk.

Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
malloc/malloc.c

index bd3c76ed310c4c2cbf8f141eb6b76182926cf24a..430d20415648e36aba842cfbf919926d2bbe69be 100644 (file)
 /* For tcache double-free check.  */
 #include <random-bits.h>
 #include <sys/random.h>
+#include <not-cancel.h>
 
 /*
   Debugging:
@@ -3153,7 +3154,7 @@ static uintptr_t tcache_key;
 static void
 tcache_key_initialize (void)
 {
-  if (__getrandom (&tcache_key, sizeof(tcache_key), GRND_NONBLOCK)
+  if (__getrandom_nocancel (&tcache_key, sizeof(tcache_key), GRND_NONBLOCK)
       != sizeof (tcache_key))
     {
       tcache_key = random_bits ();