[PATCH 8/8] elf: Scrub and reseed the AT_RANDOM bytes after deriving the guards (BZ 34197)

DJ Delorie dj@redhat.com
Thu Jun 11 20:25:30 GMT 2026


Adhemerval Zanella Netto <adhemerval.zanella@linaro.org> writes:
>>> -  _dl_random = NULL;
>>> +  _dl_reseed_random (&_dl_random);
>> 
>> can _dl_reseed_random ever be called twice in the same program?  This
>> second one happens when we load audit modules, but you don't test that
>> case, and I wonder if calling it twice might result in NULL guards, or
>> mismatched ones...
>
> The security_init cannot be called twice: in dl_main, need_security_init is
> set 'false' after the early audit-path call. The later call around line 2020
> is gated on need_security_init, and the __libc_start_main's call is only for
> !SHARED.
>
> But I think even if a double call were ever introduced, the function should be
> safe. The if (*dl_random == NULL) return; early-return makes the second call a 
> no-op.

I was more worried about the call in csu/libc-start.c and the call in
elf/rtld.c both affecting the same process.



More information about the Libc-alpha mailing list