Document that CFI diverges from Rust wrt. ABI-compatibility rules#155361
Document that CFI diverges from Rust wrt. ABI-compatibility rules#155361rust-bors[bot] merged 1 commit intorust-lang:mainfrom
Conversation
|
r? @scottmcm rustbot has assigned @scottmcm. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
TBH, I think this is a fundamental flaw in CFI, being coupled to typed-memory concepts that don't exist in Rust. Since he's been looking at this, |
|
|
|
@scottmcm CFI does have some pretty big flaws, but I don't think that's one of them. It's a useful way to detect function pointer mixups, and ABI-compatibility has always been a stronger requirement than just being memory compatible. Just because |
|
The content seems reasonable to me. The one thing I am not sure about is the location. Maybe these docs are a more natural place for CFI-specific documentation? |
| /// - `*const T`, `*mut T`, `&T`, `&mut T`, `Box<T>` (specifically, only `Box<T, Global>`), and | ||
| /// `NonNull<T>` are all ABI-compatible with each other for all `T`. They are also ABI-compatible | ||
| /// with each other for _different_ `T` if they have the same metadata type (`<T as | ||
| /// Pointee>::Metadata`). | ||
| /// Pointee>::Metadata`). However, see the [Control Flow Integrity] section below for caveats. |
There was a problem hiding this comment.
I can move the main docs section, but I'd like to keep this note in this file.
|
Some changes occurred in src/doc/unstable-book/src/compiler-flags/sanitizer.md cc @rust-lang/project-exploit-mitigations, @rcvalle |
|
@bors squash msg="Document that CFI diverges from Rust wrt. ABI-compatibility rules" |
This comment has been minimized.
This comment has been minimized.
|
🔨 10 commits were squashed into aef93ca. |
|
@bors r+ rollup |
Document that CFI diverges from Rust wrt. ABI-compatibility rules The CFI sanitizer is a sanitizer that checks that no ABI-incompatible function calls are made at runtime, but there is currently an unfortunate divergence between the Rust ABI-compatibility rules and what the CFI sanitizer checks. Thus, document that this divergence exists. There are proposals for how we can align the ABI rules to eliminate this discrepancy, and I would like to follow through with those, but for now I think we can at least document that the discrepancy exists. For further discussion please see [Re-evaluate ABI compatibility rules in light of CFI](rust-lang/unsafe-code-guidelines#489) and [Can CFI be made compatible with type erasure schemes?](rust-lang#128728) and [`fn_cast!` macro](rust-lang#140803). cc @rcvalle @samitolvanen @maurer @bjorn3 @RalfJung Rendered: <img width="956" height="391" alt="image" src="https://github.com/user-attachments/assets/410d3eaa-9476-4800-9ef8-bbb100a100c5" />
…uwer Rollup of 12 pull requests Successful merges: - #151994 (switch to v0 mangling by default on stable) - #154325 (Tweak irrefutable let else warning output) - #155899 (`dlltool`: Set the working directory to workaround `--temp-prefix` bug) - #155273 (Lock stable_crate_ids once in create_crate_num) - #155361 (Document that CFI diverges from Rust wrt. ABI-compatibility rules) - #155692 (disable naked-dead-code-elimination test if no RET mnemonic is available) - #155747 (Update documentation for `wasm32-wali-linux-musl` after integrating n…) - #155768 (compiletest: Overhaul the code for running an incremental test revision) - #155907 (Handle hkl const closures) - #155910 (misc stuff from reading borrowck again :)) - #155913 (Delete the 12 year old fixme) - #155920 (remove review queue triagebot mentions)
Document that CFI diverges from Rust wrt. ABI-compatibility rules The CFI sanitizer is a sanitizer that checks that no ABI-incompatible function calls are made at runtime, but there is currently an unfortunate divergence between the Rust ABI-compatibility rules and what the CFI sanitizer checks. Thus, document that this divergence exists. There are proposals for how we can align the ABI rules to eliminate this discrepancy, and I would like to follow through with those, but for now I think we can at least document that the discrepancy exists. For further discussion please see [Re-evaluate ABI compatibility rules in light of CFI](rust-lang/unsafe-code-guidelines#489) and [Can CFI be made compatible with type erasure schemes?](rust-lang#128728) and [`fn_cast!` macro](rust-lang#140803). cc @rcvalle @samitolvanen @maurer @bjorn3 @RalfJung Rendered: <img width="956" height="391" alt="image" src="https://github.com/user-attachments/assets/410d3eaa-9476-4800-9ef8-bbb100a100c5" />
…uwer Rollup of 14 pull requests Successful merges: - #155850 (Only exclude the #155473 change for 1-byte bool-likes) - #155923 (Subtree sync for rustc_codegen_cranelift) - #151994 (switch to v0 mangling by default on stable) - #154325 (Tweak irrefutable let else warning output) - #155899 (`dlltool`: Set the working directory to workaround `--temp-prefix` bug) - #155273 (Lock stable_crate_ids once in create_crate_num) - #155361 (Document that CFI diverges from Rust wrt. ABI-compatibility rules) - #155692 (disable naked-dead-code-elimination test if no RET mnemonic is available) - #155747 (Update documentation for `wasm32-wali-linux-musl` after integrating n…) - #155768 (compiletest: Overhaul the code for running an incremental test revision) - #155907 (Handle hkl const closures) - #155910 (misc stuff from reading borrowck again :)) - #155913 (Delete the 12 year old fixme) - #155920 (remove review queue triagebot mentions)
…uwer Rollup of 14 pull requests Successful merges: - #155850 (Only exclude the #155473 change for 1-byte bool-likes) - #155923 (Subtree sync for rustc_codegen_cranelift) - #151994 (switch to v0 mangling by default on stable) - #154325 (Tweak irrefutable let else warning output) - #155899 (`dlltool`: Set the working directory to workaround `--temp-prefix` bug) - #155273 (Lock stable_crate_ids once in create_crate_num) - #155361 (Document that CFI diverges from Rust wrt. ABI-compatibility rules) - #155692 (disable naked-dead-code-elimination test if no RET mnemonic is available) - #155747 (Update documentation for `wasm32-wali-linux-musl` after integrating n…) - #155768 (compiletest: Overhaul the code for running an incremental test revision) - #155907 (Handle hkl const closures) - #155910 (misc stuff from reading borrowck again :)) - #155913 (Delete the 12 year old fixme) - #155920 (remove review queue triagebot mentions)
…uwer Rollup of 15 pull requests Successful merges: - #155923 (Subtree sync for rustc_codegen_cranelift) - #155930 (Sync from portable simd 2026 04 28) - #155850 (Only exclude the #155473 change for 1-byte bool-likes) - #151994 (switch to v0 mangling by default on stable) - #154325 (Tweak irrefutable let else warning output) - #155273 (Lock stable_crate_ids once in create_crate_num) - #155361 (Document that CFI diverges from Rust wrt. ABI-compatibility rules) - #155692 (disable naked-dead-code-elimination test if no RET mnemonic is available) - #155747 (Update documentation for `wasm32-wali-linux-musl` after integrating n…) - #155768 (compiletest: Overhaul the code for running an incremental test revision) - #155907 (Handle hkl const closures) - #155910 (misc stuff from reading borrowck again :)) - #155913 (Delete the 12 year old fixme) - #155920 (remove review queue triagebot mentions) - #155936 (Rename `SharedContext::emit_dyn_lint*` into `emit_lint*`)
…uwer Rollup of 15 pull requests Successful merges: - #155923 (Subtree sync for rustc_codegen_cranelift) - #155930 (Sync from portable simd 2026 04 28) - #155850 (Only exclude the #155473 change for 1-byte bool-likes) - #151994 (switch to v0 mangling by default on stable) - #154325 (Tweak irrefutable let else warning output) - #155273 (Lock stable_crate_ids once in create_crate_num) - #155361 (Document that CFI diverges from Rust wrt. ABI-compatibility rules) - #155692 (disable naked-dead-code-elimination test if no RET mnemonic is available) - #155747 (Update documentation for `wasm32-wali-linux-musl` after integrating n…) - #155768 (compiletest: Overhaul the code for running an incremental test revision) - #155907 (Handle hkl const closures) - #155910 (misc stuff from reading borrowck again :)) - #155913 (Delete the 12 year old fixme) - #155920 (remove review queue triagebot mentions) - #155936 (Rename `SharedContext::emit_dyn_lint*` into `emit_lint*`)
Rollup merge of #155361 - Darksonn:abi-cfi, r=RalfJung Document that CFI diverges from Rust wrt. ABI-compatibility rules The CFI sanitizer is a sanitizer that checks that no ABI-incompatible function calls are made at runtime, but there is currently an unfortunate divergence between the Rust ABI-compatibility rules and what the CFI sanitizer checks. Thus, document that this divergence exists. There are proposals for how we can align the ABI rules to eliminate this discrepancy, and I would like to follow through with those, but for now I think we can at least document that the discrepancy exists. For further discussion please see [Re-evaluate ABI compatibility rules in light of CFI](rust-lang/unsafe-code-guidelines#489) and [Can CFI be made compatible with type erasure schemes?](#128728) and [`fn_cast!` macro](#140803). cc @rcvalle @samitolvanen @maurer @bjorn3 @RalfJung Rendered: <img width="956" height="391" alt="image" src="https://github.com/user-attachments/assets/410d3eaa-9476-4800-9ef8-bbb100a100c5" />
View all comments
The CFI sanitizer is a sanitizer that checks that no ABI-incompatible function calls are made at runtime, but there is currently an unfortunate divergence between the Rust ABI-compatibility rules and what the CFI sanitizer checks. Thus, document that this divergence exists.
There are proposals for how we can align the ABI rules to eliminate this discrepancy, and I would like to follow through with those, but for now I think we can at least document that the discrepancy exists.
For further discussion please see Re-evaluate ABI compatibility rules in light of CFI and Can CFI be made compatible with type erasure schemes? and
fn_cast!macro.cc @rcvalle @samitolvanen @maurer @bjorn3 @RalfJung
Rendered: