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

[Mono] Fix OP_CHECK_THIS to read 1 byte instead of 4/8 on x86/x64/LLVM. #74638

Merged
merged 1 commit into from
Aug 31, 2022

Conversation

lateralusX
Copy link
Member

Current implementation of OP_CHECK_THIS on x86/x64 and LLVM does a memory read of at least 4 bytes. This creates an issue when the target is a managed pointer, since that could point to the interior of a type, meaning it can read pass the allocated memory causing a crash. Fix change the size of the read to one byte since the only reason doing the read is to validate that the reference, managed pointer is not NULL. Reading only one byte is also inline with how it is implemented on arm/arm64, and it will reduce potential unaligned reads on x86/x64.

Full fix for, #74179.

Fixes #74179

@lambdageek
Copy link
Member

We should backport this

@lateralusX
Copy link
Member Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lateralusX
Copy link
Member Author

lateralusX commented Aug 29, 2022

Failures in runtime-extra-platforms seems unrelated and appears on multiple other PR's.

@lateralusX
Copy link
Member Author

/backport to release/7.0

@github-actions
Copy link
Contributor

Started backporting to release/7.0: https://github.com/dotnet/runtime/actions/runs/2950110740

Current implementation of OP_CHECK_THIS on x86/x64 and LLVM does a
memory read of at least 4 bytes. This creates an issue when the
target is a managed pointer, since that could point to the interior
of a type, meaning it can read pass the allocated memory causing
a crash. Fix change the size of the read to one byte since the only
reason doing the read is to validate that the reference, managed pointer
is not NULL. Reading only one byte is also inline with how it is
implemented on arm/arm64, and it will reduce potential unaligned
reads on x86/x64.

Full fix for, dotnet#74179.
@lateralusX lateralusX force-pushed the lateralusX/fix-74179-codegen branch from 182ec36 to 31fabbd Compare August 30, 2022 07:36
@lateralusX
Copy link
Member Author

Rebased to get CI run after #74567 had been merged and tests had been re-enabled.

@lateralusX
Copy link
Member Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lateralusX
Copy link
Member Author

lateralusX commented Aug 31, 2022

Failures looks unrelated and had failed in similar ways on other PR's as well.

@lateralusX lateralusX merged commit 9e8d261 into dotnet:main Aug 31, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Sep 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Codegen-meta-mono runtime-mono specific to the Mono runtime
Projects
None yet
2 participants