Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
64f8ebaf AR |
2 | #ifndef _LINUX_KASAN_CHECKS_H |
3 | #define _LINUX_KASAN_CHECKS_H | |
4 | ||
b5f6e0fc ME |
5 | #include <linux/types.h> |
6 | ||
611806b4 AK |
7 | /* |
8 | * The annotations present in this file are only relevant for the software | |
9 | * KASAN modes that rely on compiler instrumentation, and will be optimized | |
10 | * away for the hardware tag-based KASAN mode. Use kasan_check_byte() instead. | |
11 | */ | |
12 | ||
7d8ad890 ME |
13 | /* |
14 | * __kasan_check_*: Always available when KASAN is enabled. This may be used | |
15 | * even in compilation units that selectively disable KASAN, but must use KASAN | |
16 | * to validate access to an address. Never use these in header files! | |
17 | */ | |
0fea6e9a | 18 | #if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS) |
b5f6e0fc ME |
19 | bool __kasan_check_read(const volatile void *p, unsigned int size); |
20 | bool __kasan_check_write(const volatile void *p, unsigned int size); | |
7d8ad890 | 21 | #else |
b5f6e0fc ME |
22 | static inline bool __kasan_check_read(const volatile void *p, unsigned int size) |
23 | { | |
24 | return true; | |
25 | } | |
26 | static inline bool __kasan_check_write(const volatile void *p, unsigned int size) | |
27 | { | |
28 | return true; | |
29 | } | |
7d8ad890 ME |
30 | #endif |
31 | ||
32 | /* | |
33 | * kasan_check_*: Only available when the particular compilation unit has KASAN | |
34 | * instrumentation enabled. May be used in header files. | |
35 | */ | |
36 | #ifdef __SANITIZE_ADDRESS__ | |
37 | #define kasan_check_read __kasan_check_read | |
38 | #define kasan_check_write __kasan_check_write | |
64f8ebaf | 39 | #else |
b5f6e0fc ME |
40 | static inline bool kasan_check_read(const volatile void *p, unsigned int size) |
41 | { | |
42 | return true; | |
43 | } | |
44 | static inline bool kasan_check_write(const volatile void *p, unsigned int size) | |
45 | { | |
46 | return true; | |
47 | } | |
64f8ebaf AR |
48 | #endif |
49 | ||
50 | #endif |