Adds the portable definitions for __no_sanitize_address, and __no_sanitize_undefined, and subsequently changes noinstr to use the attributes to disable instrumentation via KASAN or UBSAN.
Showing the changes to include/linux (3 of 3 files). Show all
Unified · Split
| @@ -33,6 +33,14 @@ · 32 unmodified lines | |||
| 33 | #define __no_sanitize_thread | 33 | #define __no_sanitize_thread |
| 34 | #endif | 34 | #endif |
| 35 | 35 | ||
| 36 | #if __has_feature(undefined_behavior_sanitizer) | ||
| 37 | /* GCC does not have __SANITIZE_UNDEFINED__ */ | ||
| 38 | #define __no_sanitize_undefined \ | ||
| 39 | __attribute__((no_sanitize("undefined"))) | ||
| 40 | #else | ||
| 41 | #define __no_sanitize_undefined | ||
| 42 | #endif | ||
| 43 | |||
| 36 | /* | 44 | /* |
| 37 | * Not all versions of clang implement the the type-generic versions | 45 | * Not all versions of clang implement the the type-generic versions |
| 38 | * of the builtin overflow checkers. Fortunately, clang implements | 46 | * of the builtin overflow checkers. Fortunately, clang implements |
| @@ -150,6 +150,12 @@ · 149 unmodified lines | |||
| 150 | #define __no_sanitize_thread | 150 | #define __no_sanitize_thread |
| 151 | #endif | 151 | #endif |
| 152 | 152 | ||
| 153 | #if __has_attribute(__no_sanitize_undefined__) | ||
| 154 | #define __no_sanitize_undefined __attribute__((no_sanitize_undefined)) | ||
| 155 | #else | ||
| 156 | #define __no_sanitize_undefined | ||
| 157 | #endif | ||
| 158 | |||
| 153 | #if GCC_VERSION >= 50100 | 159 | #if GCC_VERSION >= 50100 |
| 154 | #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1 | 160 | #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1 |
| 155 | #endif | 161 | #endif |
| @@ -198,7 +198,8 @@ struct ftrace_likely_data { · 197 unmodified lines | |||
| 198 | 198 | ||
| 199 | /* Section for code which can't be instrumented at all */ | 199 | /* Section for code which can't be instrumented at all */ |
| 200 | #define noinstr \ | 200 | #define noinstr \ |
| 201 | noinline notrace __attribute((__section__(".noinstr.text"))) __no_kcsan | 201 | noinline notrace __attribute((__section__(".noinstr.text"))) \ |
| 202 | __no_kcsan __no_sanitize_address __no_sanitize_undefined | ||
| 202 | 203 | ||
| 203 | #endif /* __KERNEL__ */ | 204 | #endif /* __KERNEL__ */ |
| 204 | 205 | ||