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

Capture Reverse P/Invoke frame offset in x86 GC info and disallow return hijacking of reverse P/Invokes on x86. #49066

Merged
merged 5 commits into from
Mar 5, 2021

Conversation

jkoritzinsky
Copy link
Member

Fixes #45326

cc: @dotnet/jit-contrib

@jkoritzinsky jkoritzinsky added this to the 6.0.0 milestone Mar 3, 2021
@jkoritzinsky jkoritzinsky requested a review from jkotas March 3, 2021 17:36
@@ -5892,6 +5892,12 @@ bool EECodeManager::GetReturnAddressHijackInfo(GCInfoToken gcInfoToken, ReturnKi

DecodeGCHdrInfo(gcInfoToken, 0, &info);

if (info.revPInvokeOffset != INVALID_REV_PINVOKE_OFFSET)
Copy link
Member

Choose a reason for hiding this comment

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

Do we also need to check this in EH, like GetReversePInvokeFrameStackSlot
is checked on non-x86? It is possible that it is not needed, just mentioning it.

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not needed in x86 Windows EH since we fully integrate with SEH already. However, it looks like Unix x86 needs it, so I'll update the relevant locations to use it.

Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

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

Thank you!

@ghost
Copy link

ghost commented Mar 3, 2021

Hello @jkoritzinsky!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@jkotas
Copy link
Member

jkotas commented Mar 4, 2021

Many tests on x86 failing with:

Assert failure(PID 1332 [0x00000534], Thread: 864 [0x0360]): Assertion failed 'header->revPInvokeOffset != INVALID_REV_PINVOKE_OFFSET' in 'System.Net.NameResolutionPal:GetAddressInfoExCallback(int,int,int)' during 'Emit GC+EH tables' (IL size 10)

    File: D:\workspace\_work\1\s\src\coreclr\jit\gcencode.cpp Line: 1631

@jkoritzinsky
Copy link
Member Author

I think the sentinel we have for the "invalid offset" value can possibly be a valid value. I'll run through one of the CoreCLR tests that's failing tomorrow.

@jkoritzinsky jkoritzinsky merged commit 197ce0f into dotnet:main Mar 5, 2021
@jkoritzinsky jkoritzinsky deleted the x86-rev-pinvoke-gcinfo branch March 5, 2021 21:05
@trylek
Copy link
Member

trylek commented Mar 5, 2021

Beautiful, thank you!

@ghost ghost locked as resolved and limited conversation to collaborators Apr 4, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Test failure: readytorun/coreroot_determinism/coreroot_determinism/coreroot_determinism.sh
3 participants