Skip to content

sanitizers: Implement support for the sanitize ignorelist - #157808

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

sanitizers: Implement support for the sanitize ignorelist#157808
1c3t3a wants to merge 9 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
RustString::build_byte_buffer(f)
}

pub(crate) struct SanitizerIgnoreList {

@rcvalle rcvalle Jul 28, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can this be moved to the rustc_sanitizers crate? Maybe an ignorelist module there? Are there any other things that could be moved there?

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.

Yes it makes sense to live there. I just want to know that this relies on LLVM specific ffi calls and types. I replicated/moved the necessary pieces, but please take a look if it makes sense like this, alternatively rustc_sanitizer could be generic over these types and routines (a bit like rustc_codegen_ssa is), but it may be a bit ugly and similar amounts of code as if we don't move it :) I am fine with either!

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

rustbot commented Aug 27, 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.

@rustbot

This comment has been minimized.

1c3t3a added 3 commits August 27, 2026 10: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.
@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 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 Aug 27, 2026
src:*src-ignore-memory.rs

[cfi]
fun:*test_cfi*

@jakos-sec jakos-sec Aug 26, 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.

Do we have a concept of different CFI violation types in Rust?

I've just fixed that those get correctly reported by UBSAN here: llvm/llvm-project#213224, since then we can easily generate ignorelists if the type printed in there is the same as the section in the ignorelist.

So we should make sure that the output from UBSAN for CFI violations correspond to the section name for the ignore here.

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.

Good point! My understanding is that this commit should handle that correctly?

@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

Copy link
Copy Markdown
Collaborator

The job tidy failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
                                                            ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:1848:85: error: code should be clang-formatted [-Wclang-format-violations]
  inSectionBlame(uint32_t Mask, llvm::StringRef SectionName, llvm::StringRef Prefix,
                                                                                    ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:1849:40: error: code should be clang-formatted [-Wclang-format-violations]
                 llvm::StringRef Query, llvm::StringRef Category = llvm::StringRef()) const {
                                       ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:1850:79: error: code should be clang-formatted [-Wclang-format-violations]
    for (auto It = SanitizerSections.rbegin(); It != SanitizerSections.rend(); ++It) {
                                                                              ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:1879:66: error: code should be clang-formatted [-Wclang-format-violations]
  unsigned getLastMatch(const Section &S, llvm::StringRef Prefix, llvm::StringRef Query,
                                                                 ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:1879:89: error: code should be clang-formatted [-Wclang-format-violations]
  unsigned getLastMatch(const Section &S, llvm::StringRef Prefix, llvm::StringRef Query,
                                                                                        ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:1883:51: error: code should be clang-formatted [-Wclang-format-violations]
  static unsigned getFileIndex(const Section &S) {
                                                  ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:1884:26: error: code should be clang-formatted [-Wclang-format-violations]
    return S.fileIndex();
                         ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:1890:66: error: code should be clang-formatted [-Wclang-format-violations]
  unsigned getLastMatch(const Section &S, llvm::StringRef Prefix, llvm::StringRef Query,
                                                                 ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:1890:89: error: code should be clang-formatted [-Wclang-format-violations]
  unsigned getLastMatch(const Section &S, llvm::StringRef Prefix, llvm::StringRef Query,
                                                                                        ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:1892:75: error: code should be clang-formatted [-Wclang-format-violations]
    return llvm::SpecialCaseList::inSectionBlame(S.Entries, Prefix, Query, Category);
                                                                          ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:1894:51: error: code should be clang-formatted [-Wclang-format-violations]
  static unsigned getFileIndex(const Section &S) {
                                                  ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:1895:22: error: code should be clang-formatted [-Wclang-format-violations]
    return S.FileIdx;
                     ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:1924:65: error: code should be clang-formatted [-Wclang-format-violations]
      // CFI and its sub-kinds: [cfi], [cfi-icall], [cfi-vcall], [{cfi-vcall,cfi-icall}], etc.
                                                                ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:1927:49: error: code should be clang-formatted [-Wclang-format-violations]
          matchSection(S, "cfi-derived-cast") || matchSection(S, "cfi-unrelated-cast") ||
                                                ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:1936:50: error: code should be clang-formatted [-Wclang-format-violations]
      if (matchSection(S, "shadow-call-stack") || matchSection(S, "shadowcallstack"))
                                                 ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:1987:67: error: code should be clang-formatted [-Wclang-format-violations]
LLVMRustSpecialCaseListInSectionBlame(LLVMSpecialCaseListRef List,
                                                                  ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:1988:52: error: code should be clang-formatted [-Wclang-format-violations]
---
                                                                             ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:1990:56: error: code should be clang-formatted [-Wclang-format-violations]
                                     const char *Query,
                                                       ^
/checkout/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp:1991:77: error: code should be clang-formatted [-Wclang-format-violations]
                                     LLVMRustSpecialCaseListBlame *OutNoSan,
                                                                            ^

clang-format linting failed! Printing diff suggestions:
rerun with `--bless` to reformat C++ code: `./x.py test tidy --extra-checks=cpp:fmt --bless`
tidy [extra_checks:cpp_fmt]: checks with external tool 'clang-format' failed
tidy [extra_checks:cpp_fmt]: FAIL
spellchecking files
building external tool typos from package typos-cli@1.38.1
finished building tool typos
yarn install v1.22.22
warning package.json: No license field
---
Running eslint on rustdoc JS files
info: ES-Check: checking 7 files...
info: ✓ ES-Check passed! All files are ES10 compatible.
typechecking javascript files
tidy: The following check failed: extra_checks:cpp_fmt
Command `/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools-bin/rust-tidy --root-path=/checkout --cargo-path=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo --output-dir=/checkout/obj/build --concurrency=4 --npm-path=/node/bin/yarn --ci=true --extra-checks=py,cpp,js,spellcheck` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:1627:23
Executed at: src/bootstrap/src/core/build_steps/test.rs:1748:29

Command has failed. Rerun with -v to see more details.
Bootstrap failed while executing `test src/tools/tidy tidyselftest --extra-checks=py,cpp,js,spellcheck`
Currently active steps:
test::Tidy {  } at src/bootstrap/src/core/build_steps/test.rs:1666
Build completed unsuccessfully in 0:02:26
  local time: Thu Aug 27 16:39:34 UTC 2026

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.

5 participants