KCFI: Require -C panic=abort
While the KCFI scheme is not incompatible with unwinding, LLVM's `invoke` instruction does not currently support KCFI bundles. While it likely will in the near future, we won't be able to assume that in Rust for a while.
This commit is contained in:
parent
45796d1c24
commit
29c1a2b9e9
@ -96,6 +96,8 @@ session_sanitizer_cfi_requires_lto = `-Zsanitizer=cfi` requires `-Clto` or `-Cli
|
||||
|
||||
session_sanitizer_cfi_requires_single_codegen_unit = `-Zsanitizer=cfi` with `-Clto` requires `-Ccodegen-units=1`
|
||||
|
||||
session_sanitizer_kcfi_requires_panic_abort = `-Z sanitizer=kcfi` requires `-C panic=abort`
|
||||
|
||||
session_sanitizer_not_supported = {$us} sanitizer is not supported for this target
|
||||
|
||||
session_sanitizers_not_supported = {$us} sanitizers are not supported for this target
|
||||
|
@ -145,6 +145,10 @@ pub(crate) struct SanitizerCfiGeneralizePointersRequiresCfi;
|
||||
#[diag(session_sanitizer_cfi_normalize_integers_requires_cfi)]
|
||||
pub(crate) struct SanitizerCfiNormalizeIntegersRequiresCfi;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_sanitizer_kcfi_requires_panic_abort)]
|
||||
pub(crate) struct SanitizerKcfiRequiresPanicAbort;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag(session_split_lto_unit_requires_lto)]
|
||||
pub(crate) struct SplitLtoUnitRequiresLto;
|
||||
|
@ -1234,6 +1234,11 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
|
||||
sess.dcx().emit_err(errors::SanitizerCfiRequiresLto);
|
||||
}
|
||||
|
||||
// KCFI requires panic=abort
|
||||
if sess.is_sanitizer_kcfi_enabled() && sess.panic_strategy() != PanicStrategy::Abort {
|
||||
sess.dcx().emit_err(errors::SanitizerKcfiRequiresPanicAbort);
|
||||
}
|
||||
|
||||
// LLVM CFI using rustc LTO requires a single codegen unit.
|
||||
if sess.is_sanitizer_cfi_enabled()
|
||||
&& sess.lto() == config::Lto::Fat
|
||||
|
@ -11,6 +11,7 @@
|
||||
//@[cfi]compile-flags: -Clto -Ccodegen-units=1
|
||||
//@[kcfi]needs-llvm-components: x86
|
||||
//@[kcfi]compile-flags: -Zsanitizer=kcfi --cfg kcfi --target x86_64-unknown-none
|
||||
//@[kcfi]compile-flags: -C panic=abort
|
||||
//@[leak]needs-sanitizer-leak
|
||||
//@[leak]compile-flags: -Zsanitizer=leak --cfg leak
|
||||
//@[memory]needs-sanitizer-memory
|
||||
|
@ -14,6 +14,7 @@
|
||||
//@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0
|
||||
//@ [cfi] compile-flags: -Z sanitizer=cfi
|
||||
//@ [kcfi] compile-flags: -Z sanitizer=kcfi
|
||||
//@ [kcfi] compile-flags: -C panic=abort -C prefer-dynamic=off
|
||||
//@ run-pass
|
||||
|
||||
pub fn main() {
|
||||
|
@ -11,6 +11,7 @@
|
||||
//@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0
|
||||
//@ [cfi] compile-flags: -Z sanitizer=cfi
|
||||
//@ [kcfi] compile-flags: -Z sanitizer=kcfi
|
||||
//@ [kcfi] compile-flags: -C panic=abort -C prefer-dynamic=off
|
||||
//@ run-pass
|
||||
|
||||
use std::sync::Arc;
|
||||
|
@ -9,6 +9,7 @@
|
||||
//@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0
|
||||
//@ [cfi] compile-flags: -Z sanitizer=cfi
|
||||
//@ [kcfi] compile-flags: -Z sanitizer=kcfi
|
||||
//@ [kcfi] compile-flags: -C panic=abort -C prefer-dynamic=off
|
||||
//@ run-pass
|
||||
|
||||
use std::marker::PhantomData;
|
||||
|
@ -9,6 +9,7 @@
|
||||
//@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0
|
||||
//@ [cfi] compile-flags: -Z sanitizer=cfi
|
||||
//@ [kcfi] compile-flags: -Z sanitizer=kcfi
|
||||
//@ [kcfi] compile-flags: -C panic=abort -C prefer-dynamic=off
|
||||
//@ run-pass
|
||||
|
||||
trait Foo {
|
||||
|
Loading…
x
Reference in New Issue
Block a user