Skip to content

Commit e1741ba

Browse files
rcvalleojeda
andcommitted
Add documentation for LLVM KCFI support
This commit adds initial documentation for LLVM Kernel Control Flow Integrity (KCFI) support to the Rust compiler (see #105109 and #89653). Co-authored-by: Miguel Ojeda <ojeda@users.noreply.github.com>
1 parent 65698ae commit e1741ba

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

src/doc/unstable-book/src/compiler-flags/sanitizer.md

+30
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ This feature allows for use of one of following sanitizers:
1414
forward-edge control flow protection.
1515
* [HWAddressSanitizer](#hwaddresssanitizer) a memory error detector similar to
1616
AddressSanitizer, but based on partial hardware assistance.
17+
* [KernelControlFlowIntegrity](#kernelcontrolflowintegrity) LLVM Kernel Control
18+
Flow Integrity (KCFI) provides forward-edge control flow protection for
19+
operating systems kernels.
1720
* [LeakSanitizer](#leaksanitizer) a run-time memory leak detector.
1821
* [MemorySanitizer](#memorysanitizer) a detector of uninitialized reads.
1922
* [MemTagSanitizer](#memtagsanitizer) fast memory error detector based on
@@ -502,6 +505,32 @@ Registers where the failure occurred (pc 0xaaaae0ae4a98):
502505
SUMMARY: HWAddressSanitizer: tag-mismatch (/.../main+0x54a94)
503506
```
504507
508+
# KernelControlFlowIntegrity
509+
510+
The LLVM Kernel Control Flow Integrity (CFI) support to the Rust compiler
511+
initially provides forward-edge control flow protection for operating systems
512+
kernels for Rust-compiled code only by aggregating function pointers in groups
513+
identified by their return and parameter types. (See [LLVM commit cff5bef "KCFI
514+
sanitizer"](https://github.com/llvm/llvm-project/commit/cff5bef948c91e4919de8a5fb9765e0edc13f3de).)
515+
516+
Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed
517+
binaries" (i.e., for when C or C++ and Rust -compiled code share the same
518+
virtual address space) will be provided in later work by defining and using
519+
compatible type identifiers (see Type metadata in the design document in the
520+
tracking issue [#89653](https://github.com/rust-lang/rust/issues/89653)).
521+
522+
LLVM KCFI can be enabled with `-Zsanitizer=kcfi`.
523+
524+
LLVM KCFI is supported on the following targets:
525+
526+
* `aarch64-linux-android`
527+
* `aarch64-unknown-linux-gnu`
528+
* `x86_64-linux-android`
529+
* `x86_64-unknown-linux-gnu`
530+
531+
See the [Clang KernelControlFlowIntegrity documentation][clang-kcfi] for more
532+
details.
533+
505534
# LeakSanitizer
506535
507536
LeakSanitizer is run-time memory leak detector.
@@ -693,6 +722,7 @@ Sanitizers produce symbolized stacktraces when llvm-symbolizer binary is in `PAT
693722
[clang-asan]: https://clang.llvm.org/docs/AddressSanitizer.html
694723
[clang-cfi]: https://clang.llvm.org/docs/ControlFlowIntegrity.html
695724
[clang-hwasan]: https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.html
725+
[clang-kcfi]: https://clang.llvm.org/docs/ControlFlowIntegrity.html#fsanitize-kcfi
696726
[clang-lsan]: https://clang.llvm.org/docs/LeakSanitizer.html
697727
[clang-msan]: https://clang.llvm.org/docs/MemorySanitizer.html
698728
[clang-scs]: https://clang.llvm.org/docs/ShadowCallStack.html

0 commit comments

Comments
 (0)