[libunwind] [libunwind][AArch64] Protect PC within libunwind's context. (PR #113368)
Daniel Kiss via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 10 03:10:54 PDT 2025
================
@@ -1845,8 +1884,14 @@ class _LIBUNWIND_HIDDEN Registers_arm64 {
uint64_t getSP() const { return _registers.__sp; }
void setSP(uint64_t value) { _registers.__sp = value; }
- uint64_t getIP() const { return _registers.__pc; }
- void setIP(uint64_t value) { _registers.__pc = value; }
+ uint64_t getIP() const { return auth(_registers.__pc, getAuthSalt()); }
+ void setIP(uint64_t value) {
+ // First authenticate the current value of the IP to ensure the context
+ // is still valid. This also ensure the setIP can't be used for signing
+ // arbitrary values.
+ auth(_registers.__pc, getAuthSalt());
----------------
DanielKristofKiss wrote:
I have created a version that supports pauth_intrinsics too and made the NOP variant similar to it as possible.
In some configs we can't use the armv8.3 instruction set so for those scenarios I left the NOP space instructions version.
I had to split the signed PC into 2 parts as there is no guarantee for the passes LR doesn't contains significant bits in the location of the PAC bits. Now any value could be in LR as libunwind will preserve it.
https://github.com/llvm/llvm-project/pull/113368
More information about the cfe-commits
mailing list