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

WIP Print backtrace on failed ASSERT_PKRUs #453

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ayrtonm
Copy link
Contributor

@ayrtonm ayrtonm commented Oct 22, 2024

This currently prints a trace but at least brief checks on the read_config test shows the trace ends at compartment boundaries. Need to fix that, add anything else that might be useful and swap IA2_DEBUG for IA2_RELEASE with opposite semantics. Closes #452.

@ayrtonm ayrtonm changed the title Print backtrace on failed ASSERT_PKRUs WIP Print backtrace on failed ASSERT_PKRUs Oct 22, 2024
@ayrtonm ayrtonm marked this pull request as draft October 22, 2024 18:51
@ayrtonm ayrtonm force-pushed the am/backtrace_bad_control_flow branch from 2789124 to 6763a59 Compare October 22, 2024 18:56
@ayrtonm
Copy link
Contributor Author

ayrtonm commented Oct 22, 2024

I think the issue with the shortened backtraces is specifically in IA2_CALL callgates, not general cross-compartment calls.

./tests/read_config/read_config 
#0 0x70cc4a79fdd6 in /home/ayrton/ia2/IA2-Phase2/build/tests/read_config/libread_config_call_gates.so(ia2_print_backtrace+0x16) [0x70cc4a79fdd6] ()
#1 0x70cc4a79e86a in /home/ayrton/ia2/IA2-Phase2/build/tests/read_config/libread_config_call_gates.so(__wrap_parse_str+0x36) [0x70cc4a79e86a] ()

the trace ends at the PLT stub so the issue might not be related to the call gate prologues.

@ayrtonm
Copy link
Contributor Author

ayrtonm commented Oct 28, 2024

Printing the backtrace for the broken test mentioned above gives this

0x00007ffff7e0b874 in __wrap_parse_str () from /home/ayrton/ia2/IA2-Phase2/build/tests/read_config/libread_config_call_gates.so
(gdb) bt
#0  0x00007ffff7e0b874 in __wrap_parse_str () from /home/ayrton/ia2/IA2-Phase2/build/tests/read_config/libread_config_call_gates.so
#1  0x00007ffff7e1459c in __ia2_parse_str () from /home/ayrton/ia2/IA2-Phase2/build/tests/read_config/libread_config_lib.so
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

Although call gate control flow is wrong here (__ia2_foo should call foo not __wrap_foo) this is exactly the type of case that we want to be able to handle so we should do whatever gdb is doing.

@ayrtonm ayrtonm force-pushed the am/backtrace_bad_control_flow branch from 6763a59 to 6f9ac54 Compare November 5, 2024 02:02
backtrace(3) doesn't support unwinding through PLT stubs so this commit
replaces it with libunwind. Since we want backtraces on by default I'm not sure
if this is exactly what we want but it's good enough for now.
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.

Make ASSERT_PKRU print a backtrace and make IA2_DEBUG on by default
1 participant