← Back to Pull requests

[Docs] Add documentation for ptrauth ELF module flags #237916

Merged
smithp35 merged 1 files (20 lines) on Dec 01, 2026 11:36 UTC
View on GitHub
smithp35 smithp35 commented on Nov 02, 2026 11:22 UTC
Author

There are four module flags that influence code-generation for PAuthABI on ELF platforms.

ptrauth-elf-got
ptrauth-init-fini
ptrauth-init-fini-address-discrimination
ptrauth-sign-personality

Although largely self-explanatory, add a section in the documentation to collect all the available module flags.

The ptrauth-init-fini module flags will work on the Mach-O equivalents, but they are intended only to be used on ELF platforms.

Diff: 20 lines (+20 / -0) across 1 files Reviewer: kovdan01 Review duration: 41774m
All Vouch review confidence checks passed
Residual risk 0.04 = Change Risk (0.44) × (1 − Review Confidence (0.91)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.44 · 20 lines diff across 1 files
0.44
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.90 · 5 substantive comment(s)
0.90
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
90%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.182
Sensitive Paths sensitive_paths
0.044
Real PR Conversation Timeline
16 items
kovdan01 kovdan01 commented on code on Nov 02, 2026 15:50 UTC
Code Review
llvm/docs/PointerAuth.md:1
@@ -400,3 +400,18 @@ as follows:
 | ----------------- | -------- | -------- | -------- | ------------- | ------------------- |
 | address diversity | reserved | key      | reserved | discriminator | reserved for addend |
 ```
+
+#### ELF Module flags
+
+The following module flags control aspects of code-generation for
+pointer authentication on ELF platforms.
+
+* `ptrauth-elf-got` is a flag that determines if the GOT is signed
+  with the process-independent instruction key.
+* `ptrauth-init-fini` is a flag that determines if the pointers in
+  .init and .fini are signed with the process-independent instruction

The Keys subsection of this document does not seem to use this process-dependent/independent terms: https://github.com/llvm/llvm-project/blob/main/llvm/docs/PointerAuth.md#keys

Would it be better to avoid such terms here as well (as not defined in the document)? Especially given that e.g. on Linux, to the best of my knowledge, all 4 keys are generated uniquely for each process

Same applies to the ptrauth-elf-got point above

kovdan01 kovdan01 commented on code on Nov 02, 2026 15:51 UTC
Code Review
llvm/docs/PointerAuth.md:1
@@ -400,3 +400,18 @@ as follows:
 | ----------------- | -------- | -------- | -------- | ------------- | ------------------- |
 | address diversity | reserved | key      | reserved | discriminator | reserved for addend |
 ```
+
+#### ELF Module flags
+
+The following module flags control aspects of code-generation for
+pointer authentication on ELF platforms.
+
+* `ptrauth-elf-got` is a flag that determines if the GOT is signed
+  with the process-independent instruction key.
+* `ptrauth-init-fini` is a flag that determines if the pointers in
+  .init and .fini are signed with the process-independent instruction

You've likely meant .init_array and .fini_array, not .init/.fini. The point about address discrimination below is also probably worth updating accordingly.

kovdan01 kovdan01 commented on code on Nov 02, 2026 15:56 UTC
Code Review
llvm/docs/PointerAuth.md:1
@@ -400,3 +400,18 @@ as follows:
 | ----------------- | -------- | -------- | -------- | ------------- | ------------------- |
 | address diversity | reserved | key      | reserved | discriminator | reserved for addend |
 ```
+
+#### ELF Module flags

Would it be better to name it somehow like "ELF-Specific IR Module Flags"? My concern is that now "ELF Module" might be misinterpreted as single entity by a non-specialist reader

kovdan01 kovdan01 commented on code on Nov 02, 2026 15:56 UTC
Code Review
llvm/docs/PointerAuth.md:1
@@ -400,3 +400,18 @@ as follows:
 | ----------------- | -------- | -------- | -------- | ------------- | ------------------- |
 | address diversity | reserved | key      | reserved | discriminator | reserved for addend |
 ```
+
+#### ELF Module flags
+
+The following module flags control aspects of code-generation for
+pointer authentication on ELF platforms.
+
+* `ptrauth-elf-got` is a flag that determines if the GOT is signed
+  with the process-independent instruction key.

While the instruction key IA is used for STT_FUNC symbols, the DA data key is used for other symbol types. So "instruction key" sounds not quire precise here, if I'm not missing smth.

kovdan01 kovdan01 commented on Nov 02, 2026 15:57 UTC
Reviewer

Would it be worth also mentioning the ptrauth-sign-personality IR module flag?

smithp35 smithp35 commented on code on Nov 03, 2026 15:32 UTC
Code Review
llvm/docs/PointerAuth.md:1
@@ -400,3 +400,18 @@ as follows:
 | ----------------- | -------- | -------- | -------- | ------------- | ------------------- |
 | address diversity | reserved | key      | reserved | discriminator | reserved for addend |
 ```
+
+#### ELF Module flags
+
+The following module flags control aspects of code-generation for
+pointer authentication on ELF platforms.
+
+* `ptrauth-elf-got` is a flag that determines if the GOT is signed
+  with the process-independent instruction key.
+* `ptrauth-init-fini` is a flag that determines if the pointers in
+  .init and .fini are signed with the process-independent instruction

That is an interesting question, and as I've used the terms process-independent and process-dependent key in the driver and LLVM patches to match what is written in https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/ptrauth.h#L19

While not mentioned in llvm there is some documentation in the clang equivalent https://clang.llvm.org/docs/PointerAuthentication.html#key-assignments quoted below [1]

Granted that the concept of process-dependent and process-independent is arm64e specific, but the same conventions are followed by Linux (and bare-metal default), I'm thinking what the best way forward is. Some options:

1.) Adopt the "ptrauth.h" arm64e naming conventions, even if the keys may not actually be process-independent. Then all the names in ptrauth.h and the one other reference I could find in https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/Attr.td#L5494 would match up. I think that would need some additional documentation in clang to state that on non arm64e the same naming conventions are used, even if the keys are not actually process independent. I would need to add documentation to the key assignment in LLVM too.

2.) For LLVM, which doesn't have any references to the process-independent and process-dependent keys we could use "global (A key)" and "local (B key)" for process-independent and process-dependent respectively. I will alter my LLVM and clang patches to use global-code, global-data, local-code and local-data (with comments stating the mapping to Clang's process-independent and process-dependent.

I don't think I can touch the use of process-independent and process-dependent in ptrauth.h as that might break existing code.

Any preferences? I think global and local are better and shorter, but there's some benefit in being consistent with ptrauth.h.

[1] quote from clang key-assignments:

arm64e then further subdivides the keys as follows:

>The A keys are used for primarily “global” purposes like signing v-tables and function pointers. These keys are sometimes called process-independent or cross-process because on existing OSes they are not changed when changing processes, although this is not a platform guarantee.

> The B keys are used for primarily “local” purposes like signing return addresses. These keys are sometimes called process-specific because they are typically different between processes. However, they are in fact shared across processes in one situation: systems which provide fork cannot change these keys in the child process; they can only be changed during exec.

smithp35 smithp35 commented on code on Nov 03, 2026 15:32 UTC
Code Review
llvm/docs/PointerAuth.md:1
@@ -400,3 +400,18 @@ as follows:
 | ----------------- | -------- | -------- | -------- | ------------- | ------------------- |
 | address diversity | reserved | key      | reserved | discriminator | reserved for addend |
 ```
+
+#### ELF Module flags
+
+The following module flags control aspects of code-generation for
+pointer authentication on ELF platforms.
+
+* `ptrauth-elf-got` is a flag that determines if the GOT is signed
+  with the process-independent instruction key.
+* `ptrauth-init-fini` is a flag that determines if the pointers in
+  .init and .fini are signed with the process-independent instruction

Thanks, will fix.

smithp35 smithp35 commented on code on Nov 03, 2026 15:32 UTC
Code Review
llvm/docs/PointerAuth.md:1
@@ -400,3 +400,18 @@ as follows:
 | ----------------- | -------- | -------- | -------- | ------------- | ------------------- |
 | address diversity | reserved | key      | reserved | discriminator | reserved for addend |
 ```
+
+#### ELF Module flags

OK, will do.

smithp35 smithp35 commented on code on Nov 03, 2026 15:34 UTC
Code Review
llvm/docs/PointerAuth.md:1
@@ -400,3 +400,18 @@ as follows:
 | ----------------- | -------- | -------- | -------- | ------------- | ------------------- |
 | address diversity | reserved | key      | reserved | discriminator | reserved for addend |
 ```
+
+#### ELF Module flags
+
+The following module flags control aspects of code-generation for
+pointer authentication on ELF platforms.
+
+* `ptrauth-elf-got` is a flag that determines if the GOT is signed
+  with the process-independent instruction key.

Thanks, I expect you're right there and both instruction and data keys can be used. Will double check and update.

smithp35 smithp35 commented on Nov 03, 2026 16:11 UTC
Author

Thanks for the comments. I've updated the patch to not use process-independent and process-dependent, and have applied the corrections.

Definitely interested in opinions on whether I should avoid using process-independent and process-dependent throughout the remainder of the patch set.

I'm inclined to try and use global and local where possible, with mappings to process-independent and process-dependent. Global and local would fit bare-metal much better as there may not even be the concept of a process.

kovdan01 kovdan01 approved these changes on Nov 16, 2026 22:20 UTC
Approved Reviewer

LGTM, thanks! And, as discussed during the call, it would be very nice to adopt global/local terminology throughout the documentation where applicable.

One minor nit-pick remaining in context of this PR though:

Would it be worth also mentioning the ptrauth-sign-personality IR module flag?

smithp35 smithp35 commented on Nov 17, 2026 14:16 UTC
Author

LGTM, thanks! And, as discussed during the call, it would be very nice to adopt global/local terminology throughout the documentation where applicable.

> One minor nit-pick remaining in context of this PR though:

> > Would it be worth also mentioning the ptrauth-sign-personality IR module flag?

Yes, apologies for missing that one. I've added it to the patch and have updated the description. Let me know if you'd like any changes, or whether I should split into a separate patch?

kovdan01 kovdan01 commented on code on Nov 30, 2026 16:46 UTC
Code Review
llvm/docs/PointerAuth.md:1
@@ -400,3 +400,23 @@ as follows:
 | ----------------- | -------- | -------- | -------- | ------------- | ------------------- |
 | address diversity | reserved | key      | reserved | discriminator | reserved for addend |
 ```
+
+#### ELF-Specific IR Module flags
+
+The following module flags control aspects of code-generation for
+pointer authentication on ELF platforms.
+
+* `ptrauth-elf-got` is a flag that determines if the GOT is
+  signed. Code pointers in the GOT are signed with the global
+  instruction key (`ASIA`). Data pointers are signed with the global
+  data key (`ASDA`).
+* `ptrauth-init-fini` is a flag that determines if the pointers in
+  `.init_array` and `.fini_array` are signed with the global
+  instruction key (`ASIA`).
+* `ptrauth-init-fini-address-discrimination` is a flag used in
+  combination with `ptrauth-init-fini`, it determines whether address
+  diversity is used in the discriminator for the pointers in the
+  `.init_array` and `.fini_array`.
+* `ptrauth-sign-personality` is a flag that determines if the pointer
+  to the personality routine `DW.ref.__gxx_personality_v0` is signed

Nit: I guess that the personality routine is actually __gxx_personality_v0, while the DW.ref.__gxx_personality_v0 is an object containing the pointer to it. Like:

DW.ref.__gxx_personality_v0:
    .xword __gxx_personality_v0@AUTH(ia,32429,addr)

Might be worth making it clear here to avoid misunderstanding by someone not too deeply in the context and trying to figure out why this DW.ref.... object is called a personality routine :)

kovdan01 kovdan01 approved these changes on Nov 30, 2026 16:47 UTC
Approved Reviewer

LGTM module one very minor nit-pick, thanks!

smithp35 smithp35 commented on code on Dec 01, 2026 11:32 UTC
Code Review
llvm/docs/PointerAuth.md:1
@@ -400,3 +400,23 @@ as follows:
 | ----------------- | -------- | -------- | -------- | ------------- | ------------------- |
 | address diversity | reserved | key      | reserved | discriminator | reserved for addend |
 ```
+
+#### ELF-Specific IR Module flags
+
+The following module flags control aspects of code-generation for
+pointer authentication on ELF platforms.
+
+* `ptrauth-elf-got` is a flag that determines if the GOT is
+  signed. Code pointers in the GOT are signed with the global
+  instruction key (`ASIA`). Data pointers are signed with the global
+  data key (`ASDA`).
+* `ptrauth-init-fini` is a flag that determines if the pointers in
+  `.init_array` and `.fini_array` are signed with the global
+  instruction key (`ASIA`).
+* `ptrauth-init-fini-address-discrimination` is a flag used in
+  combination with `ptrauth-init-fini`, it determines whether address
+  diversity is used in the discriminator for the pointers in the
+  `.init_array` and `.fini_array`.
+* `ptrauth-sign-personality` is a flag that determines if the pointer
+  to the personality routine `DW.ref.__gxx_personality_v0` is signed

Ack. Have changed to __gc_personality_v0.

Reviewers
Assignees
smithp35 smithp35
Labels
risk: low confidence: 90.8% reviewed sensitive_module
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 44.4% (MEDIUM) · Higher = larger blast radius
44.4%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 90.8% · Lower = rushed or shallow review
90.8%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 4.1% · Safe to merge
4.1%