Skip to content
This repository has been archived by the owner on May 12, 2022. It is now read-only.

Enable Control Flow Guard #16

Open
2 tasks
yvt opened this issue Feb 22, 2020 · 1 comment
Open
2 tasks

Enable Control Flow Guard #16

yvt opened this issue Feb 22, 2020 · 1 comment
Labels
enhancement New feature or request

Comments

@yvt
Copy link
Owner

yvt commented Feb 22, 2020

Control Flow Guard is a forward-edge control-flow integrity mechanism supported by Windows.

https://docs.microsoft.com/en-us/windows/win32/secbp/control-flow-guard:

Control Flow Guard (CFG) is a highly-optimized platform security feature that was created to combat memory corruption vulnerabilities.

https://docs.microsoft.com/en-us/cpp/build/reference/guard-enable-control-flow-guard?view=vs-2019:

A common attack on software takes advantage of bugs in handling extreme or unexpected inputs. Carefully crafted input to the application may overwrite a location that contains a pointer to executable code. This can be used to redirect control flow to code controlled by the attacker. The CFG runtime checks do not fix the data corruption bugs in your executable. They instead make it more difficult for an attacker to use them to execute arbitrary code. CFG is a mitigation tool that prevents calls to locations other than function entry points in your code.

According to [Burow2017], the execution time overhead measured with the SPEC CPU2006 benchmarks ranges between -0.3–10.8% with a geometric mean of 2.3%.

[Burow2017] Burow, Nathan, et al. "Control-flow integrity: Precision, security, and performance." ACM Computing Surveys (CSUR) 50.1 (2017): 1-33.

The compiler implementation of CFGuard is comprised of two parts: The first part is to emit metadata indicating valid entry points, and the second part is to insert runtime checks before indirect call instructions. In LLVM, the first part was there for a quite long time, but the patch adding the second part was merged only in 2019. The support for CFGuard in Rust has been introduced in rust-lang/rust#68180.

The option for enabling CFGuard is currently feature-gated by -Z control_flow_guard, whose tracking issue can be found at rust-lang/rust#68793.

  • Enable in CI builds
  • Wait for the stabilization of -Z control_flow_guard
@yvt yvt added the enhancement New feature or request label Feb 22, 2020
@ajpaverd
Copy link

The -C control-flow-guard option has now been stabilized and is available in Rust 1.47.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants