[PATCH] elf: Do not scrub AT_RANDOM to a constant when reseeding fails (BZ 34197)

Florian Weimer fweimer@redhat.com
Wed Jun 17 07:24:20 GMT 2026


* Adhemerval Zanella:

> _dl_reseed_random zeroed the AT_RANDOM bytes before refilling them with
> getrandom (GRND_NONBLOCK).  That call is best-effort and can write nothing
> (e.g. before the kernel entropy pool is initialized early at boot), leaving
> the 16 bytes as a constant zero.
>
> Since the value is exposed through getauxval (AT_RANDOM), this traded a
> potential guard leak for a guaranteed predictable value.
>
> Drop the memset and overwrite the bytes in place instead.  The generic
> version now just drops the pointer (it is not used anywhere).
>
> Checked on x86_64-linux-gnu and i686-linux-gnu.
> ---
>  sysdeps/generic/dl-reseed-random.h         |  8 +++-----
>  sysdeps/unix/sysv/linux/dl-reseed-random.h | 17 +++++++++--------
>  2 files changed, 12 insertions(+), 13 deletions(-)

Looks okay to me.

Reviewed-by: Florian Weimer <fweimer@redhat.com>

Thanks,
Florian



More information about the Libc-alpha mailing list