diff options
author | Marco Elver <elver@google.com> | 2019-07-11 23:54:07 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-07-12 14:05:42 -0400 |
commit | b5f6e0fc7d60e0234dac82498e90dfe9027bad1f (patch) | |
tree | 41492a12b523dbf5af7211b71cdc2569204945f8 /include/linux/kasan-checks.h | |
parent | 7d8ad890dad00f6cd64bfb44d9be4fceb10cf819 (diff) |
mm/kasan: change kasan_check_{read,write} to return boolean
This changes {,__}kasan_check_{read,write} functions to return a boolean
denoting if the access was valid or not.
[sfr@canb.auug.org.au: include types.h for "bool"]
Link: http://lkml.kernel.org/r/20190705184949.13cdd021@canb.auug.org.au
Link: http://lkml.kernel.org/r/20190626142014.141844-3-elver@google.com
Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
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: Mark Rutland <mark.rutland@arm.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 | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/include/linux/kasan-checks.h b/include/linux/kasan-checks.h index 221f05fbddd7..ac6aba632f2d 100644 --- a/include/linux/kasan-checks.h +++ b/include/linux/kasan-checks.h | |||
@@ -2,19 +2,25 @@ | |||
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 | #include <linux/types.h> | ||
6 | |||
5 | /* | 7 | /* |
6 | * __kasan_check_*: Always available when KASAN is enabled. This may be used | 8 | * __kasan_check_*: Always available when KASAN is enabled. This may be used |
7 | * even in compilation units that selectively disable KASAN, but must use KASAN | 9 | * 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! | 10 | * to validate access to an address. Never use these in header files! |
9 | */ | 11 | */ |
10 | #ifdef CONFIG_KASAN | 12 | #ifdef CONFIG_KASAN |
11 | void __kasan_check_read(const volatile void *p, unsigned int size); | 13 | bool __kasan_check_read(const volatile void *p, unsigned int size); |
12 | void __kasan_check_write(const volatile void *p, unsigned int size); | 14 | bool __kasan_check_write(const volatile void *p, unsigned int size); |
13 | #else | 15 | #else |
14 | static inline void __kasan_check_read(const volatile void *p, unsigned int size) | 16 | static inline bool __kasan_check_read(const volatile void *p, unsigned int size) |
15 | { } | 17 | { |
16 | static inline void __kasan_check_write(const volatile void *p, unsigned int size) | 18 | return true; |
17 | { } | 19 | } |
20 | static inline bool __kasan_check_write(const volatile void *p, unsigned int size) | ||
21 | { | ||
22 | return true; | ||
23 | } | ||
18 | #endif | 24 | #endif |
19 | 25 | ||
20 | /* | 26 | /* |
@@ -25,10 +31,14 @@ static inline void __kasan_check_write(const volatile void *p, unsigned int size | |||
25 | #define kasan_check_read __kasan_check_read | 31 | #define kasan_check_read __kasan_check_read |
26 | #define kasan_check_write __kasan_check_write | 32 | #define kasan_check_write __kasan_check_write |
27 | #else | 33 | #else |
28 | static inline void kasan_check_read(const volatile void *p, unsigned int size) | 34 | static inline bool kasan_check_read(const volatile void *p, unsigned int size) |
29 | { } | 35 | { |
30 | static inline void kasan_check_write(const volatile void *p, unsigned int size) | 36 | return true; |
31 | { } | 37 | } |
38 | static inline bool kasan_check_write(const volatile void *p, unsigned int size) | ||
39 | { | ||
40 | return true; | ||
41 | } | ||
32 | #endif | 42 | #endif |
33 | 43 | ||
34 | #endif | 44 | #endif |