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

Conditionally disable file fallback for Android and Linux #396

Merged
merged 2 commits into from
Mar 27, 2024

Conversation

newpavlov
Copy link
Member

@newpavlov newpavlov commented Feb 19, 2024

The file fallback is left enabled for Android targets and for Linux targets which support pre-3.17 kernels.

This PR also adds linux_disable_fallback crate feature and removes catching of EPERM during getrandom availability check on Android targets.

Closes #376
Closes #229

cc @briansmith

@newpavlov newpavlov changed the title Disable file fallback for Android and Linux outside of whitelisted target_arches Conditioanlly disable file fallback for Android and Linux Feb 19, 2024
src/lib.rs Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
src/linux_with_fallback.rs Outdated Show resolved Hide resolved
src/linux_android.rs Outdated Show resolved Hide resolved
src/linux_android.rs Show resolved Hide resolved
@newpavlov newpavlov changed the title Conditioanlly disable file fallback for Android and Linux Conditionally disable file fallback for Android and Linux Feb 21, 2024
src/lib.rs Show resolved Hide resolved
// getrandom(2) was introduced in Linux 3.17
static HAS_GETRANDOM: LazyBool = LazyBool::new();
if HAS_GETRANDOM.unsync_init(is_getrandom_available) {
sys_fill_exact(dest, getrandom_syscall)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to contradict my earlier suggestion, but I think I have a better one: Let's change this line to linux_android::getrandom_inner(dest). This way, it will crystal clear that the logic is EXACTLY the same as the no-fallback case. This would also allow you to keep getrandom_syscall in linux_android, which I think would be better than putting it in libc_util.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need getrandom_syscall for checking getrandom availability, so I think the current solution is fine.

src/linux_android_with_fallback.rs Outdated Show resolved Hide resolved
src/lib.rs Outdated Show resolved Hide resolved
@newpavlov
Copy link
Member Author

@josephlr WDYT?

Copy link
Member

@josephlr josephlr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good! Thanks for working on this.

My only concerns are with how the new Cargo feature should work. If you want, you can merge the rest of this and we can discuss in a followup PR (or we can discuss it here).

Cargo.toml Outdated Show resolved Hide resolved
@newpavlov
Copy link
Member Author

My only concerns are with how the new Cargo feature should work.

I think we can discuss it here. It looks like the Nightly is broken on some targets which causes breakage of some CI jobs, so I do not plan to merge it right away.

@newpavlov
Copy link
Member Author

The CI failures are caused by Nightly issues and not relevant to this PR, so we can merge it.

@newpavlov newpavlov merged commit 8ffd43e into master Mar 27, 2024
48 of 51 checks passed
@newpavlov newpavlov deleted the whitelist_fallback branch March 27, 2024 12:46
@newpavlov newpavlov mentioned this pull request Apr 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants