← Back to Pull requests

chore: Generate UUIDs on Android below API level 28 #460

Closed
unknown closed this pull request without merging on Nov 20, 2026 22:09 UTC
View on GitHub
unknown unknown commented on Nov 20, 2026 18:25 UTC
Author

refs: RUM-20301

## Context

We want the code in types to be portable to other platforms and build toolchains, even those where dd-sdk-cpp is not supported in full. This is one in a series of PRs addressing minor portability issues.

This one deals with supporting the getrandom syscall 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/urandom instead. 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 types for 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 define getrandom() at those API levels.

## Solution

As of this PR, we have now a fallback path: our Linux UuidGenerate function will use syscall(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.TXT at android-8.0.0_r1 and android-8.1.0_r1) allows the getrandom syscall, as do later versions, whose bionic getrandom() makes the same syscall. This matters because the filter doesn't make a disallowed syscall fail with EPERM: it kills the app with SIGSYS.

If the kernel does not support getrandom, the call to syscall() is still safe: it will fail with ENOSYS, and the same exact runtime fallback behavior described above will take effect.

## Testing

uuid_linux.cpp compiles 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 UuidGenerate from this branch's uuid_linux.cpp. It ran on Android 8.0 and 8.1 arm64 emulators, and on an Android 14 phone. On each one:

  • The app process ran under a seccomp filter (Seccomp: 2 in /proc/self/status).

  • A forked child that called swapoff, which the filter blocks, was killed with SIGSYS, showing that the filter is enforced.

  • syscall(SYS_getrandom, ...) returned 16 bytes, and UuidGenerate produced distinct version 4 UUIDs.
  • The ENOSYS fallback wasn't exercised, since each device's kernel has the getrandom syscall.

    Diff: 343 lines (+257 / -86) across 4 files Reviewer: fuzzybinary Review duration: 223m
    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
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.3% (MEDIUM) · Higher = larger blast radius
    42.3%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.7% · Safe to merge
    16.7%