Skip to content

fix(modulefinder): handle ENOSYS in read_safely for Kubernetes seccomp - #1654

Closed
HrMathematiker wants to merge 1 commit into
getsentry:masterfrom
HrMathematiker:fix/read-safely-enosys
Closed

HrMathematiker wants to merge 1 commit into
getsentry:masterfrom
HrMathematiker:fix/read-safely-enosys

Conversation

@HrMathematiker

@HrMathematiker HrMathematiker commented Apr 15, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1653.

Problem

When running under Kubernetes with the default RuntimeDefault seccomp profile, process_vm_readv is blocked and returns ENOSYS (errno 38). The existing fallback in read_safely() only handles EPERM and EINVAL, so every ELF module validation fails silently.

The result: sentry_get_modules_list() returns 0 modules, debug_meta.images is absent from manually-captured events, and every stack frame shows as unknown_image in Sentry — even when debug symbols have been uploaded correctly.

When does this happen?

  • Kubernetes pods using the default RuntimeDefault seccomp profile
  • Docker containers (Docker default profile returns EPERM, already handled)
  • Bare-metal / VMs (syscall is permitted)

Crash events via crashpad are not affected because the out-of-process handler enumerates modules from /proc/<pid>/maps directly, independent of sentry_get_modules_list().

Root cause

read_safely() in sentry_modulefinder_linux.c:

// Before
if (!rv && (errno == EPERM || errno == EINVAL)) {

// After
if (!rv && (errno == EPERM || errno == EINVAL || errno == ENOSYS)) {

Verification

Confirmed with a static test binary copied into a real K8s pod (Flatcar Linux, kernel 6.12, Seccomp: 2):

FAILED: errno=38 (Function not implemented)

Also reproduced locally using Docker with a custom seccomp profile (SCMP_ACT_ERRNO / errnoRet: 38) — the original code fails, the patched code falls back to memcpy and succeeds.

Fix

One-liner: add || errno == ENOSYS to the existing errno fallback. The address is valid in-process memory, so memcpy is safe.

Kubernetes RuntimeDefault seccomp profiles block `process_vm_readv`
and return ENOSYS (errno=38). The existing fallback only handled EPERM
and EINVAL, so every ELF module validation failed silently, leaving
`debug_meta.images` empty in manually-captured events and causing all
stack frames to show as `unknown_image` in Sentry.

Add ENOSYS to the fallback so the memcpy path is taken when the syscall
is unavailable, matching the behaviour already in place for EPERM/EINVAL.
@sdk-maintainer-bot

Copy link
Copy Markdown
Contributor

This PR has been automatically closed. All non-maintainer contributions must reference an existing GitHub issue.

Next steps:

  1. Find or open an issue describing the problem or feature
  2. Discuss the approach with a maintainer in the issue
  3. Once a maintainer has acknowledged your proposed approach, open a new PR referencing the issue

Please review our contributing guidelines for more details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sentry_modulefinder_linux: empty module list in containers with restricted process_vm_readv

1 participant