Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assume getrandom on Linux #15040

Merged

Conversation

ysbaddaden
Copy link
Contributor

The getrandom(2) syscall was added in 2017 and at the time we couldn't expect the glibc 2.25 to be widely available, but we're in 2024 now, and even Ubuntu 18.04 LTS that is now EOL had a compatible glibc release (2.27). I assume musl-libc also added the symbol at the same time.

We can simplify the implementation to assume getrandom is available, which avoids the initial check, initialization and fallback to urandom. We still fallback to urandom at compile time when targeting android api level < 28 (we support 24+).

An issue is that executables will now expect glibc 2.25+ (for example), though the interpreter already did.

Related to #15034.

@straight-shoota
Copy link
Member

https://crystal-lang.org/reference/1.13/syntax_and_semantics/platform_support.html list already as a requirement GNU libc 2.26+. However, I have no idea what's the driving factor 🙈 I added the version information in crystal-lang/crystal-book#678, but I don't recall where the number comes from.

@ysbaddaden
Copy link
Contributor Author

We also expect kernel 2.6.18 to be compatible, but getrandom was added in 3.17 which means it depends on how the libc symbol is implemented —does it fallback to urandom, does it fail?

src/crystal/system/unix/getrandom.cr Outdated Show resolved Hide resolved
src/crystal/system/unix/getrandom.cr Outdated Show resolved Hide resolved
src/crystal/system/unix/getrandom.cr Outdated Show resolved Hide resolved
@straight-shoota straight-shoota changed the title Assume getrandom on Linux Assume getrandom on Linux Oct 7, 2024
@straight-shoota straight-shoota added this to the 1.15.0 milestone Oct 8, 2024
@straight-shoota straight-shoota merged commit 8b4fe41 into crystal-lang:master Oct 10, 2024
66 checks passed
@ysbaddaden ysbaddaden deleted the refactor/linux-getrandom branch October 10, 2024 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants