public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Yann Droneaud <ydroneaud@opteya.com>
Cc: libc-alpha@sourceware.org
Subject: Re: Using arc4random() in the library (was Re: [PATCH] malloc: Use __getrandom_nocancel during tcache initiailization)
Date: Tue, 02 Aug 2022 11:44:14 +0200	[thread overview]
Message-ID: <87r11z6kup.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <2cce82a8-5a6c-f555-4592-1fae54dc2d0e@opteya.com> (Yann Droneaud's message of "Tue, 2 Aug 2022 11:04:25 +0200")

* Yann Droneaud:

> Hi,
>
> Le 01/08/2022 à 12:35, Florian Weimer via Libc-alpha a écrit :
>> 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 <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)
>
>
> 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


  reply	other threads:[~2022-08-02  9:44 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-01 10:35 [PATCH] malloc: Use __getrandom_nocancel during tcache initiailization Florian Weimer
2022-08-01 13:42 ` Adhemerval Zanella Netto
2022-08-02  9:04 ` Using arc4random() in the library (was Re: [PATCH] malloc: Use __getrandom_nocancel during tcache initiailization) Yann Droneaud
2022-08-02  9:44   ` Florian Weimer [this message]
2022-08-03 13:50     ` Cristian Rodríguez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r11z6kup.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=ydroneaud@opteya.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).