Pointer authentication config and user facing options#156712
Conversation
This comment has been minimized.
This comment has been minimized.
77fe412 to
b0a7e47
Compare
This comment has been minimized.
This comment has been minimized.
b0a7e47 to
4e8d9e3
Compare
This comment has been minimized.
This comment has been minimized.
4e8d9e3 to
418f447
Compare
This comment has been minimized.
This comment has been minimized.
418f447 to
6af45da
Compare
|
@davidtwco, @folkertdev, @tgross35, @madsmtm FWI this is a follow up to #155722 and #156548 |
|
This PR modifies If appropriate, please update Some changes occurred in src/tools/compiletest cc @jieyouxu The GCC codegen subtree was changed
Some changes occurred in src/doc/rustc/src/platform-support cc @Noratrieb This PR modifies cc @jieyouxu These commits modify compiler targets. |
|
r? @mejrs rustbot has assigned @mejrs. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
82f7a40 to
1c7ac6d
Compare
This comment has been minimized.
This comment has been minimized.
|
Hi, I am not qualified to review this. r? madsmtm or reroll maybe |
57246bd to
b185861
Compare
This comment has been minimized.
This comment has been minimized.
b185861 to
aed511f
Compare
This comment has been minimized.
This comment has been minimized.
aed511f to
68d5206
Compare
There was a problem hiding this comment.
Quick look, will go over in more detail after #155722 (and perhaps a bit before if I get the time).
| } | ||
| } | ||
|
|
||
| pub(crate) fn parse_pointer_authentication_list_with_polarity( |
There was a problem hiding this comment.
Remark: Huh, I thought we'd be better at doing this parsing... I get the sense that this entire module could be simplified a bunch, but the impl you've done here is fine for now.
| "indirect-gotos" => Some(Self::IndirectGotos), | ||
| "init-fini" => Some(Self::InitFini), | ||
| "init-fini-address-discrimination" => Some(Self::InitFiniAddressDiscrimination), | ||
| "intrinsics" => Some(Self::Intrinsics), |
There was a problem hiding this comment.
Nit: This seems like it should just be part of core_intrinsics?
There was a problem hiding this comment.
I'm not sure, probably not.
Intrinsics here refer to the set introduced in <ptrauth.h>. And we only need it for the calculation of the pauth ABI version.
For reference, -fptrauth-intrinsics was introduced to clang here.
| "vt-ptr-addr-discrimination" => Some(Self::VTPtrAddrDisc), | ||
| "vt-ptr-type-discrimination" => Some(Self::VTPtrTypeDisc), | ||
| _ => None, | ||
| } |
There was a problem hiding this comment.
Hmm, we're not following the same naming scheme here as Clang, maybe we should? In particular:
-Zpointer-authentication=+return-addresses<->-fptrauth-returns-Zpointer-authentication=+typeinfo-vt-ptr-discrimination<->-fptrauth-type-info-vtable-pointer-discrimination-Zpointer-authentication=+vt-ptr-addr-discrimination<->-fptrauth-vtable-pointer-address-discrimination-Zpointer-authentication=+vt-ptr-type-discrimination<->-fptrauth-vtable-pointer-type-discrimination
In any case, could you link to Clang's or LLVM's docs on the enum variants for reference?
There was a problem hiding this comment.
I've linked clang's command line reference, slight complication is that we only support a subset of those (for instance we are unlikely to ever interact with obj-c).
Are you saying that:
- we should get rid of
-Zpointer-authenticationall together, - or that the values that the option takes should match exactly how they are spelled out in clang (i.e.
-Zpointer-authentication=+ptrauth-returnsinstead of what it is now:-Zpointer-authentication=+return-addresses)?
One thing that I would say is that the list with polarity provides a nice way to opt-in/opt-out. Without it we would have to duplicate every entry with -Zno-.....
| "whether to use the PLT when calling into shared libraries; | ||
| only has effect for PIC code on systems with ELF binaries | ||
| (default: PLT is disabled if full relro is enabled on x86_64)"), | ||
| pointer_authentication: Vec<(PointerAuthOption, bool)> = (Vec::new(), parse_pointer_authentication_list_with_polarity, [TRACKED], |
There was a problem hiding this comment.
Could you create a new tracking issue for these options, and add docs for this to doc/unstable-book/compiler-flags?
There was a problem hiding this comment.
One unresolved question I'd like to add before we can consider stabilizing this is "correctness"; how do we ensure the security correctness of the implementation, both for the initial implementation, and as the compiler evolves.
68d5206 to
f7791c4
Compare
5e94586 to
90c3ab6
Compare
This comment has been minimized.
This comment has been minimized.
90c3ab6 to
503d1e6
Compare
This patch brings: * unified handling of pointer authentication options through: `-Zpointer-authentication`, with possible values: `aarch64-jump-table-hardening`, `auth-traps`, `calls`, `elf-got`, `function-pointer-type-discrimination`, `indirect-gotos`, `init-fini`, `init-fini-address-discrimination`, `return-addresses`. Toggled with `+`/`-`. * centralized handling of pointer authentication features. Session holds `pointer_auth_config: Option<PointerAuthConfig>` * encapsulation of schema for function pointers and init/fini through `PointerAuthSchema`. This allowed for retiring of `PacMetadata`. * refactor enabling of pointer authentication in code, instead of relying on the target (`pauthtest`) use the session
- warning on unsupported test - error on type discrimination - removal of PointerAuthKind
361b585 to
d601217
Compare
View all comments
This patch brings:
-Zpointer-authentication, with possible values:aarch64-jump-table-hardening,auth-traps,calls,elf-got,function-pointer-type-discrimination,indirect-gotos,init-fini,init-fini-address-discrimination,return-addresses. Toggled with+/-.pointer_auth_config: Option<PointerAuthConfig>PointerAuthSchema. This allowed for retiring ofPacMetadata.relying on the target (
pauthtest) use the session