Skip to content

munmap tracer programs cause panic on RHEL 9.x #323

@gmarler

Description

@gmarler

lightswitch v0.3.1, when started on RHEL 9.6, immediately panics with the following (with RUST_BACKTRACE=full):

...
2025-10-10T11:50:53.422374Z DEBUG lightswitch::profiler: adding kernel module [vmlinux] [0xffffffffa0600000 - 0xffffffffa1600000)

thread 'main' panicked at src/profiler.rs:721:31:
attach tracers: Error: Permission denied (os error 13)
stack backtrace:
   0:     0x555555c59992 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h4af010e4b1354d4d
   1:     0x555555c7f7b3 - core::fmt::write::h17347e42c9203d6d
   2:     0x555555c55b63 - std::io::Write::write_fmt::h05610498df74ae59
   3:     0x555555c597e2 - std::sys::backtrace::BacktraceLock::print::h0286e2cc1356b990
   4:     0x555555c5b2a9 - std::panicking::default_hook::{{closure}}::hb566dc96699e42f6
   5:     0x555555c5b08b - std::panicking::default_hook::h1b340523e54d7d17
   6:     0x5555557d4421 - lightswitch::panic_thread_hook::{{closure}}::hca7a44bbcd05f0af
   7:     0x555555c5bd7e - std::panicking::rust_panic_with_hook::hceef4321c6f4ad8a
   8:     0x555555c5ba4a - std::panicking::begin_panic_handler::{{closure}}::hf9fd67a226c3bb3d
   9:     0x555555c59e89 - std::sys::backtrace::__rust_end_short_backtrace::h52410ec1fdc70787
  10:     0x555555c5b6dd - __rustc[507298ddafb0ef2f]::rust_begin_unwind
  11:     0x555555c7d1d0 - core::panicking::panic_fmt::hf04b323265684a46
  12:     0x555555c7d596 - core::result::unwrap_failed::hdf92484becbba54e
  13:     0x555555806bd4 - lightswitch::profiler::Profiler::run::h8ede74104368aa90
  14:     0x5555557d62ab - lightswitch::main::he67577b2f10368df
  15:     0x5555557db546 - std::sys::backtrace::__rust_begin_short_backtrace::h852a5d5477f6819b
  16:     0x5555557de57c - std::rt::lang_start::{{closure}}::h99f025f2b5cd6b24
  17:     0x555555c4dc40 - std::rt::lang_start_internal::hefa4f6595ff6acba
  18:     0x5555557d8c7d - main
  19:     0x7ffff7c295d0 - __libc_start_call_main
  20:     0x7ffff7c29680 - __libc_start_main@GLIBC_2.2.5
  21:     0x55555579256e - _start
  22:                0x0 - <unknown>

Traced this down to the munmap() tracepoints in src/bpf/tracers.bpf.c. The first problem relates to the fact that the struct munmap_entry_args passed to entry tracepoint for munmap() isn't quite CO-RE compliant, and has changed for the RHEL 9.x kernel.

That's easy to change and make CO-RE compliant, as the offset of the addr field remains constant, so just need generic padding at the start of the struct.

But even after fixing this, the exit tracepoint for munmap() continues to panic on startup, and libbpf-rs isn't giving a clear indication of why, nor does the kernel bpf log.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions