Adding Pointer-Authentication Protection For Free List Forward Edge#840
Adding Pointer-Authentication Protection For Free List Forward Edge#840Pengxiang-Huang wants to merge 2 commits intomicrosoft:mainfrom
Conversation
Co-authored-by: Schrodinger ZHU Yifan <i@zhuyi.fan>
|
@microsoft-github-policy-service agree |
|
I think we can just I remember being told inside llvm-libc that PAC hints are no-op on arch without support. So it might also be okay to have it on aarch64 as long as user enable the mitigation. I don't have time to exactly verify this. The following materials are summarized by Codex with ChatGPT 5.4 (high):
|
There was a problem hiding this comment.
Pull request overview
This PR adds Pointer Authentication Code (PAC) support for forward-edge protection of freelist “next” pointers on AArch64, integrating it into snmalloc’s AAL feature system and wiring up CMake detection/flags.
Changes:
- Introduces a new
PtrAuthenticationAAL feature and generic AAL helpers for signing/authenticating stored pointers. - Implements ARM AAL support using
ptrauth.h(when available) and applies PAC to freelist forward-edge encoding/decoding. - Extends CMake configuration to probe for PAC support and define/enable the feature.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| CMakeLists.txt | Detects PAC support and adds build flags / defines to enable the feature. |
| src/snmalloc/aal/aal.h | Adds generic AAL wrappers for pointer sign/auth operations. |
| src/snmalloc/aal/aal_consts.h | Adds PtrAuthentication to the AalFeatures enum. |
| src/snmalloc/aal/aal_arm.h | Implements ARM PAC sign/auth via ptrauth.h under feature guards. |
| src/snmalloc/mem/freelist.h | Uses PAC for freelist forward-edge protection when supported, else falls back to existing schemes. |
|
@mjp41 could you take a look when you get time? |
|
Thanks for doing this. I have some high-level questions
Do you have thoughts on this? I am probably misunderstanding PAC on ARM. |
|
@mjp41 Thanks for your reply! Here is my humble opinion:
|
Would you be able to adjust the Github actions to do that. You should be able to run the actions on a personal fork. I have to approve new contributors Github Action runs manually (Microsoft policy).
Thanks. I mostly agree with you. The XOR is not great. It is the bare minimum. It is pretty dependent on the adversary model if it provides any protection. I think offering this as an option would be great. I am not sure I know which is more important integrity or confidentiality. The back edge in the other part of the allocation provides a pretty strong integrity protection as it requires an arbitrary write to by pass, and by the time an attacker has an arbitrary write, the allocator is probably not going to be the route to increased priviledge. |
I found out that the CI test for the last commit has shown that PAC was enabled and tested in macos 14/15 arm64 jobs: https://github.com/microsoft/snmalloc/actions/runs/23927647563/job/69791221236, But it does not make PAC a required property for those runners, so it can fall back to the XOR approach and CI jobs will still pass. IIUC, do you want to create a CI job such that it fails when PAC is not available? |
Co-authored-by: Schrodinger ZHU Yifan i@zhuyi.fan
The implementation is largely based on the original code proposed in this issue: #838 @SchrodingerZhu
I did some correctness changes for the cmake; some minor fixes; and adding a few comments;
I run and verify this PAC feature on my local Mac environment with Apple Clang 17.