Skip to content

fix: reject ambiguous module load instances - #302

Merged
swananan merged 1 commit into
mainfrom
fix/reject-ambiguous-load-instances
Sep 6, 2026
Merged

fix: reject ambiguous module load instances#302
swananan merged 1 commit into
mainfrom
fix/reject-ambiguous-load-instances

Conversation

@swananan

@swananan swananan commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Loading one ELF more than once can assign different load biases to the same (PID, module cookie) map key. Both probes could then read one instance's globals, reporting 11 for an instance whose native value is 22.

Reject ambiguous executable load instances at PID and target startup, including distinct files with the same Build-ID cookie. Read-only ELF mappings do not establish another load instance. Contradictory executable-segment evidence is rejected instead of falling back to an arbitrary mapping.

Check the actual probe load bias (runtime IP - attached ELF PC) before rebasing global addresses. This also protects cross-module reads from a stale probe-module entry. A read-only mapping can no longer broaden the acceptance range to cover another instance.

When sysmon detects ambiguity, remove the previous userspace snapshot and published offsets/ranges for the PID's runtime aliases. Module reconciliation invalidates rejected PIDs immediately and continues refreshing supported processes. Target cookie validation is reused while the executable mapping snapshot is unchanged.

The existing map ABI is unchanged. This patch rejects or invalidates unsupported instances; full multi-instance tracing and cross-namespace instance association remain separate work.

Validation:

  • Formatting and full workspace Clippy passed with -D warnings -D clippy::undocumented_unsafe_blocks.
  • All 961 non-e2e unit, integration, and documentation tests passed; final GitHub Test Suite has exactly the same test names.
  • All eight load-instance e2e cases passed on the final source. The wrong-value and target-copy regressions fail against the original PR binary and pass after the fixes. Controlled ELF tests cover shared executable file pages and contradictory load biases.
  • A separate privileged proof calls only module reconciliation against real pinned maps. The original PR retains four stale offsets and four ranges and fails to restore a healthy PID's missing entry. The fix clears the rejected PID, restores the healthy PID, and preserves strict startup rejection. The proof remains outside the repository.
  • Full standard and host -> docker-private e2e passed locally: 361 tests each on the final runtime code. The last test-only applicability change was rechecked with all eight focused cases and full Clippy.
  • Final commit 2c99914 passed all nine GitHub checks, including standard e2e, three full container topologies, and host-PID smoke. GitHub standard e2e's 361 test names exactly match the local run.

Coverage boundary: nested child-container globals -t remains unsupported, as documented in docs/container.md and already handled by the existing globals target suite. The three late target-mode tests now reuse that same applicability helper. Final CI logs confirm all eight cases execute in host-to-private and private-same-sandbox; nested child-container executes the four startup rejection cases and PID late-load case, explicitly skipping the three unsupported runtime cases. Their value assertions remain active in the supported topologies.

Rebased onto main after #301 merged; this PR contains one commit against main.

@swananan
swananan marked this pull request as ready for review September 6, 2026 04:59
@swananan
swananan force-pushed the fix/cancellable-script-output branch from d366401 to 9314b7d Compare September 6, 2026 12:40
Base automatically changed from fix/cancellable-script-output to main September 6, 2026 13:29
@swananan
swananan force-pushed the fix/reject-ambiguous-load-instances branch from 35dcd6c to a859154 Compare September 6, 2026 14:13
@swananan
swananan force-pushed the fix/reject-ambiguous-load-instances branch from a859154 to 2c99914 Compare September 6, 2026 14:39
@swananan
swananan merged commit f3ed030 into main Sep 6, 2026
9 checks passed
@swananan
swananan deleted the fix/reject-ambiguous-load-instances branch September 6, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant