Skip to content

Commit

Permalink
kmsan: add __no_sanitize_memory for non-Clang builds
Browse files Browse the repository at this point in the history
  • Loading branch information
ramosian-glider committed Dec 6, 2018
1 parent 5dc4569 commit f39a968
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion include/linux/compiler-clang.h
Expand Up @@ -21,7 +21,7 @@
#define __SANITIZE_ADDRESS__
#endif

/* KMSAN is a Clang tool, thus putting the defines here */
/* KMSAN is a Clang-only tool, thus putting the defines here */
#if __has_feature(memory_sanitizer)
# define __SANITIZE_MEMORY__
# define __no_sanitize_memory __attribute__((no_sanitize("kernel-memory")))
Expand Down
10 changes: 10 additions & 0 deletions include/linux/compiler_attributes.h
Expand Up @@ -219,6 +219,16 @@
# define __no_sanitize_address
#endif

/*
* Optional: only supported since clang >= 7.0.2
*/
#if __has_attribute(__no_sanitize_memory__)
/* We're using Clang. __no_sanitize_memory is defined in include/compiler-clang.h. */
#else
/* GCC and other compilers don't implement KMSAN. */
# define __no_sanitize_memory
#endif

/*
* gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-packed-type-attribute
* clang: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-packed-variable-attribute
Expand Down

0 comments on commit f39a968

Please sign in to comment.