Re: Support getrandom() for pg_strong_random() source

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Dagfinn Ilmari Mannsåker <ilmari(at)ilmari(dot)org>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Support getrandom() for pg_strong_random() source
Date: 2025-07-30 11:09:01
Message-ID: a6ba99bf-c5bd-4522-b25a-c817ec495644@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 22.07.25 13:11, Dagfinn Ilmari Mannsåker wrote:
> getrandom() is Linux-specific, while getentropy() is specified by POSIX
> (since 2024). It was originally introduced by OpenBSD 5.6 in 2014, and
> was added to macOS 10.12 in 2016, glibc 2.25 (same as getrandom()) in
> 2017, musl 1.1.20 and FreeBSD 12.0 in 2018, and NetBSD 10.0 in 2024
>
> Sources:
>
> https://pubs.opengroup.org/onlinepubs/9799919799/functions/getentropy.html
> https://dotat.at/@/2024-10-01-getentropy.html
>
> So I think it's more worthwhile to add support for getentropy() than
> getrandom().

The POSIX description of getentropy() says:

"The intended use of this function is to create a seed for other
pseudo-random number generators."

So using getentropy() for generating the random numbers that are passed
back to the application code would appear to be the wrong use.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Fabrice Chapuis 2025-07-30 11:09:21 Re: pg_basebackup and pg_switch_wal()
Previous Message Japin Li 2025-07-30 11:07:38 Re: [WIP]Vertical Clustered Index (columnar store extension) - take2