[libunwind] [libunwind][AArch64] Protect PC within libunwind's context. (PR #113368)
Anton Korobeynikov via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 6 22:51:36 PST 2024
================
@@ -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());
----------------
asl wrote:
Since we're already having support for pointer authentication in frontend, I think it would make sense to use pauth builtins (e.g. `__builtin_ptrauth_auth_and_resign`). Then backend will do necessary things depending on the target features (e.g. if FPAC is enabled)
https://github.com/llvm/llvm-project/pull/113368
More information about the cfe-commits
mailing list