Skip to content

Add fine-grained LLVM CFI support to the Rust compiler#95548

Merged
bors merged 2 commits intorust-lang:masterfrom
rcvalle:rust-cfi-2
Jul 24, 2022
Merged

Add fine-grained LLVM CFI support to the Rust compiler#95548
bors merged 2 commits intorust-lang:masterfrom
rcvalle:rust-cfi-2

Conversation

@rcvalle
Copy link
Member

@rcvalle rcvalle commented Apr 1, 2022

This PR improves the LLVM Control Flow Integrity (CFI) support in the Rust compiler by providing forward-edge control flow protection for Rust-compiled code only by aggregating function pointers in groups identified by their return and parameter types.

Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by identifying C char and integer type uses at the time types are encoded (see Type metadata in the design document in the tracking issue #89653).

LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e., -Clto).

Thank you again, @eddyb, @nagisa, @pcc, and @tmiasko for all the help!

@rust-highfive
Copy link
Contributor

Some changes occured to rustc_codegen_gcc

cc @antoyo

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Apr 1, 2022
@rust-highfive
Copy link
Contributor

r? @davidtwco

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 1, 2022
@rcvalle
Copy link
Member Author

rcvalle commented Apr 1, 2022

r? @nagisa

@rust-highfive rust-highfive assigned nagisa and unassigned davidtwco Apr 1, 2022
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@nagisa nagisa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a style pass. Too late for me to review the itanium thing but I imagine @tmiasko did a thorough pass through it already.

@nagisa
Copy link
Member

nagisa commented Jul 5, 2022

@bors try

@bors
Copy link
Collaborator

bors commented Jul 5, 2022

⌛ Trying commit 26e0e2fa35ec940179f6a6958695f5c983d9838f with merge f3b1bd9b4aaafaa85ca8ac59698ca6ac1b6c839d...

@bors
Copy link
Collaborator

bors commented Jul 5, 2022

💔 Test failed - checks-actions

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Jul 6, 2022

☔ The latest upstream changes (presumably #98206) made this pull request unmergeable. Please resolve the merge conflicts.

@workingjubilee
Copy link
Member

@bors try

@bors
Copy link
Collaborator

bors commented Jul 6, 2022

⌛ Trying commit 7845e5af761b3bea8366f1f88ba10bc8e906cab0 with merge a607188a97cc5cd4d066808cbba3681a504ec3f0...

@bors
Copy link
Collaborator

bors commented Jul 6, 2022

☀️ Try build successful - checks-actions
Build commit: a607188a97cc5cd4d066808cbba3681a504ec3f0 (a607188a97cc5cd4d066808cbba3681a504ec3f0)

@nagisa
Copy link
Member

nagisa commented Jul 6, 2022

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 6, 2022

📌 Commit 7845e5af761b3bea8366f1f88ba10bc8e906cab0 has been approved by nagisa

@bors
Copy link
Collaborator

bors commented Jul 9, 2022

⌛ Testing commit 7845e5af761b3bea8366f1f88ba10bc8e906cab0 with merge b7043630dfadc284e196852738595393d6c541e7...

@bors
Copy link
Collaborator

bors commented Jul 9, 2022

💔 Test failed - checks-actions

@rust-log-analyzer

This comment has been minimized.

@Dylan-DPC
Copy link
Member

@bors rollup=iffy

@bors
Copy link
Collaborator

bors commented Jul 20, 2022

⌛ Testing commit 7845e5af761b3bea8366f1f88ba10bc8e906cab0 with merge 63a9c9d05059ba6cdb67b75bee1429c7166bb9fd...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Jul 20, 2022

💔 Test failed - checks-actions

@nagisa
Copy link
Member

nagisa commented Jul 23, 2022

@bors r+ rollup=never

@bors
Copy link
Collaborator

bors commented Jul 23, 2022

📌 Commit c8d90e270275f980ea42e76ccc3a52fe67d31cc4 has been approved by nagisa

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Jul 23, 2022

⌛ Testing commit c8d90e270275f980ea42e76ccc3a52fe67d31cc4 with merge 5c514af3814b732c3702d4f9069e3bf8ae71aa85...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Jul 23, 2022

💔 Test failed - checks-actions

rcvalle added 2 commits July 23, 2022 10:51
This commit improves the LLVM Control Flow Integrity (CFI) support in
the Rust compiler by providing forward-edge control flow protection for
Rust-compiled code only by aggregating function pointers in groups
identified by their return and parameter types.

Forward-edge control flow protection for C or C++ and Rust -compiled
code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code
share the same virtual address space) will be provided in later work as
part of this project by identifying C char and integer type uses at the
time types are encoded (see Type metadata in the design document in the
tracking issue rust-lang#89653).

LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e.,
-Clto).
This commit updates the documentation for the LLVM Control Flow
Integrity (CFI) support in the Rust compiler (see rust-lang#95548 and rust-lang#89653).
@nagisa
Copy link
Member

nagisa commented Jul 23, 2022

@bors r+

@bors
Copy link
Collaborator

bors commented Jul 23, 2022

📌 Commit f792f26 has been approved by nagisa

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Jul 24, 2022

⌛ Testing commit f792f26 with merge db8086e...

@bors
Copy link
Collaborator

bors commented Jul 24, 2022

☀️ Test successful - checks-actions
Approved by: nagisa
Pushing db8086e to master...

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (db8086e): comparison url.

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results
  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: 😿 relevant regressions found
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
3.6% 4.8% 2
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
N/A N/A 0
All 😿🎉 (primary) N/A N/A 0

Cycles

Results
  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: mixed results
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
3.4% 3.4% 1
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
-3.1% -3.1% 1
All 😿🎉 (primary) N/A N/A 0

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

Footnotes

  1. the arithmetic mean of the percent change 2

  2. number of relevant changes 2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-bors This PR was explicitly merged by bors. PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.