chore: Generate UUIDs on Android below API level 28 #460
All Vouch review confidence checks passed
Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 343 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.349
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #460"
general
weight: 0.35
fuzzybinary
refs: RUM-20301
## Context
We want the code in
typesto be portable to other platforms and build toolchains, even those wheredd-sdk-cppis not supported in full. This is one in a series of PRs addressing minor portability issues.This one deals with supporting the
getrandomsyscall on older Android API versions.## Problem
On Linux, we generate random UUIDs with a call to
getrandom(). If that syscall isn't supported by the kernel (ENOSYS) or isn't permitted (EPERM), we read/dev/urandominstead. If the kernel's random pool isn't initialized yet, we fall back to a non-cryptographic source rather than block.On Linux systems with glibc 2.25 or newer, the C library provides a
getrandom()wrapper, which is what our current implementation uses.Android's C standard library implementation, bionic, declares
getrandom()from API Level 28 onward.We want to be able to compile
typesfor Android API Level 26 at a minimum. With our current implementation, this means that we'd get a compilation error when targeting API 26 or 27, since bionic does not definegetrandom()at those API levels.## Solution
As of this PR, we have now a fallback path: our Linux
UuidGeneratefunction will usesyscall(SYS_getrandom, ...)on Android builds targeting API levels below 28.This fallback implementation will only be compiled into builds targeting Android 8.0 (API Level 26) and Android 8.1 (API Level 27). On those Android versions, the seccomp filter applied to all apps (bionic's
libc/SECCOMP_WHITELIST.TXTatandroid-8.0.0_r1andandroid-8.1.0_r1) allows thegetrandomsyscall, as do later versions, whose bionicgetrandom()makes the same syscall. This matters because the filter doesn't make a disallowed syscall fail withEPERM: it kills the app withSIGSYS.If the kernel does not support
getrandom, the call tosyscall()is still safe: it will fail withENOSYS, and the same exact runtime fallback behavior described above will take effect.## Testing
uuid_linux.cppcompiles at API level 26 for arm64-v8a and x86_64.I verified the claims above on the Android versions in question. A minimal app built at API level 26 calls
UuidGeneratefrom this branch'suuid_linux.cpp. It ran on Android 8.0 and 8.1 arm64 emulators, and on an Android 14 phone. On each one:Seccomp: 2in/proc/self/status).swapoff, which the filter blocks, was killed withSIGSYS, showing that the filter is enforced.syscall(SYS_getrandom, ...)returned 16 bytes, andUuidGenerateproduced distinct version 4 UUIDs.The
ENOSYSfallback wasn't exercised, since each device's kernel has thegetrandomsyscall.