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
33#define __no_sanitize_thread33#define __no_sanitize_thread
34#endif34#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 versions45 * Not all versions of clang implement the the type-generic versions
38 * of the builtin overflow checkers. Fortunately, clang implements46 * of the builtin overflow checkers. Fortunately, clang implements
include/linux/compiler-gcc.h+6−0
@@ -150,6 +150,12 @@ · 149 unmodified lines
150#define __no_sanitize_thread150#define __no_sanitize_thread
151#endif151#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 >= 50100159#if GCC_VERSION >= 50100
154#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1160#define COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW 1
155#endif161#endif
include/linux/compiler_types.h+2−1
@@ -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_kcsan201 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

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