Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libunwind] Support new frame layout of rtld-c18n #732

Closed
wants to merge 3 commits into from

Conversation

dpgao
Copy link

@dpgao dpgao commented Apr 17, 2024

This updates the unwinder to support the changes in CTSRD-CHERI/cheribsd#2079.

dstolfa and others added 3 commits March 22, 2024 15:10
This commit adds support for backtrace and exception handling in
libunwind when the process is running with the compartmentalization
runtime linker. The unwinding process remains the same until a
trampoline is encountered as the return address. This means that we are
crossing compartment boundaries and we need to gather the unwind
information from the runtime linker. We do this by reading information
from the executive stack that the runtime linker populates for us in
unw_getcontext.

It also adds a new class, CompartmentInfo, which is responsible for
abstracting away the details of c18n compartments. Currently, it is only
used to define the constants relating to the trusted frame layout.

There are two ways to compile this code:
 - LIBUNWIND_SANDBOX_OTYPES only;
 - LIBUNWIND_SANDBOX_OTYPES and LIBUNWIND_SANDBOX_HARDENED.

When LIBUNWIND_SANDBOX_HARDENED is specified, every stack pointer, frame
pointer and callee-saved register will be sealed in the unwind register
context. This is to prevent leakage of capabilities through the register
context as much as possible. There are two exceptions to this:
 - When unw_set_reg() is called from a libunwind consumer, the caller
   might expect to be able to retrieve the capability it stored in the
   context, and sealing it will break the API semantics;
 - When the capability that is in the context is a sentry. These can't
   be sealed using an otype.

The otype allocated to libunwind is given to libunwind by the runtime
linker via the _rtld_unw_getsealer function.

This functionality only works on Morello right now.
@dstolfa
Copy link
Contributor

dstolfa commented Apr 29, 2024

This is now merged and squashed into a clean history

@dstolfa dstolfa closed this Apr 29, 2024
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.

2 participants