Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for LLVM ShadowCallStack. #98208

Merged
merged 1 commit into from
Jul 23, 2022
Merged

Add support for LLVM ShadowCallStack. #98208

merged 1 commit into from
Jul 23, 2022

Conversation

ivanloz
Copy link
Contributor

@ivanloz ivanloz commented Jun 17, 2022

LLVMs ShadowCallStack provides backward edge control flow integrity protection by using a separate shadow stack to store and retrieve a function's return address.

LLVM currently only supports this for AArch64 targets. The x18 register is used to hold the pointer to the shadow stack, and therefore this only works on ABIs which reserve x18. Further details are available in the LLVM ShadowCallStack docs.

Usage

-Zsanitizer=shadow-call-stack

Comments/Caveats

  • Currently only enabled for the aarch64-linux-android target
  • Requires the platform to define a runtime to initialize the shadow stack, see the LLVM docs for more detail.

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

r? @compiler-errors

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

@rust-highfive
Copy link
Collaborator

⚠️ Warning ⚠️

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 17, 2022
@rust-log-analyzer

This comment has been minimized.

@compiler-errors
Copy link
Member

I'm not an expert in codegen so passing this to another compiler person

r? rust-lang/compiler

@oli-obk
Copy link
Contributor

oli-obk commented Jun 23, 2022

cc @rust-lang/wg-llvm

@ivanloz
Copy link
Contributor Author

ivanloz commented Jul 6, 2022

Friendly ping for review? Thanks!

@oli-obk
Copy link
Contributor

oli-obk commented Jul 7, 2022

r? @nagisa

I don't really know enough about this to make a real decision.

@rust-highfive rust-highfive assigned nagisa and unassigned oli-obk Jul 7, 2022
@ivanloz
Copy link
Contributor Author

ivanloz commented Jul 14, 2022

Friendly ping for review, thanks!

@nikic
Copy link
Contributor

nikic commented Jul 14, 2022

Not familiar with this sanitizer, but the implementation looks fine to me. Only suggestion I'd make is to also add a #[no_sanitize(shadow-call-stack)] variant to your test -- for the unusual spelling if nothing else.

src/test/codegen/sanitizer_scs_attr_check.rs Show resolved Hide resolved
src/test/codegen/sanitizer_scs_attr_check.rs Outdated Show resolved Hide resolved
compiler/rustc_span/src/symbol.rs Outdated Show resolved Hide resolved
@nagisa
Copy link
Member

nagisa commented Jul 16, 2022

Friendly ping for review, thanks!

FWIW I only really have time for reviews on the weekends, and summer is also a vacation season, so it might be some time before I can get to reviewing a PR.

@bors
Copy link
Contributor

bors commented Jul 18, 2022

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

Adds support for the LLVM ShadowCallStack sanitizer.
@ivanloz
Copy link
Contributor Author

ivanloz commented Jul 20, 2022

Thanks for the review! I believe I've addressed all the comments.

And also thanks for the heads up on when you're able to handle reviews -- totally understand and appreciate the value of recharging.

@nagisa
Copy link
Member

nagisa commented Jul 23, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Jul 23, 2022

📌 Commit adf61e3 has been approved by nagisa

It is now in the queue for this repository.

@bors bors 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 Jul 23, 2022
@bors
Copy link
Contributor

bors commented Jul 23, 2022

⌛ Testing commit adf61e3 with merge 93ffde6...

@bors
Copy link
Contributor

bors commented Jul 23, 2022

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

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 23, 2022
@bors bors merged commit 93ffde6 into rust-lang:master Jul 23, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jul 23, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (93ffde6): comparison url.

Instruction count

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

Max RSS (memory usage)

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

Cycles

Results
  • Primary benchmarks: 🎉 relevant improvement found
  • Secondary benchmarks: 🎉 relevant improvements found
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
N/A N/A 0
Improvements 🎉
(primary)
-3.2% -3.2% 1
Improvements 🎉
(secondary)
-2.7% -3.4% 6
All 😿🎉 (primary) -3.2% -3.2% 1

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 3

  2. number of relevant changes 2 3

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. 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.

10 participants