Repository navigation
Preserve ARM64 PAC masks in macOS core dumps - #138041
Conversation
Write a version 4 "addrable bits" LC_NOTE to macOS ARM64 Mach-O core dumps, sourced from the machdep.virtual_address_size sysctl (the same source debugserver uses). Without this note, LLDB falls back to stripping only the top address byte and leaves PAC signature bits in return addresses signed by arm64e system libraries, breaking unwinding through those frames - the same class of gap fixed for Linux ARM64 in dotnet#137777. Validated on an Apple M3 Pro (FEAT_PAuth/FEAT_PAuth2/FEAT_FPAC) by building createdump from this change, crash-dumping a managed process, and confirming via otool -l and a manual LC_NOTE payload decode that the emitted note (version 4, lowAddressBits=47, highAddressBits=47) exactly matches the live machdep.virtual_address_size sysctl value. Co-authored-by: Copilot <[email protected]>
|
Azure Pipelines: Successfully started running 3 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 |
|
Tracking note: the change looks good to land. End-to-end validation will follow in dotnet/diagnostics via dotnet/diagnostics#6256, using the same A/B approach as #137777: run Note This comment was drafted with GitHub Copilot assistance. |
|
/backport to release/11.0 |
|
Started backporting to |
|
@max-charlamb backporting to git am output$ git cherry-pick 749802c992b98ef2e3291999e0b5eb7ddb497fba
Auto-merging src/coreclr/debug/createdump/dumpwritermacho.cpp
CONFLICT (modify/delete): src/coreclr/debug/createdump/shared/dumpwritermacho.h deleted in HEAD and modified in 749802c992b (Preserve ARM64 PAC masks in macOS core dumps (#138041)). Version 749802c992b (Preserve ARM64 PAC masks in macOS core dumps (#138041)) of src/coreclr/debug/createdump/shared/dumpwritermacho.h left in tree.
error: could not apply 749802c992b... Preserve ARM64 PAC masks in macOS core dumps (#138041)
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch
Applying: Add PAC address metadata to macOS ARM64 core dumps
Using index info to reconstruct a base tree...
A src/coreclr/debug/createdump/shared/dumpwritermacho.cpp
A src/coreclr/debug/createdump/shared/dumpwritermacho.h
Falling back to patching base and 3-way merge...
Auto-merging src/coreclr/debug/createdump/dumpwritermacho.cpp
CONFLICT (modify/delete): src/coreclr/debug/createdump/shared/dumpwritermacho.h deleted in HEAD and modified in Add PAC address metadata to macOS ARM64 core dumps. Version Add PAC address metadata to macOS ARM64 core dumps of src/coreclr/debug/createdump/shared/dumpwritermacho.h left in tree.
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Add PAC address metadata to macOS ARM64 core dumps
Error: The process '/usr/bin/git' failed with exit code 128 |
Summary
#137777 added
NT_ARM_PAC_MASKsupport so Linux ARM64 core dumps preserve the PAC (Pointer Authentication Code) address mask, letting debuggers correctly strip signed return addresses when unwinding. That PR also contained a macOS equivalent, but it was reverted (c6d46965dcd56ea37441a826457a5f039370e765) because it hadn't been built or tested on real macOS/PAC hardware.This PR reapplies that macOS fix (cherry-picked from the reverted commit
b4f6b7329b7efa4733918edcae847aa9a911a752) and validates it end-to-end on real Apple Silicon PAC hardware.What it does
On ARM64 macOS,
createdumpnow emits anLC_NOTEnamed"addrable bits"in the Mach-O core dump, containing a version-4{version, lowAddressBits, highAddressBits, reserved}payload sourced fromsysctlbyname("machdep.virtual_address_size", ...). This matches the format LLDB/debugserveralready expect/produce, so LLDB can correctly determine how many address bits are valid and strip PAC signing bits from return addresses when unwinding arm64e-signed frames.src/coreclr/debug/createdump/shared/dumpwritermacho.cpp: addsBuildAddressableBitsNote(), wires it intoWriteDump()/WriteHeader().src/coreclr/debug/createdump/shared/dumpwritermacho.h: addsAddressableBitsPayloadstruct and relatedDumpWritermembers.Validation
Performed on a local Apple M3 Pro (confirmed
FEAT_PAuth,FEAT_PAuth2,FEAT_FPAC,FEAT_PACIMPall enabled viasysctl hw.optional.arm.*):createdumpwith the fix (osx.arm64.Debug) and deployed it into a matching testhost's shared framework directory.DOTNET_DbgEnableMiniDump=1 DOTNET_DbgMiniDumpType=4to produce a full core dump.otool -lthat anLC_NOTEwithdata_owner="addrable bits"is present, and manually decoded its 16-byte payload ({version=4, lowAddressBits=47, highAddressBits=47, reserved=0}) — this exactly matches the livesysctl machdep.virtual_address_sizevalue (47) on the machine.Bus errorinObjectFileMachO::ParseSymtab/OSO debug-map parsing on this Xcode LLDB build) identically on dumps produced with and without the fix, confirming it's an environment issue unrelated to this change, not a regression.Note
This PR description and the investigation behind it were drafted with GitHub Copilot CLI assistance.