Conversation
1191bc5 to
07c2a2a
Compare
This comment has been minimized.
This comment has been minimized.
07c2a2a to
9508e21
Compare
This comment has been minimized.
This comment has been minimized.
9508e21 to
c7a338e
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| // KHWASAN: In LLVM versions prior to 21.1.0, the HWAddressSanitizer pass incorrectly | ||
| // ignores the pass-specific `CompileKernel` flag and only looks at the global command-line | ||
| // flag `-hwasan-kernel`. To work around this, pass `-hwasan-kernel` on the relevant LLVM | ||
| // versions. | ||
| // | ||
| // Fixed by: [HWASan][bugfix] Fix kernel check in ShadowMapping::init (#142226). | ||
| if sess.sanitizers().contains(SanitizerSet::KERNELHWADDRESS) && get_version() < (21, 1, 0) { | ||
| add("-hwasan-kernel", false); | ||
| } |
There was a problem hiding this comment.
@fmayer Is this reasonable a reasonable fix for rustc to work around the lack of llvm/llvm-project#142226? Or do you think I should pass this on all versions? Thanks!
This comment has been minimized.
This comment has been minimized.
|
Some changes occurred in cfg and check-cfg configuration cc @Urgau Some changes occurred in tests/ui/sanitizer cc @rcvalle Some changes occurred in src/tools/compiletest cc @jieyouxu Some changes occurred in tests/codegen-llvm/sanitizer cc @rcvalle Some changes occurred in compiler/rustc_attr_parsing |
|
r? @chenyukang rustbot has assigned @chenyukang. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
|
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. |
Fix minor kasan bugs Fixes a few minor bugs discovered during rust-lang/rust#153049.
Fix minor kasan bugs Fixes a few minor bugs discovered during rust-lang/rust#153049.
|
r? compiler |
| if sanitizer.contains(SanitizerSet::LEAK) | ||
| && !sanitizer.contains(SanitizerSet::ADDRESS) | ||
| && !sanitizer.contains(SanitizerSet::HWADDRESS) | ||
| && !sanitizer.contains(SanitizerSet::KERNELHWADDRESS) |
There was a problem hiding this comment.
| && !sanitizer.contains(SanitizerSet::KERNELHWADDRESS) |
I don't think this is necessary since -Zsanitizer=leak,kernel-hwaddress gets rejected on grounds of being incompatible. That's likely also why KERNELADDRESS isn't listed here, -Zsanitizer=leak,kernel-address is an error, too.
There was a problem hiding this comment.
(commenting on an arbitrary file)
Could you add a section for KernelHwAddressSanitizer to the Unstable Book (in src/doc/unstable-book/, cc https://doc.rust-lang.org/unstable-book/compiler-flags/sanitizer.html). A stub would be sufficient.
|
@bors try jobs=test-various,aarch64-gnu |
Add `-Zsanitize=kernel-hwaddress` try-job: test-various try-job: aarch64-gnu
This comment has been minimized.
This comment has been minimized.
|
Some changes occurred in src/doc/unstable-book/src/compiler-flags/sanitizer.md cc @rust-lang/project-exploit-mitigations, @rcvalle
These commits modify compiler targets. |
|
@rustbot ready |
|
Thanks! @bors r+ |
Add `-Zsanitize=kernel-hwaddress` The Linux kernel has a config option called `CONFIG_KASAN_SW_TAGS` that enables `-fsanitize=kernel-hwaddress`. This is not supported by Rust. One slightly awkward detail is that `#[sanitize(address = "off")]` applies to both `-Zsanitize=address` and `-Zsanitize=kernel-address`. Probably it was done this way because both are the same LLVM pass. I replicated this logic here for hwaddress, but it might be undesirable. Note that `#[sanitize(kernel_hwaddress = "off")]` could be supported as an annotation on statics, but since it's also missing for `#[sanitize(hwaddress = "off")]`, I did not add it. MCP: rust-lang/compiler-team#975 Tracking issue: rust-lang#154171 cc @rcvalle @maurer @ojeda
Rollup of 6 pull requests Successful merges: - #154004 (`Alignment`: move from `ptr` to `mem` and rename `as_nonzero` to `as_nonzero_usize`) - #153049 (Add `-Zsanitize=kernel-hwaddress`) - #154269 (miri recursive validation: only check one layer deep) - #154112 (some `tests/ui/macros` cleanup) - #154131 (begin `tests/ui/structs-enums` cleanup) - #154233 (Move ui/issues tests to relevant subdirectories)
Add `-Zsanitize=kernel-hwaddress` The Linux kernel has a config option called `CONFIG_KASAN_SW_TAGS` that enables `-fsanitize=kernel-hwaddress`. This is not supported by Rust. One slightly awkward detail is that `#[sanitize(address = "off")]` applies to both `-Zsanitize=address` and `-Zsanitize=kernel-address`. Probably it was done this way because both are the same LLVM pass. I replicated this logic here for hwaddress, but it might be undesirable. Note that `#[sanitize(kernel_hwaddress = "off")]` could be supported as an annotation on statics, but since it's also missing for `#[sanitize(hwaddress = "off")]`, I did not add it. MCP: rust-lang/compiler-team#975 Tracking issue: rust-lang#154171 cc @rcvalle @maurer @ojeda
Rollup of 5 pull requests Successful merges: - #153049 (Add `-Zsanitize=kernel-hwaddress`) - #154269 (miri recursive validation: only check one layer deep) - #154112 (some `tests/ui/macros` cleanup) - #154131 (begin `tests/ui/structs-enums` cleanup) - #154233 (Move ui/issues tests to relevant subdirectories)
View all comments
The Linux kernel has a config option called
CONFIG_KASAN_SW_TAGSthat enables-fsanitize=kernel-hwaddress. This is not supported by Rust.One slightly awkward detail is that
#[sanitize(address = "off")]applies to both-Zsanitize=addressand-Zsanitize=kernel-address. Probably it was done this way because both are the same LLVM pass. I replicated this logic here for hwaddress, but it might be undesirable.Note that
#[sanitize(kernel_hwaddress = "off")]could be supported as an annotation on statics, but since it's also missing for#[sanitize(hwaddress = "off")], I did not add it.MCP: rust-lang/compiler-team#975
Tracking issue: #154171
cc @rcvalle @maurer @ojeda