Skip to content

fix(selene-manager): harden multi-rank packed handling, protocol validation, and resource reclamation - #612

Merged
yatesdr merged 1 commit into
NVIDIA:mainfrom
yatesdr:fix/selene-manager-hardening
Nov 29, 2026
Merged

yatesdr merged 1 commit into
NVIDIA:mainfrom
yatesdr:fix/selene-manager-hardening

Conversation

@yatesdr

@yatesdr yatesdr commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Why this change is needed

Several selene-manager paths accepted unvalidated peer metadata or multi-process packed operations that could cause out-of-bounds arena reads/writes, panics, or permanent slot and connection resource leaks (beyond the items already landed in #607):

  • Multi-process (world >= 2) packed PutBegin and PinAck grants sized an arena extent to compressed bytes while passing uncompressed window lengths to pass::run or concurrent rank writers.
  • validate_scope allowed unbounded rank counts and record sizes; store.rs used panicking next_power_of_two; claims.rs planned window vectors before validating reservation and max_pages bounds; and windows::plan could overflow first_page + pages.
  • Rootless fallback replacement left stale parent links in Index; evict_accounted could evict page-only ancestors with active readers; session_claims_lost leaked terminal remote-channel Pinned exports on source disconnect; idle scopes grew unbounded; agent_fence_by_id could misresolve rank 0; rank-0 reconnect did not check scope/rank secret compatibility; watch_pid did not retry EINTR or fall back when pidfd_open is unavailable; --listen TLS handshakes were uncapped and untimed; and control.rs aborted pool_task before calling hub.shutdown().

Hardening these checks directly inside selene-manager and selene/src/shared/index.rs closes every crash, OOB, DoS, and leak vector without changing wire compatibility.

What changed

  • Multi-process packed safety (selene-manager/src/pool/store_bridge.rs, selene-manager/src/pool/claims.rs): Reject multi-process (world >= 2) packed PutBegin and PinAck grants cleanly.
  • Bounds & DoS validation (selene-manager/src/pool/mod.rs, selene-manager/src/store.rs, selene-manager/src/pool/claims.rs, selene-manager/src/pool/windows.rs): Cap scopes at 64 ranks and 1 TiB record sizes in validate_scope; use checked_next_power_of_two in store.rs; verify reserved_bytes (NoWindows) and max_pages (CopyError) before allocating PlannedWindow vectors; check first_page.checked_add(pages) and checked arithmetic in windows::plan.
  • Tree topology & eviction safety (selene/src/shared/index.rs, selene-manager/src/store.rs): Add Index::reparent_to_root and invoke it in publish_put when rootless fallback converts a linked replacement to root; guard !node.location.reading() in evict_accounted.
  • Reclamation, auth, TLS, and shutdown (selene-manager/src/pool/claims.rs, selene-manager/src/pool/ranks.rs, selene-manager/src/pool/core.rs, selene-manager/src/local.rs, selene-manager/src/control.rs): Reclaim terminal remote-channel Pinned exports in session_claims_lost; bound and prune idle scopes (MAX_SCOPES = 64); resolve rank-agent fences via aid; verify scope and rank secrets across rank-0 reconnect; retry EINTR and fall back to kill(pid, 0) polling in watch_pid; cap --listen TLS handshakes at 64 concurrent with a 5s timeout; invoke hub.shutdown() before pool_task.abort().
  • Unit tests: Added reparent_to_root_detaches_old_parent_and_updates_tail_pages, validate_scope_rejects_more_than_64_ranks_and_oversize_records, and plan_rejects_first_page_u32_overflow.

Expected benefit and measured result

selene-manager safely rejects malformed or unsupported multi-process packed requests, resists oversize-geometry DoS inputs, maintains consistent Index parent links across rootless replacements, bounds idle scope memory and TLS handshakes, and reclaims remote export slots and shutdown resources cleanly.

Supporting evidence

  • Standalone branch rebased onto post-#607 main (5df8edd3c):
    • RUSTFLAGS="-D warnings" cargo check --locked --manifest-path selene/Cargo.toml --all-targets --features codec,rdma and selene-manager --lib --bins --tests: passed with 0 warnings.
    • cargo test --locked --release --manifest-path selene/Cargo.toml --features codec --lib: 540/540 passed.
    • cargo test --locked --release --manifest-path selene-manager/Cargo.toml --lib --test builder --test offload --test packed --test pool_claims --test pool_net --test pool_store: 186/186 lib (1 ignored) + builder 3/3 + offload 2/2 + packed 9/9 + pool_claims 36/36 + pool_net 6/6 + pool_store 11/11 passed.
  • Combined 4-PR validation & SM120/SM121 hardware qualification:
    • Live flare run + selene-manager baseline vs patched qualification on SM120 (cn5: DeepSeek-V4.1-Flash-1017 TP4, GLM-5.3-Flash TP2/TP4 off/cpu/gpu, Qwen3.8-Flash-Next TP1/TP2 including wiped-local-disk pool-only cold restore) and GB10 (cn6–cn9: 3-node TP2 and 4-node TP4 cross-host pool retirement & restore): 0 panics, 0 leaked pins/slots, 0 quarantined bytes, clean shutdowns.
  • Material limitations: Live hardware qualification ran against the combined 4-PR stack before rebasing onto #496/#497/#607, and CPU tests were re-run after rebasing onto 5df8edd3c.

Discord: D-Rock

@yatesdr
yatesdr force-pushed the fix/selene-manager-hardening branch 3 times, most recently from 555f4b5 to d3d4f40 Compare November 29, 2026 17:27
Several `selene-manager` paths accepted unvalidated peer metadata or
multi-process packed operations that could cause out-of-bounds arena
reads/writes, panics, or permanent slot and resource leaks.

- Reject multi-process (`world >= 2`) packed `PutBegin` and `PinAck`
  grants cleanly instead of sizing an arena extent to compressed bytes
  and passing uncompressed window lengths to `pass::run` or concurrent
  rank writers (`selene-manager/src/pool/store_bridge.rs`,
  `selene-manager/src/pool/claims.rs`).
- Cap scopes at 64 ranks and 1 TiB record sizes in `validate_scope`,
  replace panicking `next_power_of_two` calls with
  `checked_next_power_of_two`, check `PinAck` page and reservation
  bounds before allocating `PlannedWindow` vectors, and use checked
  arithmetic in `windows::plan` (`selene-manager/src/pool/mod.rs`,
  `selene-manager/src/store.rs`, `selene-manager/src/pool/claims.rs`,
  `selene-manager/src/pool/windows.rs`).
- Reparent replaced nodes to root in `Index::reparent_to_root` when
  rootless fallback converts a linked replacement to a root record, and
  refuse evicting page-only ancestors with active readers in
  `evict_accounted` (`selene/src/shared/index.rs`,
  `selene-manager/src/store.rs`).
- Reclaim terminal remote-channel `Pinned` exports on source disconnect,
  resolve rank-agent fences by `aid`, verify scope and rank secrets
  before keeping peer agents across rank-0 reconnect, bound and prune
  idle scopes, fall back to `kill(pid, 0)` when `pidfd_open` is
  unavailable, cap and time out TLS handshakes on `--listen`, and call
  `hub.shutdown()` before aborting `pool_task`
  (`selene-manager/src/pool/claims.rs`,
  `selene-manager/src/pool/ranks.rs`,
  `selene-manager/src/pool/core.rs`, `selene-manager/src/local.rs`,
  `selene-manager/src/control.rs`).

The manager now rejects malformed or unsupported multi-process packed
requests safely, resists oversize-geometry DoS inputs, keeps `Tree`
topology consistent across rootless replacements, and reclaims remote
export slots and shutdown resources cleanly.

Validated on Linux (rebased onto post-NVIDIA#607 main `5df8edd3c`), GB10, and
SM120 hardware across `selene` and `selene-manager`.

Signed-off-by: yatesdr <6937857+yatesdr@users.noreply.github.com>
Design-Signed-Off-By: yatesdr; design-review=2e5b
@yatesdr
yatesdr force-pushed the fix/selene-manager-hardening branch from d3d4f40 to 1f9ee76 Compare November 29, 2026 17:31
@yatesdr
yatesdr merged commit 3801ff1 into NVIDIA:main Nov 29, 2026
2 of 3 checks passed
@flare-autobot

Copy link
Copy Markdown
Collaborator

A case file has been opened for 612.
Case File Intake Report

Future reviews will auto-run 90 minutes after code updates are pushed.

  • Re-review sooner: Call @flare-autobot after push.
  • Opt-out: Include #autobot:ignore in the PR or any comment.

@flare-autobot

Copy link
Copy Markdown
Collaborator

Review Stopped

Auto-Review halted due to finding: It was already fixed another way (merged or on the main branch), or is no longer needed for another reason.
Value Proposition Report

@flare-autobot flare-autobot added area:selene Selene shared prefix-cache pool, protocol, manager, and transfers. bug Something isn't working triage:review Proposed change needs code review; this does not imply merge readiness. labels Nov 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:selene Selene shared prefix-cache pool, protocol, manager, and transfers. bug Something isn't working triage:review Proposed change needs code review; this does not imply merge readiness.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants