This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Fix Windows context to Unix context translation on AMD64 #6027
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
There was a bug in the context translation between the Windows context and Unix context on AMD64 caused by the fact that the Unix context gregs array contains CS, GS and FS in a single field (REG_CSGSFS) and the MCREG_SegCs accessor macro was incorrectly written to use the whole field as CS. So writing the CS into the Unix context also cleared the GS, FS and the topmost 16 bits described as padding. This issue was exposed on the Linux kernel >= 4.6.0 where the padding for some reason was not zero, probably used by the kernel for some internal purposes. I have fixed it by changing the accessor to modify only the 16 bits corresponding to the CS. I have also changed the code in the inject_activation_handler to save cycles and not to copy the Windows context back to the Unix one in case the activation function was not called and so the context was not possibly changed.
@adityamandaleeka can you take a look please? |
Fixes #6016 |
@dotnet-bot test CentOS7.1 x64 Debug Build and Test please |
LGTM |
This was referenced Jul 18, 2016
janvorli
added a commit
to janvorli/coreclr
that referenced
this pull request
May 15, 2018
…#6027) There was a bug in the context translation between the Windows context and Unix context on AMD64 caused by the fact that the Unix context gregs array contains CS, GS and FS in a single field (REG_CSGSFS) and the MCREG_SegCs accessor macro was incorrectly written to use the whole field as CS. So writing the CS into the Unix context also cleared the GS, FS and the topmost 16 bits described as padding. This issue was exposed on the Linux kernel >= 4.6.0 where the padding for some reason was not zero, probably used by the kernel for some internal purposes. I have fixed it by changing the accessor to modify only the 16 bits corresponding to the CS. I have also changed the code in the inject_activation_handler to save cycles and not to copy the Windows context back to the Unix one in case the activation function was not called and so the context was not possibly changed.
u-abramchuk
added a commit
to u-abramchuk/b2.domain
that referenced
this pull request
Dec 3, 2018
picenka21
pushed a commit
to picenka21/runtime
that referenced
this pull request
Feb 18, 2022
…clr#6027) There was a bug in the context translation between the Windows context and Unix context on AMD64 caused by the fact that the Unix context gregs array contains CS, GS and FS in a single field (REG_CSGSFS) and the MCREG_SegCs accessor macro was incorrectly written to use the whole field as CS. So writing the CS into the Unix context also cleared the GS, FS and the topmost 16 bits described as padding. This issue was exposed on the Linux kernel >= 4.6.0 where the padding for some reason was not zero, probably used by the kernel for some internal purposes. I have fixed it by changing the accessor to modify only the 16 bits corresponding to the CS. I have also changed the code in the inject_activation_handler to save cycles and not to copy the Windows context back to the Unix one in case the activation function was not called and so the context was not possibly changed. Commit migrated from dotnet/coreclr@56ab756
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a bug in the context translation between the Windows context
and Unix context on AMD64 caused by the fact that the Unix context
gregs array contains CS, GS and FS in a single field (REG_CSGSFS) and
the MCREG_SegCs accessor macro was incorrectly written to use the
whole field as CS. So writing the CS into the Unix context also
cleared the GS, FS and the topmost 16 bits described as padding.
This issue was exposed on the Linux kernel >= 4.6.0 where the padding
for some reason was not zero, probably used by the kernel for some
internal purposes.
I have fixed it by changing the accessor to modify only the 16 bits
corresponding to the CS.
I have also changed the code in the inject_activation_handler to
save cycles and not to copy the Windows context back to the Unix one
in case the activation function was not called and so the context
was not possibly changed.