[PATCH] Linux: Also check for 0 return value from vDSO gerandom probe
Florian Weimer
fweimer@redhat.com
Sun Dec 15 12:55:32 GMT 2024
* Jason A. Donenfeld:
> On Sun, Dec 15, 2024 at 12:56:02PM +0100, Florian Weimer wrote:
>> As of Linux 6.13, there is no code in the vDSO that declines this
>> initialization request with the special ~0UL state size. If the vDSO
>> has the function, the call succeeds and returns 0. It's expected
>> that the code would follow the “a negative value indicating an error”
>> convention, as indicated in the __cvdso_getrandom_data function
>> comment, so that INTERNAL_SYSCALL_ERROR_P on glibc's side would return
>> true. Yet this commit treats all non-zero values as error indicators.
>>
>> Fixes commit 4f5704ea347e52ac3f272d1341da10aed6e9973e ("powerpc: Use
>> correct procedure call standard for getrandom vDSO call (bug 32440)").
>>
>> Tested on x86_64-linux-gnu.
>>
>> ---
>> sysdeps/unix/sysv/linux/getrandom.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/sysdeps/unix/sysv/linux/getrandom.c b/sysdeps/unix/sysv/linux/getrandom.c
>> index 0dc8fa6e65..815f4b1f4a 100644
>> --- a/sysdeps/unix/sysv/linux/getrandom.c
>> +++ b/sysdeps/unix/sysv/linux/getrandom.c
>> @@ -246,7 +246,7 @@ __getrandom_early_init (_Bool initial)
>> } params;
>> long int ret = INTERNAL_VSYSCALL_CALL (GLRO(dl_vdso_getrandom),
>> 5, NULL, 0, 0, ¶ms, ~0UL);
>> - if (! INTERNAL_SYSCALL_ERROR_P (ret))
>> + if (! INTERNAL_SYSCALL_ERROR_P (ret) && ret == 0)
>
> Checking for both seems confusing and not necessary Just check for ==0?
We used to have support for true out-of-band signalling and could handle
the “error, but the error code is zero” case as an actual error (but
with no way to report it following POSIX rules), but that's gone with
the single return value from INTERNAL_VSYSCALL_CALL.
I'll change it to ret == 0.
Thanks,
Florian
More information about the Libc-alpha
mailing list