-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Arm-64: Add initial support for PAC-RET #110472
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
base: main
Are you sure you want to change the base?
Conversation
@SwapnilGaikwad - once you resolve the stack walking problem, can you also try something like this in a Foo() method? paciasp
stp fp, lr, [sp, #-0x10]!
mov x9, [sp] ; overwrite lr value with random content
...
...
xpaclri ; will fail and should give the call stack
... |
- Add support for 'pac_sign_lr' unwind code - Use authenticate instruciton instead of stripping PAC in epilog
Hi @jkotas , I was wondering if you any suggestions to investigate a segfault. The NativeAot version of
Any pointers to debug this? I'm using a debug build. Currently checking if any GC workflow jumps to this address. |
I do not see this specific failure in the CI, but I see plenty of other failures. They are related to hijacking - we are trying to return to RhpGcProbeHijack, but the return address is not signed.
The hijack target is returned up during return address hijacking. It is expected that the hijack target is signed - it is expected to happen here https://github.com/dotnet/runtime/pull/110472/files#diff-ab37b443cf4fe3a293dfbfddb896222f93c6b3c3630a6b023bb2c27399a841bdR838
Yes, crashes related to GC suspension tend to be timing dependent. You may want to create a more stressful repro to debug it - run the test routing the problem on one thread and run a |
Correct. However, we should jump to the hijack target after authenticating so shouldn't have it to be signed. You're right, it could be the case where we are incorrectly detecting PAC which may lead to jumping to this address without auth. I'll probably fix the detecting PAC using DWARF info and come back to this failure (hopefully it disappears :) ). I don't think currently I'm having correct starting unwind code.
Cool, I'll use this if the issue persists. Thanks for the pointers 👍 |
@dotnet/samsung Could you please take a look? These changes may be related to riscv64. |
@@ -105,7 +109,7 @@ inline PCODE GetIP(T_CONTEXT* context) | |||
#elif defined(TARGET_ARM) | |||
return (PCODE)context->Pc; | |||
#elif defined(TARGET_ARM64) | |||
return (PCODE)context->Pc; | |||
return (PCODE) PacStripPtr((void *)context->Pc); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll move these strip operations to the source while populating the context. These are temporarily added until we get all the CI issues fixed.
Have we tried running the diagnostic tests on this yet? |
RISC-V Release-CLR-QEMU: 9080 / 9110 (99.67%)
report.xml, report.md, failures.xml, testclr_details.tar.zst Build information and commandsGIT: |
RISC-V Release-CLR-VF2: 9083 / 9113 (99.67%)
report.xml, report.md, failures.xml, testclr_details.tar.zst RISC-V Release-CLR-QEMU: 9082 / 9112 (99.67%)
report.xml, report.md, failures.xml, testclr_details.tar.zst Build information and commandsGIT: |
@steveisok is doing this now |
@dotnet/samsung Could you please take a look? These changes may be related to riscv64. |
This PR introduces initial support for Pointer Authentication (PAC) on Arm64. PAC is a hardware security feature designed to mitigate Return-Oriented Programming (ROP) attacks by cryptographically signing return addresses. The signed return address is stored on the stack and later authenticated before returning from a function, ensuring control flow returns to the intended caller.
More details on PAC and its role in software security can be found (here).
Enabling PAC involves inserting additional instructions into both the function prolog (for signing) and epilog (for authentication). This results in increased code size. For example, we observe a 1.8% increase in code size across System*.dll assemblies compiled using crossgen2.
The added instructions also introduce some runtime overhead. In our benchmark of Orchard CMS 9.0, we observe a 1.3% performance regression, which falls within the noise range (standard deviation: ~1.3%).
@kunalspathak @janvorli @a74nh
Contributes to #109457