Repository navigation
feat: add detect_rootless_container helper for SQPOLL gate (SQP-LAND.3) - #5554
Merged
Merged
Conversation
Adds a pure, side-effect-free `detect_rootless_container()` helper to `fast_io` that probes the well-known rootless-container markers in priority order: 1. `/proc/self/uid_map` non-identity (user namespace) 2. `/run/.containerenv` (Podman) 3. `/.dockerenv` (Docker) The outcome is cached in a `OnceLock<bool>` so the probe runs at most once per process. On non-Linux targets the helper is a compile-time constant `false` because SQPOLL has no analogue outside Linux io_uring. Detection logic lives in an internal `probe_with_reader` taking injectable readers so unit tests can exercise every signal path without touching the real filesystem. Tests cover host identity, multi-line maps, narrowed ranges, marker fall-through, signal priority, single-read caching, and the non-Linux stub. This PR ships the helper only - the call-site wiring into `IoUringConfig::build_ring` is reserved for SQP-LAND.4. See `docs/audits/sqpoll-rootless-detection-status.md` (SQP-LAND.1) for the gap analysis that motivates the helper.
3 of 4 tasks
is_identity_uid_map was returning false for empty /proc/self/uid_map contents, which made probe_with_reader short-circuit to container detected before checking the marker-file probes. Empty contents carry no signal, so the probe must fall through to /run/.containerenv and /.dockerenv instead of falsely reporting a user namespace. Aligns the helper with the empty_uid_map_falls_through unit test contract: an empty uid_map is not a positive container signal.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
…3) (#5554) * feat: add detect_rootless_container helper for SQPOLL gate (SQP-LAND.3) Adds a pure, side-effect-free `detect_rootless_container()` helper to `fast_io` that probes the well-known rootless-container markers in priority order: 1. `/proc/self/uid_map` non-identity (user namespace) 2. `/run/.containerenv` (Podman) 3. `/.dockerenv` (Docker) The outcome is cached in a `OnceLock<bool>` so the probe runs at most once per process. On non-Linux targets the helper is a compile-time constant `false` because SQPOLL has no analogue outside Linux io_uring. Detection logic lives in an internal `probe_with_reader` taking injectable readers so unit tests can exercise every signal path without touching the real filesystem. Tests cover host identity, multi-line maps, narrowed ranges, marker fall-through, signal priority, single-read caching, and the non-Linux stub. This PR ships the helper only - the call-site wiring into `IoUringConfig::build_ring` is reserved for SQP-LAND.4. See `docs/audits/sqpoll-rootless-detection-status.md` (SQP-LAND.1) for the gap analysis that motivates the helper. * fix: treat empty uid_map as no-signal in rootless container probe is_identity_uid_map was returning false for empty /proc/self/uid_map contents, which made probe_with_reader short-circuit to container detected before checking the marker-file probes. Empty contents carry no signal, so the probe must fall through to /run/.containerenv and /.dockerenv instead of falsely reporting a user namespace. Aligns the helper with the empty_uid_map_falls_through unit test contract: an empty uid_map is not a positive container signal.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
fast_io::detect_rootless_container()- a pure, side-effect-free helper that probes well-known markers (/proc/self/uid_map,/run/.containerenv,/.dockerenv) to detect rootless container / user-namespace environments where SQPOLL is structurally unavailable.OnceLock<bool>; probe runs at most once per process.falsestub on every other target.IoUringConfig::build_ringto skip the doomed SQPOLL attempt and surface context-rich diagnostics.Motivation and design rationale are documented in
docs/audits/sqpoll-rootless-detection-status.md(SQP-LAND.1), which identified the rootless detection gap atcrates/fast_io/src/io_uring/config.rs:357-386.Test plan
detect_rootless_container(). Helper enum types and detection logic stay private to the module.