Repository navigation
fix(arm64): unwind past PAC-signed return addresses - #12
Merged
Merged
Conversation
This was referenced Oct 29, 2026
`strip_pac()` only strips with a mask, and nothing sets one. The `__bionic_clear_pac_bits()` fallback was compiled out because it is not in the NDK, so a signed return address ended the unwind. Strip with `xpaclri` like bionic does, spelled as `hint #7` for assemblers without Armv8.3-A support. It is a NOP on older CPUs. Pixel 8 Pro (Tensor G3, Android 17), `abort()` through two `-mbranch-protection=pac-ret` functions, unwound from a SIGABRT handler like sentry-native's inproc backend. Before: #00 pc 000000000007fdc0 .../libc.so (abort+160) #1 pc 006e8cdf7ce216d0 <unknown> After: #00 pc 000000000007fdc0 .../libc.so (abort+160) #1 pc 000000000002867c .../pac_test (pac_crash()+12) #2 pc 000000000002868c .../pac_test (pac_caller()+12) #3 pc 0000000000028708 .../pac_test (main+120) #4 pc 000000000007183c .../libc.so (__libc_init+124) Ref: getsentry/sentry-native#2258
jpnurmi
force-pushed
the
jpnurmi/fix/strip-pac
branch
from
October 29, 2026 12:10
e3fdf2e to
d38db07
Compare
mujacica
approved these changes
Oct 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
strip_pac()only strips with a mask, and nothing sets one. The__bionic_clear_pac_bits()fallback was compiled out because it is not in the NDK, so a signed return address ended the unwind. Strip withxpaclrilike bionic does, spelled ashint #7for assemblers without Armv8.3-A support. It is a NOP on older CPUs.Proof
__bionic_clear_pac_bits()inlined, which upstream libunwindstack calls instrip_pac(). Only the mnemonic differs.XPACLRIstrips the PAC from the instruction address in LR (x30). It has no operands, so thex30register variable with a"+r"constraint passes the value in and out. Its operationStrip(X[30], data=FALSE)takes no key or modifier.d50320ffis in the HINT space withCRm=0000, op2=111, which ishint #7, and decodes as a NOP withoutFEAT_PAuth. LLVM definesXPACLRIashint #7, and compiler-rt's sanitizers strip PACs with the samehint #7.With NDK r27,
RegsArm64::set_pc()compiles to:Verification
We don't have Android ARM64 covered by the CI, so verified on a Pixel 8 Pro (Tensor G3, Android 17). The test signs an address with
pacia1716and passes it toset_pc(), then callsabort()through two-mbranch-protection=pac-retfunctions and unwinds from a SIGABRT handler like sentry-native's inproc backend.master:
This PR:
Steps to reproduce
Save the two files below in
pac_test/of a libunwindstack-ndk checkout, then run on an arm64 device with PAC, on master and on this branch:pac_test/CMakeLists.txt:pac_test/pac_test.cpp:Ref: