runtime icon indicating copy to clipboard operation
runtime copied to clipboard

ARM64: verify we have coverage of GS cookie codegen.

Open russellhadley opened this issue 10 years ago • 4 comments

Ensure that we have an implementation commensurate with x64 for GS. We might need to add tests here.

russellhadley avatar May 31 '16 18:05 russellhadley

Basic GS cookie works. We've already hundreds of tests that emits GS cookies in CoreCLR Tests.

But since our Arm64 frame saves FP/LR at the bottom of stack, there is a potential issue where LR is corrupted while GS cookies (a local var) is not. So, we might want to save LR at the highest address to avoid such problem. But we wanted FP to be at the lowest to use the positive offset as possible and the unwind info wanted to save FP and LR as a pair sequence. And there is also some logic that finds FP from SP in between main/handlers.

Given the current logic covers the basic and the localloc is not common case and there are a subtle interactions described above, we defer working on this issue.

kyulee1 avatar Jun 06 '16 22:06 kyulee1

@BruceForstall @russellhadley

Can you describe roughly what needs to be done here?

sdmaclea avatar Mar 02 '18 15:03 sdmaclea

This is the buffer overrun checking (named "GS" because that's the C++ compiler switch for this feature). Implemented in genEmitGSCookieCheck() and related.

The issue is whether the implementation is sufficient for arm64, to provide adequate protection against buffer overruns, as stated here, due to the arm64 frame layout where FP/LR is often located at a low address. Basically, you want to make sure that if a malicious user overruns a buffer and trashes the saved LR (which could lead to arbitrary code execution), that the GS cookie is also trashed such that checking it causes a failure. Being able to trash the saved LR but not the GS cookie is probably bad.

cc @RussKeldorph @briansull @dotnet/arm64-contrib

BruceForstall avatar Mar 02 '18 20:03 BruceForstall

With https://github.com/dotnet/coreclr/pull/22023, GS support is complete on arm64.

BruceForstall avatar Mar 08 '19 17:03 BruceForstall