Skip to content

sanitizers: Implement support for the sanitize ignorelist - #157808

Open
1c3t3a wants to merge 13 commits into
rust-lang:mainfrom
1c3t3a:sanitizer-ignorelist
Open

sanitizers: Implement support for the sanitize ignorelist#157808
1c3t3a wants to merge 13 commits into
rust-lang:mainfrom
1c3t3a:sanitizer-ignorelist

Conversation

@1c3t3a

@1c3t3a 1c3t3a commented Jun 12, 2026

Copy link
Copy Markdown
Member

View all comments

The sanitize ignorelist gives central controls over which functions, files, etc. should be ignored and not sanitized. It is a common file format for clang and explained here:
https://clang.llvm.org/docs/SanitizerSpecialCaseList.html. This change adds support for this list in Rust as well.

r? @rcvalle

@rustbot

rustbot commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred in tests/codegen-llvm/sanitizer

cc @rcvalle

@rustbot rustbot added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 12, 2026
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3a force-pushed the sanitizer-ignorelist branch 2 times, most recently from 624834b to 693e22f Compare June 12, 2026 12:49
@1c3t3a
1c3t3a requested a review from rcvalle June 12, 2026 14:20
Comment thread compiler/rustc_codegen_llvm/src/builder.rs Outdated
Comment thread compiler/rustc_codegen_llvm/src/builder.rs Outdated
Comment thread compiler/rustc_codegen_llvm/src/builder.rs Outdated
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 12, 2026
@1c3t3a
1c3t3a requested a review from rcvalle June 15, 2026 08:54
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 15, 2026
@rust-bors

This comment has been minimized.

Comment thread compiler/rustc_codegen_llvm/src/common.rs Outdated
Comment thread tests/codegen-llvm/sanitizer/ignorelist/cfi-ignorelist.rs
Comment thread compiler/rustc_codegen_llvm/src/llvm/mod.rs Outdated
Comment thread compiler/rustc_codegen_llvm/src/attributes.rs
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 28, 2026
@1c3t3a
1c3t3a force-pushed the sanitizer-ignorelist branch from a24ff27 to eeed708 Compare August 27, 2026 10:12
@rustbot

rustbot commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

Some changes occurred in compiler/rustc_sanitizers

cc @rcvalle

@rustbot

This comment has been minimized.

@rustbot

This comment has been minimized.

@1c3t3a
1c3t3a force-pushed the sanitizer-ignorelist branch from eeed708 to 066c9e1 Compare August 27, 2026 10:17
@1c3t3a
1c3t3a requested a review from rcvalle August 27, 2026 10:18
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 27, 2026
Comment thread tests/codegen-llvm/sanitizer/ignorelist/ignorelist.txt Outdated
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3a force-pushed the sanitizer-ignorelist branch from 3f6de90 to 1cb8361 Compare August 27, 2026 16:30
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3a force-pushed the sanitizer-ignorelist branch from 1cb8361 to a9e36d5 Compare August 28, 2026 08:59
@rust-bors

This comment has been minimized.

1c3t3a added 11 commits August 31, 2026 16:16
The sanitize ignorelist gives central controls over which functions,
files, etc. should be ignored and not sanitized. It is a common file
format for clang and explained here:
https://clang.llvm.org/docs/SanitizerSpecialCaseList.html. This change
adds support for this list in Rust as well.
- Add support for the `[all]` section across all sanitizers.
- Restrict CFI ignorelist matching to `[cfi]` and `[cfi-icall]`, ignoring unrelated C++ sub-kinds like `[cfi-vcall]`.
- Clean up unused `in_sanitizer_blame` helper.
- Add test coverage for `[all]` and `[cfi-icall]`.
In Clang, falling back to [address] for kernel-address (and [hwaddress] for
kernel-hwaddress) only applies to global variables, not functions. Update
function ignorelist filtering to match Clang.
@1c3t3a
1c3t3a force-pushed the sanitizer-ignorelist branch from a9e36d5 to f071cb7 Compare August 31, 2026 16:17
@rustbot

rustbot commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3a force-pushed the sanitizer-ignorelist branch from 4d27534 to 40db0f2 Compare August 31, 2026 17:43
@rust-log-analyzer

This comment has been minimized.

@1c3t3a
1c3t3a force-pushed the sanitizer-ignorelist branch from 40db0f2 to 2f2945e Compare August 31, 2026 18:33
Comment thread compiler/rustc_codegen_llvm/src/consts.rs Outdated
/// Opaque type that allows C++ code to write bytes to a Rust-side buffer,
/// in conjunction with `RawRustStringOstream`. Use this as `&RustString`
/// (Rust) and `RustStringRef` (C++) in FFI signatures.
pub(crate) type RustString;

@dingxiangfei2009 dingxiangfei2009 Aug 31, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this actually rustc_llvm::RustString?

I have a remedy, how about abstracting away the interfaces here into a trait and let rustc_llvm provide a trait implementor? A BuilderMethods extension trait might help.

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me! The only problem I see is that cg_llvm is a standalone crate and has no dependencies on other rustc_* crates. Should this then best extend Builder/CodegenCx in cg_ssa?

Comment thread compiler/rustc_sanitizers/src/ignorelist/ffi.rs Outdated
}

impl SanitizerIgnoreList {
pub fn new(paths: &[String]) -> Result<Self, String> {

@dingxiangfei2009 dingxiangfei2009 Aug 31, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, some FFI mechanics could be folded into cg_llvm or so.

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, we could move the whole SanitizerIgnoreList there, but Ramon mentioned this could also be tucked away in this crate (which arguably encapsulates it nicer). This is the previous discussion, would be curious what you'd advise!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rcvalle: I discussed offline with Xiang, the trait approach here doesn't really make sense, because both the callsite and the impl of the trait would be in cg_llvm. I still like to have this code here, and my understanding is that the rustc_sanitizers crate is anyways llvm centric? Would it makes sense to put this here like this and eventually rename the crate to rustc_llvm_sanitizers? To make sure the tight coupling to cg_llvm? Would be very curious of your opinion :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. PG-exploit-mitigations Project group: Exploit mitigations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants