[PATCH 8/8] elf: Scrub and reseed the AT_RANDOM bytes after deriving the guards (BZ 34197)
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Thu Jun 11 20:36:05 GMT 2026
On 11/06/26 17:25, DJ Delorie wrote:
>
> 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.
>
Right, the csu/libc-start.c is only for static objects. The static-dlopen edge
case also does trigger the elf/rtld.c initialization, and that's why we have
__rtld_static_init to handle the requires missing pieces.
More information about the Libc-alpha
mailing list