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

Tracking Issue for control-flow enforcement technology (CET) #93754

Open
1 of 4 tasks
abrown opened this issue Feb 8, 2022 · 7 comments
Open
1 of 4 tasks

Tracking Issue for control-flow enforcement technology (CET) #93754

abrown opened this issue Feb 8, 2022 · 7 comments
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC PG-exploit-mitigations Project group: Exploit mitigations

Comments

@abrown
Copy link
Contributor

abrown commented Feb 8, 2022

This is a tracking issue for standardizing the control-flow enforcement technology (CET) flag, cf-protection.

About tracking issues

Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.

Steps

  • Implement the unstable flag for cf-protection
  • Standardize the cf-protection flag as a -C codegen flag

Unresolved Questions

  • Decide whether it is necessary/advisable to merge similar compilation flags (e.g. cf-guard, cf-protection, branch-protection) under a common flag interface
  • Decide whether to build the standard libraries with cf-protection by default

If we do build the standard libraries with cf-protection enabled, any assembly code in the libraries will need to be manually checked to see to it that when this flag is set, ENDBR* instructions are inserted in the right places.

Implementation history

See #93439.

@abrown abrown added the C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC label Feb 8, 2022
bors added a commit to rust-lang-ci/rust that referenced this issue Feb 15, 2022
Add support for control-flow protection

This change adds a flag for configuring control-flow protection in the LLVM backend. In Clang, this flag is exposed as `-fcf-protection` with options `none|branch|return|full`. This convention is followed for `rustc`, though as a codegen option: `rustc -Z cf-protection=<none|branch|return|full>`. Tracking issue for future work is rust-lang#93754.
@xnox
Copy link

xnox commented Feb 23, 2022

In distributions that already elect to build everything with CET enabled by default, we would want to turn it on by default in the rustc compiler and use it for the standard library, and everything by default.

The question is simply as to when. And what can be done to get there. I wonder if we could attempt rebuilding all packages with CET in the distribution to see how far the coverage goes.

@cuviper
Copy link
Member

cuviper commented Feb 23, 2022

In distributions that already elect to build everything with CET enabled by default, we would want to turn it on by default in the rustc compiler and use it for the standard library, and everything by default.

I don't see any way we could conditionally-default CET for rustup toolchains, but I think the way to go is to make it a rustbuild option, for such distributions to use when building their own Rust toolchain.

@haraldh
Copy link
Contributor

haraldh commented Jul 1, 2022

one issue:
#98768

@workingjubilee
Copy link
Member

Decide whether it is necessary/advisable to merge similar compilation flags (e.g. cf-guard, cf-protection, branch-protection) under a common flag interface

If these are going to be independent compiler flags and not, say, target features, then yes, it may be a good idea to coalesce these. At least, certainly when the feature is functionally identical (e.g. branch-protection=bti vs. cf-protection=branch).

@tgross35
Copy link
Contributor

tgross35 commented Oct 10, 2023

Could we get a better summary of the status is here? There is this issue (cc @abrown), a tracking issue with no content for cf-protection stratis-storage/project#418 (cc @mulkieran) and a tracking issue specifically for cf-branch-protection's stabilization (a tracking issue for stabilization seems a bit unusual) #113369 (cc @jacobbramley). Then there's the CFI issue #89653 and RFC rust-lang/rfcs#3296 (cc @rcvalle), which aren't the same thing but cover similar areas.

My feeling is that since cf-protection is just a LLVM flag that has been in the compiler for two years, we can probably stabilize something here if someone makes a proposal about what flags to use, which will go through FCP. But the tracking issues are kind of chaotic, need to figure out what is going on there first

@jacobbramley
Copy link
Contributor

@tgross35 I just updated #113369 with a link to a Zulip thread regarding merging with cf-protection (or not). I'd welcome further input!

@tgross35
Copy link
Contributor

Thanks for the update Jacob, I think following up on Zulip is a good direction to go toward getting this done 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: An issue tracking the progress of sth. like the implementation of an RFC PG-exploit-mitigations Project group: Exploit mitigations
Projects
None yet
Development

No branches or pull requests

8 participants