Skip to content

Open attached executables through procfs#374

Open
jeet-dekivadia wants to merge 1 commit into
janestreet:masterfrom
jeet-dekivadia:codex/open-container-executable
Open

Open attached executables through procfs#374
jeet-dekivadia wants to merge 1 commit into
janestreet:masterfrom
jeet-dekivadia:codex/open-container-executable

Conversation

@jeet-dekivadia

@jeet-dekivadia jeet-dekivadia commented May 30, 2026

Copy link
Copy Markdown

Summary

  • keep /proc/<pid>/exe intact while loading an attached process executable
  • use the procfs symlink target only when matching the executable name reported by /proc/<pid>/maps
  • preserve the existing realpath behavior for ordinary executable paths

Fixes #307.

Why both paths are needed

For a process in another mount namespace, /proc/<pid>/exe remains openable from the host even when its symlink target, such as /app/server, is not present in the host filesystem. Concretely, readlink("/proc/123/exe") can return /app/server while open("/app/server") fails on the host and open("/proc/123/exe") succeeds. The maps file still reports /app/server, so stop-filter address calculation needs the readlink result for its pathname comparison while ELF loading needs the procfs path itself.

Validation

  • git diff --check
  • reviewed both executable consumers: ELF loading now receives the procfs path for attach mode, and map-name comparison resolves only procfs executable symlinks with readlink

Signed-off-by: Jeet Dekivadia <jeet.university@gmail.com>
@jeet-dekivadia

Copy link
Copy Markdown
Author

I rechecked this today while it is waiting for review. The patch stays on the attach path: when magic-trace is reading symbols for an already-running target, it opens the executable through procfs so the path is resolved in the target process context instead of the tracer's current mount namespace.

The startup/non-attach path still uses the existing executable resolution. DCO is green, and the PR has no red checks.

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.

Failure to read symbols inside docker-container due to broken /proc/pid/exe link

1 participant