CFI: Support function pointers for trait methods by maurer · Pull Request #12305...
source link: https://github.com/rust-lang/rust/pull/123052
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
CFI: Support function pointers for trait methods #123052
Conversation
Contributor
Adds support for both CFI and KCFI for function pointers to trait methods by attaching both concrete and abstract types to functions.
KCFI does this through generation of a ReifyShim
on any function pointer for a method that could go into a vtable, and keeping this separate from ReifyShim
s that are intended for vtable us by setting a ReifyReason
on them.
CFI does this by setting both the concrete and abstract type on every instance.
This should land after #123024 or a similar PR, as it diverges the implementation of CFI vs KCFI.
added A-testsuite Area: The testsuite used to check the correctness of rustc PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
labels
Collaborator
These commits modify compiler targets. Some changes occurred in compiler/rustc_symbol_mangling/src/typeid cc @rust-lang/project-exploit-mitigations, @rcvalle Some changes occurred in tests/ui/sanitizer cc @rust-lang/project-exploit-mitigations, @rcvalle Some changes occurred in src/tools/compiletest cc @jieyouxu Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
since this touches regular codegen by adding a @bors try @rust-timer queue |
This comment has been minimized.
added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label
Collaborator
Some changes occurred in tests/codegen/sanitizer cc @rust-lang/project-exploit-mitigations, @rcvalle |
Contributor
☔ The latest upstream changes (presumably #123065) made this pull request unmergeable. Please resolve the merge conflicts. |
Contributor
☔ The latest upstream changes (presumably #123071) made this pull request unmergeable. Please resolve the merge conflicts. |
I really don't expect perf to come back with anything other than neutral here, but -- @bors try @rust-timer queue |
This comment has been minimized.
Contributor
☀️ Try build successful - checks-actions |
This comment has been minimized.
Collaborator
Finished benchmarking commit (0f5b741): comparison URL. Overall result: ✅ improvements - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)Results CyclesResults Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 667.526s -> 668.303s (0.12%) |
@@ -147,7 +147,7 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> { | ||
for options in [ |
||
TypeIdOptions::GENERALIZE_POINTERS, |
||
TypeIdOptions::NORMALIZE_INTEGERS, |
||
TypeIdOptions::NO_SELF_TYPE_ERASURE, |
||
TypeIdOptions::ERASE_SELF_TYPE, |
I don't know, I kinda disagree with the change to the NO_SELF_TYPE_ERASURE. I think the default should be what is going to be done most of the time or more commonly, and it's performing type erasure. The exception for the secondary type id should be opted in when needed.
Contributor
Author
I don't have a strong preference - I like this version a little better due to the "positive" nature of it.
With regards to defaults vs secondary, only KCFI has a meaningful notion of a "default" type ID - CFI attaches all of them to the same attachment site, so none of them are really primary or secondary. KCFI still sets ERASE_SELF_TYPE
as its default with this changeset.
That said, if this change is contentious and not required by compiler-errors to land this PR, I don't really care to fight over this.
It's secondary because these are not always included. They're only included when they're unique and for methods, and also are only tested for when methods are used as function pointers so the concept of secondary does apply generally.
// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_{{[[:print:]]+}}6Trait1u6regionEEE"} |
||
// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_{{[[:print:]]+}}5Type1EE"} |
||
// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_{{[[:print:]]+}}5Type1EE"} |
||
// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_{{[[:print:]]+}}6Trait1u6regionEEE"} |
As a result of what I mentioned above, it seems the type id order also changed here.
Contributor
Author
Yes. I'm not sure why the type order changing is an issue if we only have one test that checks it.
The tests aren't an issue now. My disagreement is with the less common case (i.e., not performing self type erasure/the secondary type id) being the default behavior and also the first type id.
Contributor
Author
@rustbot ready |
added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
labels
added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
labels
Contributor
💔 Test failed - checks-actions |
added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
labels
added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
labels
Contributor
☀️ Test successful - checks-actions |
Collaborator
Finished benchmarking commit (29fe618): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 667.94s -> 669.353s (0.21%) |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Successfully merging this pull request may close these issues.
None yet
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK