History

compiler_types.h: Add __no_sanitize_{address,undefined} to noinstr

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.

Marco Elver committed 6 years ago

Commit 5144f8a1 parent 7b861a53 files · +16 −1Browse files

Showing the changes to include/linux (3 of 3 files). Show all

Unified · Split

3 files
  1. include/linux/compiler-clang.h +8 −0
  2. include/linux/compiler-gcc.h +6 −0
  3. include/linux/compiler_types.h +2 −1
include/linux/compiler-clang.h+8−0
@@ -33,6 +33,14 @@ · 32 unmodified lines
3333 #define __no_sanitize_thread
3434 #endif
3535
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+
3644 /*
3745 * Not all versions of clang implement the the type-generic versions
3846 * of the builtin overflow checkers. Fortunately, clang implements
include/linux/compiler-gcc.h+6−0
@@ -150,6 +150,12 @@ · 149 unmodified lines
150150 #define __no_sanitize_thread
151151 #endif
152152
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+
153159 #if GCC_VERSION >= 50100
154160 #define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
155161 #endif
include/linux/compiler_types.h+2−1
@@ -198,7 +198,8 @@ struct ftrace_likely_data { · 197 unmodified lines
198198
199199 /* Section for code which can't be instrumented at all */
200200 #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
202203
203204 #endif /* __KERNEL__ */
204205

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t