From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2178) id 3AA30385841A; Mon, 1 Aug 2022 13:50:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3AA30385841A Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Florian Weimer To: glibc-cvs@sourceware.org Subject: [glibc] malloc: Use __getrandom_nocancel during tcache initiailization X-Act-Checkin: glibc X-Git-Author: Florian Weimer X-Git-Refname: refs/heads/master X-Git-Oldrev: 032712621fd376def8ee4c1d997b414f29a30108 X-Git-Newrev: 7187efd0aa270c83c428ea6cd0e1cffc34b41a74 Message-Id: <20220801135052.3AA30385841A@sourceware.org> Date: Mon, 1 Aug 2022 13:50:52 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Aug 2022 13:50:52 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=7187efd0aa270c83c428ea6cd0e1cffc34b41a74 commit 7187efd0aa270c83c428ea6cd0e1cffc34b41a74 Author: Florian Weimer Date: Mon Aug 1 15:49:07 2022 +0200 malloc: Use __getrandom_nocancel during tcache initiailization 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 Diff: --- malloc/malloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/malloc/malloc.c b/malloc/malloc.c index bd3c76ed31..430d204156 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -254,6 +254,7 @@ /* For tcache double-free check. */ #include #include +#include /* 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 ();