[libunwind] [libunwind][AArch64] Protect PC within libunwind's context. (PR #113368)

Daniel Kiss via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 11 05:54:58 PDT 2025


================
@@ -1845,8 +1986,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 authPC(&_registers, getDiscriminator()); }
+  void setIP(uint64_t value) {
+    // First authenticate the current value of the IP to ensure the context
----------------
DanielKristofKiss wrote:

unwinding starts from a context which is created by the `__unw_getcontext`. 
Here the authentication ensure the context/registers are still pointing to a legitimate address.
without this check any buffer could be used and setIP would just set the arbitrary address and where the restore context would happily jump.
If the `value` is altered outside of libunwind then nothing to do here. Here I assume rest of the application has no idea about PAC. With PAuthAbi this would be different. 

https://github.com/llvm/llvm-project/pull/113368


More information about the cfe-commits mailing list