[PATCH 2/2] linux: use __getrandom_nocancel in getentropy
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Tue Nov 25 16:11:56 GMT 2025
On 22/11/25 11:35, Cristian Rodríguez wrote:
> On Wed, Feb 12, 2025 at 6:40 PM Cristian Rodríguez
> <cristian@rodriguez.im> wrote:
>>
>> On Wed, Feb 12, 2025 at 9:57 AM Adhemerval Zanella Netto
>> <adhemerval.zanella@linaro.org> wrote:
>>
>>>
>>> And remove both sysdeps/mach/hurd/getentropy.c and sysdeps/unix/sysv/linux/getentropy.c
>>
>>
>> OK, Im gonna post an improved version later.
>
> Went back to this again.. what to do with GETENTROPY_MAX now.. ? Posix says
>
> {GETENTROPY_MAX}The maximum value of the length argument in calls to
> the getentropy() function.
> Minimum Acceptable Value: 256
>
> However since:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e3c1c4fd9e6d14059ed93ebfe15e1c57793b1a05
>
> The kernel special case is PAGE_SIZE not 256..and the special 256
> never worked in the first place..
>
> So at least for the linux parts
>
> - GETENTROPY_MAX == 256 ? and forget such a limit will not be enforced?
> - GETENTROPY_MAX == getpagesize() ? because PAGE_SIZE is not fixed in
> userspace?
> - Do not define it all.. make the wrapper return EINVAL if bigger than
> a pagesize to match the current kernel special case.
>
> looking forward to your inputs.
Can we assume 'GETENTROPY_MAX == getpagesize()' works for older kernels than 5.18?
We did changed PTHREAD_STACK_MIN to be dynamic based on sysconf(_SC_THREAD_STACK_MIN)
(5d98a7dae955bafa6740c26eaba9c86060ae0344), so I think we will need something
similar to make GETENTROPY_MAX based on the system page size.
This is really a lot of complexity, and I am not sure it users will really
require GETENTROPY_MAX > 256 for most usercases.
More information about the Libc-alpha
mailing list