tunable request: glibc.random.nondeterministic or similar

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Mon Nov 2 13:03:37 GMT 2026



On 29/10/26 10:31, Cristian Rodriguez wrote:
> Hi:
> 
> It would be really nice if  a new tunable, tentatively named
> glibc.random.nondeterministic, or glibc.random.secure could become
> available.
> 
> In short, when the tunable is set, in every random number function and
> the various seeds and states  are ignored and calls translate to
> suitable arc4random() arc4random_uniform() calls.
> 
> Currently I use an interposer shared library for this purpose but I'll
> be the first to say it's a horrendous way to do it.
> 
> Since this behaviour is obviously non-standard and can break unknown
> software, the tunable must be off by default.
> 
> A lot of software still uses the `rand` and `random` interfaces,
> assuming they have properties they do not. most annoying ones are
> shared libraries that call srand* at any time and will perturb the
> process global state.

I know that OpenBSD went this way, but they do not really care for backward
compatibility, they have much less users, and they usually patch their
codebase to accommodate their changes.

The recent added security-related tunable are focused on enforce opt-in
hardening that might or not be supported by the hardware (BTI, GCS, CET),
or security hardening that binary might not be built with (my
'elf: Add loader hardening tunables' [1]).

Adding semantic change tunables might would add extra constraint that
might make it an ABI de-facto, since eventually users will rely on it
(Hyrum law). I do not want to go in this way.

So I am not sure about this, it adds a lot of other issues:

1. It silently breaks things the C and POSIX standards guarantee.

2. The scope is too coarse, where GLIBC_TUNABLES is inherited by every
   child process. Setting it for one program also changes build steps, 
   test generators and anything else in the process tree. OpenBSD paired
   its change with srand_deterministic(), but I don't want to do on this
   way either.

3. There is a performance cliff, specially for ABIs without getrandom
   vDSO support.

4. Functions that cannot fail today would be able to abort or block:

   - rand() never fails, never blocks and never enters the kernel.
   - arc4random calls __libc_fatal in two cases:
     - getrandom fails with anything other than ENOSYS (there is still
       a bug report stating some kernel might fail in this case [1])
     - The ENOSYS fallback can't open /dev/random or /dev/urandom, as
       in a chroot or minimal container without /dev.
   - The vDSO path also maps memory for per-thread state.

5. It is a weak security feature, which makes the name glibc.random.secure
   misleading.
  - The program is still broken on every other libc, every older glibc
    and every system without the setting.

6. It brings specification and maintenance work.
  - What initstate/setstate/seed48 return when the state is ignored;
  - Whether lcong48 parameters still mean anything;
  - How many random bits drand48's result in [0, 1) should carry; the
    48 a seeded call produces, or the 53 a double holds;
  - Keeping the signed range of jrand48.

I think we should keep promoting getrandom/arc4random and fix the users
instead if they are still using srand* assuming some secure semantic.

[1] https://patchwork.sourceware.org/project/glibc/list/?series=68776
[2] https://sourceware.org/bugzilla/show_bug.cgi?id=32335


More information about the Libc-alpha mailing list