Skip to content

Commit 4ec2349

Browse files
committed
Review update
1 parent ba742cb commit 4ec2349

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

src/lib.rs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,16 +226,29 @@ cfg_if! {
226226
} else if #[cfg(all(
227227
not(feature = "disable_urandom_fallback"),
228228
any(
229-
// Rust supports Android API level 19 (KitKat) [0], while `getrandom(2)`
230-
// was added only in level 23 (Marshmallow).
229+
// Rust supports Android API level 19 (KitKat) [0] and the next upgrade targets
230+
// level 21 (Lollipop) [1], while `getrandom(2)` was added only in
231+
// level 23 (Marshmallow). Note that it applies only to the "old" `target_arch`es,
232+
// RISC-V Android targets sufficiently new API level, same will apply for potential
233+
// new Android `target_arch`es.
231234
// [0]: https://blog.rust-lang.org/2023/01/09/android-ndk-update-r25.html
232-
target_os = "android",
235+
// [1]: https://github.com/rust-lang/rust/pull/120593
236+
all(
237+
target_os = "android",
238+
any(
239+
target_arch = "aarch64",
240+
target_arch = "arm",
241+
target_arch = "x86",
242+
target_arch = "x86_64",
243+
),
244+
),
245+
// Only on these `target_arch`es Rust supports Linux kernel versions (3.2+)
246+
// that precede the version (3.17) in which `getrandom(2)` was added:
247+
// https://doc.rust-lang.org/stable/rustc/platform-support.html
233248
all(
234249
target_os = "linux",
235-
// Only on these `target_arch`es Rust supports Linux kernel versions (3.2+)
236-
// that precede the version (3.17) in which `getrandom(2)` was added:
237-
// https://doc.rust-lang.org/stable/rustc/platform-support.html
238250
any(
251+
target_arch = "aarch64",
239252
target_arch = "arm",
240253
target_arch = "powerpc",
241254
target_arch = "powerpc64",

src/linux_android_with_fallback.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ fn is_getrandom_available() -> bool {
2020
if getrandom_syscall(&mut []) < 0 {
2121
match last_os_error().raw_os_error() {
2222
Some(libc::ENOSYS) => false, // No kernel support
23+
// The fallback on EPERM is intentionally not done on Android since this workaround
24+
// seems to be needed only for specific Linux-based products that aren't based
25+
// on Android. See https://github.com/rust-random/getrandom/issues/229.
2326
#[cfg(target_os = "linux")]
24-
Some(libc::EPERM) => false, // Blocked by seccomp
27+
Some(libc::EPERM) => false, // Blocked by seccomp
2528
_ => true,
2629
}
2730
} else {

0 commit comments

Comments
 (0)