Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

[x86/Linux] Fix segmentation fault during GSCookie check (WIP)#8981

Closed
parjong wants to merge 1 commit into
dotnet:masterfrom
parjong:fix/issue_8980
Closed

[x86/Linux] Fix segmentation fault during GSCookie check (WIP)#8981
parjong wants to merge 1 commit into
dotnet:masterfrom
parjong:fix/issue_8980

Conversation

@parjong
Copy link
Copy Markdown

@parjong parjong commented Jan 18, 2017

This commit attempts to fix segfault due to incorrect GSCookie address.

The current implementation computes GSCookie address via dereferencing pEbp field in REGDISPLAY, and adding some offsets, but pEbp is not initialized correctly.

This results in segmentation fault discussed in #8980.

In addition, the currenct implementation of FaultingExceptionFrame::UpdateRegDisplay does not updates pXXX fields at all, which incurs segmentation fault while checking GSCookie inside ExceptionTracker::FindNonvolatileRegisterPointers .

This commit attempts to update pEbp to fix #8980.

@parjong parjong changed the title [x86/Linux] Fix segfault during GSCookie check [x86/Linux] Fix segfault during GSCookie check (WIP) Jan 18, 2017
@parjong parjong changed the title [x86/Linux] Fix segfault during GSCookie check (WIP) [x86/Linux] Fix segmentation fault during GSCookie check (WIP) Jan 18, 2017

do
{
CONTEXT currentContext = *frameContext;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We should not change anything in this function, but rather fix it for x86 elsewhere. This function works for amd64 and arm, so it should be possible to ensure that it works for x86 too.
One of the problems here is that you set the dispatcherContext.ContextRecord to a local variable address, but the ProcessCLRException stores it in the ExceptionTracker that outlives this function.
This is the reason why 65 tests have failed in the CI.

@janvorli
Copy link
Copy Markdown
Member

@parjong could you please dump me the call stack when the cookie check has seg faulted?

@parjong
Copy link
Copy Markdown
Author

parjong commented Jan 18, 2017

@janvorli As you pointed out, it seems that this PR is not appropriate. I'll close this PR, and re-submit later with right fix.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[x86/Linux] Catch exceptions thrown from unsafe code

4 participants