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 BD4673856DDD for ; Tue, 2 Aug 2022 09:44:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BD4673856DDD 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-588-1E7VAuDuNw2S9Kt9vYFivQ-1; Tue, 02 Aug 2022 05:44:17 -0400 X-MC-Unique: 1E7VAuDuNw2S9Kt9vYFivQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 08A0D85A584; Tue, 2 Aug 2022 09:44:17 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.194.59]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 328382166B2A; Tue, 2 Aug 2022 09:44:15 +0000 (UTC) From: Florian Weimer To: Yann Droneaud Cc: libc-alpha@sourceware.org Subject: Re: Using arc4random() in the library (was Re: [PATCH] malloc: Use __getrandom_nocancel during tcache initiailization) References: <87fsigp7y9.fsf@oldenburg.str.redhat.com> <2cce82a8-5a6c-f555-4592-1fae54dc2d0e@opteya.com> Date: Tue, 02 Aug 2022 11:44:14 +0200 In-Reply-To: <2cce82a8-5a6c-f555-4592-1fae54dc2d0e@opteya.com> (Yann Droneaud's message of "Tue, 2 Aug 2022 11:04:25 +0200") Message-ID: <87r11z6kup.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.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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: Tue, 02 Aug 2022 09:44:22 -0000 * Yann Droneaud: > Hi, > > Le 01/08/2022 =C3=A0 12:35, Florian Weimer via Libc-alpha a =C3=A9crit=C2= =A0: >> 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_NONBL= OCK) > > > Is this a place where arc4random() could be used in the future ? > > aka. is there a policy on using arc4random() instead of getrandom() in > the library ? Currently there is not much of a difference between arc4random_buf and getrandom on current kernels. We'll see where getrandom is heading (and if vDSO acceleration will end up in the kernel), and if it will involve malloc in some way. If it does, we can't use arc4random from malloc, we have to use the system call. Thanks, Florian