Skip to content

Arm64: [PAC-RET] cDAC changes - #135959

Open
SwapnilGaikwad wants to merge 17 commits into
dotnet:mainfrom
SwapnilGaikwad:github-pac-cdac
Open

SwapnilGaikwad wants to merge 17 commits into
dotnet:mainfrom
SwapnilGaikwad:github-pac-cdac

Conversation

@SwapnilGaikwad

Copy link
Copy Markdown
Contributor

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

Strip PAC from saved return addresses before unwinding and resolving code.
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Oct 16, 2026
@azure-pipelines

Copy link
Copy Markdown
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.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

@SwapnilGaikwad

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/coreclr/vm/cdacplatformmetadata.cpp Resolved
max-charlamb pushed a commit that referenced this pull request Oct 20, 2026
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
@SwapnilGaikwad

Copy link
Copy Markdown
Contributor Author

The CI failures look unrelated to PAC changes.
Hi @max-charlamb could you take a look the patch and let us know how can we push this further?

@max-charlamb

Copy link
Copy Markdown
Member

Changes look pretty good.

@SwapnilGaikwad

Copy link
Copy Markdown
Contributor Author

Hi @jkotas, kindly look at the patch and let me know if there is anything we need to push this further.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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

Comment thread src/coreclr/vm/cdacplatformmetadata.cpp Resolved
return TargetCodePointer.Null;
}

return CodePointerUtils.StripPtrAuthFromReturnAddress(returnAddress, _target);

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-Diagnostics-cdac community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants