From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 8A49C3858D39 for ; Mon, 1 Aug 2022 10:35:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8A49C3858D39 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-568-WtVZcUNMM-O5_275akiisw-1; Mon, 01 Aug 2022 06:35:45 -0400 X-MC-Unique: WtVZcUNMM-O5_275akiisw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D89A3811E75 for ; Mon, 1 Aug 2022 10:35:44 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 44EE42026D64 for ; Mon, 1 Aug 2022 10:35:44 +0000 (UTC) From: Florian Weimer To: libc-alpha@sourceware.org Subject: [PATCH] malloc: Use __getrandom_nocancel during tcache initiailization Date: Mon, 01 Aug 2022 12:35:42 +0200 Message-ID: <87fsigp7y9.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Aug 2022 10:35:48 -0000 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. --- 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 ();