theuni
commented at 1:07 AM on May 4, 2017:
member
Yet another fallback needed for getentropy :(
When building on a newer linux machine (glibc >= 2.25), the resulting binary will fail to run on an older one (<2.25), due to missing symbols. This adds a weak symbol for our own implementation for use as a last resort.
Alternative solutions welcome.
dcousens
commented at 1:09 AM on May 4, 2017:
contributor
Alternative solutions welcome.
return 0? (aka, do nothing)
I assume we are already mixing /dev/urandom elsewhere though - if not, ACK
How about not using getentropy on Linux? It's a BSD compatibility function. The Really Good (TM) solution is using SYS_getrandom, but if that's not available, just fallback to using /dev/urandom directly.
I assume we are already mixing /dev/urandom elsewhere though.
No. getrandom / getentropy replace the need for /dev/urandom.
theuni
commented at 1:32 AM on May 4, 2017:
member
Just had a quick chat about this on IRC. I'll fix this up as discussed.
laanwj
commented at 8:16 AM on May 4, 2017:
member
Huh? we should never be using getentropy() on Linux, that's why the getrandom() syscall is called directly. What is going wrong here exactly?
Edit: ok after discussion on IRC understand, getentropy is detected on newer versions of glibc, causing that to be used. That should be avoided, the SYS_getrandom path should always be used on Linux, getentropy is for BSD.
fanquake added the label Utils and libraries on May 4, 2017
theuni force-pushed on May 4, 2017
theuni force-pushed on May 4, 2017
theuni force-pushed on May 4, 2017
random: make the DevURandom fallback available to all OSs
Additionally, ensure that getentropy uses the fallback in the event that it's
unsupported at runtime.
062c7c1541
back-compat: add getentropy stub
getentropy was added in glibc 2.25. This ensures that binaries linked against
later versions have a runtime fallback.
This fallback simply returns ENOSYS, indicating that /dev/urandom should be
used instead.
e596faf8ef
theuni
commented at 6:05 PM on May 4, 2017:
member
Updated as discussed with @sipa on IRC.
@laanwj: specifically, the problem is building against a newer glibc, and older linux kernel headers for compatibility. So getentropy() is defined, but the syscall isn't. That's what I ran into here.
Would you like to explicitly disable getentropy for linux on the build side as well?
Both this PR or just disabling getentropy on Linux are fine solutions to me.
laanwj
commented at 10:02 AM on May 5, 2017:
member
Would you like to explicitly disable getentropy for linux on the build side as well?
I don't see why we'd need it. I made the syscall-based path for Linux to avoid having to rely on any function provided by glibc (e.g. to require a certain glibc version) for kernel randomness. But I don't care deeply, as long as it works...
ryanofsky
commented at 9:12 PM on May 10, 2017:
member
utACKe596faf8efa211b3b17a555beba81a34dc68d55d. Unclear from discussion above whether there is agreement to continue allowing fallback to getentropy on linux, though IMO it makes the code cleaner to fall straight through all the available calls like this PR does (despite the need for the weak symbol workaround).
This is a metadata mirror of the GitHub repository
bitcoin/bitcoin.
This site is not affiliated with GitHub.
Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:15 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me