Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _LINUX_KASAN_CHECKS_H
0003 #define _LINUX_KASAN_CHECKS_H
0004 
0005 #include <linux/types.h>
0006 
0007 /*
0008  * The annotations present in this file are only relevant for the software
0009  * KASAN modes that rely on compiler instrumentation, and will be optimized
0010  * away for the hardware tag-based KASAN mode. Use kasan_check_byte() instead.
0011  */
0012 
0013 /*
0014  * __kasan_check_*: Always available when KASAN is enabled. This may be used
0015  * even in compilation units that selectively disable KASAN, but must use KASAN
0016  * to validate access to an address.   Never use these in header files!
0017  */
0018 #if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
0019 bool __kasan_check_read(const volatile void *p, unsigned int size);
0020 bool __kasan_check_write(const volatile void *p, unsigned int size);
0021 #else
0022 static inline bool __kasan_check_read(const volatile void *p, unsigned int size)
0023 {
0024     return true;
0025 }
0026 static inline bool __kasan_check_write(const volatile void *p, unsigned int size)
0027 {
0028     return true;
0029 }
0030 #endif
0031 
0032 /*
0033  * kasan_check_*: Only available when the particular compilation unit has KASAN
0034  * instrumentation enabled. May be used in header files.
0035  */
0036 #ifdef __SANITIZE_ADDRESS__
0037 #define kasan_check_read __kasan_check_read
0038 #define kasan_check_write __kasan_check_write
0039 #else
0040 static inline bool kasan_check_read(const volatile void *p, unsigned int size)
0041 {
0042     return true;
0043 }
0044 static inline bool kasan_check_write(const volatile void *p, unsigned int size)
0045 {
0046     return true;
0047 }
0048 #endif
0049 
0050 #endif