Skip to content

docs(fast_io): audit io_uring bgid u16 namespace exhaustion risk (#2044) - #3509

Merged
oferchen merged 2 commits into
masterfrom
feat/iouring-bgid-namespace-audit-2044
May 1, 2026
Merged

oferchen merged 2 commits into
masterfrom
feat/iouring-bgid-namespace-audit-2044

Conversation

@oferchen

@oferchen oferchen commented May 1, 2026

Copy link
Copy Markdown
Owner

Summary

Audits whether io_uring's 16-bit buffer-group identifier (bgid) can be exhausted by oc-rsync at scale (issue #2044). Findings:

  • The bgid namespace is per io_uring instance, not per-process; each RawIoUring has its own 0..=u16::MAX slot table maintained by io_uring/kbuf.c::io_register_pbuf_ring().
  • oc-rsync allocates zero bgid values in production today: BufferRing / BufferRingConfig exist at crates/fast_io/src/io_uring/buffer_ring.rs and are re-exported via crates/fast_io/src/io_uring/mod.rs:100 and crates/fast_io/src/lib.rs:155, but no caller constructs them outside unit tests.
  • Each IoUringReader / IoUringWriter / IoUringSocketReader / IoUringSocketWriter / IoUringDiskBatch owns its own RawIoUring, so any future BufferRing would naturally be one-per-fd.
  • Recommendation is option (a) "document and assert not a concern", with two guard rails: pin bgid = 0 for the primary ring per RawIoUring, and add a debug warn if any single ring crosses ~256 live buffer groups. A sketch of an allocator (option (b)) is included in case the architecture ever changes.

Guarantees

  • Docs only - the only file added is docs/audits/io-uring-bgid-namespace.md (322 lines); no code, configuration, or other docs are touched.
  • Cites real symbols - all path:line references resolve in the current tree (buffer_ring.rs:41,44,60-66,134-152,151,159,267-397,414,516-553, mod.rs:100, lib.rs:155, plus per-fd ring construction sites in file_reader.rs:60, file_writer.rs:54,81,141, socket_reader.rs:32, socket_writer.rs:32, disk_batch.rs:46,71).
  • Matches existing audit style - mirrors the structure of iouring-pipe-stdio.md, iouring-socket-sqpoll-defer-taskrun.md, and madvise-willneed-prefault.md (Summary / Current state / Risk / Recommendation / References) and stays under 500 lines.
  • Follows conventional-prefix and hyphen rules - docs(fast_io): prefix on commit and PR title, no em-dashes anywhere in the new file.

Test plan

  • tools/enforce_limits.sh clean (docs-only change, no LoC impact).
  • Markdown links in the new audit resolve (sibling-audit cross references and code path:line anchors).

@oferchen
oferchen merged commit f2c73ef into master May 1, 2026
10 checks passed
@github-actions github-actions Bot added the documentation Improvements or additions to documentation label May 1, 2026
@oferchen
oferchen deleted the feat/iouring-bgid-namespace-audit-2044 branch May 1, 2026 21:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant