Repository navigation
Arm64: [PAC-RET] cDAC changes - #135959
SwapnilGaikwad wants to merge 17 commits into
Conversation
Strip PAC from saved return addresses before unwinding and resolving code.
|
Azure Pipelines: Successfully started running 4 pipeline(s). 12 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
|
The CI status of changes when PAC is enabled is found on PR #125436. |
| #if defined(TARGET_UNIX) | ||
| *Pointer &= 0x0000FFFFFFFFFFFF; | ||
| #else | ||
| // Windows uses 47-bit user addresses, so bit 47 can also contain PAC. |
There was a problem hiding this comment.
We may need to change wording with certainty if we can confirm TCR_EL1.T0SZ always = 17 on Windows. It would make PAC algorithm use TCR_EL1.T0SZ = PACEffectiveTxSZ = 17 in InsertPAC(). Thus, bit indexed 47 will always be used for storing PAC.
Some runtime paths report stack-interior references without using PromoteCarefully. Filter these references from both cDAC and runtime results before comparison so asymmetric filtering does not produce false stress-test failures. NOTE: This PR is created with the help of codex to address failing CI pipeline for #135959 cc: @dotnet/arm64-contrib @dhartglassMSFT @max-charlamb
|
The CI failures look unrelated to PAC changes. |
|
Changes look pretty good. |
|
Hi @jkotas, kindly look at the patch and let me know if there is anything we need to push this further. |
There was a problem hiding this comment.
🟡 Changes recommended
Existing x86 transition-frame tests lack the required metadata mock, and PAC handling remains untested for explicit frames and real ARM64 dumps.
4 open issues
What changed in this PR
Adds ARM64 pointer-authentication support to cDAC stack walking, complementing the earlier JIT, VM, and NativeAOT work by recovering usable addresses from signed return addresses.
Changes:
- Publishes a runtime-derived pointer-authentication mask through platform metadata.
- Applies the mask during ARM64 unwinding and explicit-frame handling, and adjusts native Windows PAC stripping.
- Adds mask and unwind unit tests and updates the platform-metadata specification.
| File | Description |
|---|---|
src/native/managed/cdac/tests/UnitTests/StackWalkTests.cs |
Adds PAC unwind cases and platform-metadata mocks. |
src/native/managed/cdac/tests/UnitTests/PlatformMetadataTests.cs |
Tests missing masks and selective bit clearing. |
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Legacy/ConversionExtensions.cs |
Removes the obsolete PAC rejection from address conversion. |
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Data/PlatformMetadata.cs |
Reads the optional authentication mask. |
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/StackWalk_1.cs |
Uses normalized frame return addresses for method lookup. |
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/FrameHandling/FrameHelpers.cs |
Strips authentication bits from explicit-frame return addresses. |
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/FrameHandling/BaseFrameHandler.cs |
Normalizes inlined-call and transition-frame instruction pointers. |
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/FrameHandling/ARM64FrameHandler.cs |
Normalizes hijack-frame return addresses. |
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/StackWalk/Context/ARM64/ARM64Unwinder.cs |
Handles the PAC unwind opcode using the target mask. |
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/PrecodeStubs_Common.cs |
Removes obsolete PAC-specific rejection. |
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/Contracts/PlatformMetadata_1.cs |
Exposes the mask, defaulting to zero when absent. |
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Contracts/CodePointerUtils.cs |
Adds shared return-address masking. |
src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IPlatformMetadata.cs |
Replaces the PAC flag with a mask accessor. |
src/coreclr/vm/datadescriptor/datadescriptor.inc |
Exports the mask field in runtime descriptors. |
src/coreclr/vm/cdacplatformmetadata.hpp |
Stores the authentication mask in native metadata. |
src/coreclr/vm/cdacplatformmetadata.cpp |
Derives and initializes the ARM64 mask. |
src/coreclr/unwinder/arm64/unwinder.cpp |
Clears bit 47 when stripping PAC on Windows. |
docs/design/datacontracts/PlatformMetadata.md |
Documents the mask accessor and optional-field behavior. |
docs/design/datacontracts/data-descriptor-meanings.json |
Describes the new mask descriptor. |
Review effort: Balanced
| return TargetCodePointer.Null; | ||
| } | ||
|
|
||
| return CodePointerUtils.StripPtrAuthFromReturnAddress(returnAddress, _target); |


This PR covers the cDAC subset of changes from 1#25436 related to cDAC.
It follows the previous work from- #127949, #127838, #128147 and #128950
More details on PAC and its role in software security can be found (here).
cc: @dotnet/arm64-contrib @a74nh @jkotas @dhartglassMSFT