Page MenuHomeFreeBSD

cdefs: Use __has_feature to gate the definition of __nosanitize*
ClosedPublic

Authored by markj on Oct 19 2024, 2:30 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 7, 5:29 AM
Unknown Object (File)
Thu, Nov 6, 1:19 AM
Unknown Object (File)
Mon, Nov 3, 10:55 PM
Unknown Object (File)
Wed, Oct 29, 1:03 PM
Unknown Object (File)
Wed, Oct 29, 12:07 PM
Unknown Object (File)
Wed, Oct 29, 10:43 AM
Unknown Object (File)
Wed, Oct 29, 10:03 AM
Unknown Object (File)
Fri, Oct 24, 6:42 PM
Subscribers

Details

Summary

clang 12 does not implement the coverage sanitizer, and the build fails
when attribute((no_sanitize("coverage"))) is used.

Try to work around the problem by giving __nosanitize* a non-trivial
definition only when the corresponding sanitizer is actually enabled in
the build.

Tested by reading disassembly of pmap_update_strided() and pmap_enter()
in a kernel compiled with "options COVERAGE", and similar sanity checks
for the other sanitizers. I also test-booted KASAN and KMSAN kernels in
amd64 bhyve.

Suggested by: jrtc27
Fixes: a78bacf3b0ec ("cdefs: Add __nosanitizecoverage")

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 60087
Build 56971: arc lint + arc unit

Event Timeline

markj requested review of this revision.Oct 19 2024, 2:30 PM

Why test for clang? Is gcc broken for sanitizers?

This revision is now accepted and ready to land.Oct 19 2024, 2:47 PM
In D47193#1076016, @imp wrote:

Why test for clang? Is gcc broken for sanitizers?

See commit 4c235c0083837. I've never tested gcc+kernel sanitizers and I doubt they will just work (though hopefully it wouldn't require a lot of effort).