diff options
author | Marco Elver <elver@google.com> | 2019-07-11 23:54:03 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-07-12 14:05:42 -0400 |
commit | 7d8ad890dad00f6cd64bfb44d9be4fceb10cf819 (patch) | |
tree | 03134a0314ae139e8d92941353e2ef21ef5c0470 /include/linux/kasan-checks.h | |
parent | 751ad98d5f881df91ba47e013b82422912381e8e (diff) |
mm/kasan: introduce __kasan_check_{read,write}
Patch series "mm/kasan: Add object validation in ksize()", v3.
This patch (of 5):
This introduces __kasan_check_{read,write}. __kasan_check functions may
be used from anywhere, even compilation units that disable instrumentation
selectively.
This change eliminates the need for the __KASAN_INTERNAL definition.
[elver@google.com: v5]
Link: http://lkml.kernel.org/r/20190708170706.174189-2-elver@google.com
Link: http://lkml.kernel.org/r/20190626142014.141844-2-elver@google.com
Signed-off-by: Marco Elver <elver@google.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Reviewed-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/kasan-checks.h')
-rw-r--r-- | include/linux/kasan-checks.h | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/include/linux/kasan-checks.h b/include/linux/kasan-checks.h index a61dc075e2ce..221f05fbddd7 100644 --- a/include/linux/kasan-checks.h +++ b/include/linux/kasan-checks.h | |||
@@ -2,9 +2,28 @@ | |||
2 | #ifndef _LINUX_KASAN_CHECKS_H | 2 | #ifndef _LINUX_KASAN_CHECKS_H |
3 | #define _LINUX_KASAN_CHECKS_H | 3 | #define _LINUX_KASAN_CHECKS_H |
4 | 4 | ||
5 | #if defined(__SANITIZE_ADDRESS__) || defined(__KASAN_INTERNAL) | 5 | /* |
6 | void kasan_check_read(const volatile void *p, unsigned int size); | 6 | * __kasan_check_*: Always available when KASAN is enabled. This may be used |
7 | void kasan_check_write(const volatile void *p, unsigned int size); | 7 | * even in compilation units that selectively disable KASAN, but must use KASAN |
8 | * to validate access to an address. Never use these in header files! | ||
9 | */ | ||
10 | #ifdef CONFIG_KASAN | ||
11 | void __kasan_check_read(const volatile void *p, unsigned int size); | ||
12 | void __kasan_check_write(const volatile void *p, unsigned int size); | ||
13 | #else | ||
14 | static inline void __kasan_check_read(const volatile void *p, unsigned int size) | ||
15 | { } | ||
16 | static inline void __kasan_check_write(const volatile void *p, unsigned int size) | ||
17 | { } | ||
18 | #endif | ||
19 | |||
20 | /* | ||
21 | * kasan_check_*: Only available when the particular compilation unit has KASAN | ||
22 | * instrumentation enabled. May be used in header files. | ||
23 | */ | ||
24 | #ifdef __SANITIZE_ADDRESS__ | ||
25 | #define kasan_check_read __kasan_check_read | ||
26 | #define kasan_check_write __kasan_check_write | ||
8 | #else | 27 | #else |
9 | static inline void kasan_check_read(const volatile void *p, unsigned int size) | 28 | static inline void kasan_check_read(const volatile void *p, unsigned int size) |
10 | { } | 29 | { } |