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

user backtrace fix #291

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

user backtrace fix #291

wants to merge 10 commits into from

Conversation

v4m1n
Copy link
Collaborator

@v4m1n v4m1n commented Mar 24, 2023

checkAddressValid panics when given a non-canonical address due to the new assert in resolveMapping.
A user could trigger this by crashing with a non-canonical address in rbp.
Add an extra check in checkAddressValid since it should never assert.

An incorrectly aligned user-space stack could make the user backtrace function read from an incorrect page in the identity mapping. This can lead to a crash due to a read from non-existing physical memory.

@v4m1n
Copy link
Collaborator Author

v4m1n commented Mar 24, 2023

Changed it from no backtrace prints to a warning.
Fixed a bug that could lead to incorrect backtrace prints even with correctly aligned stack if rbp is exactly at a page boundary.

if (thread->user_registers_->rbp % sizeof(pointer))
{
debug(BACKTRACE, "stack not aligned. this could cause serious problems\n");
return 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this return intentionally here?

Copy link
Collaborator Author

@v4m1n v4m1n Mar 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left it in by mistake.
already removed it

@v4m1n
Copy link
Collaborator Author

v4m1n commented Mar 24, 2023

Made a small mistake there. with correct 16 byte alignment the old code was fine.
Now it's a bit more relaxed though and works with an 8 byte aligned rbp as well.

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