]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - include/linux/kasan-checks.h
Merge tag 'fs.move_mount.move_mount_set_group.v5.15' of git://git.kernel.org/pub...
[mirror_ubuntu-jammy-kernel.git] / include / linux / kasan-checks.h
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_KASAN_CHECKS_H
3 #define _LINUX_KASAN_CHECKS_H
4
5 #include <linux/types.h>
6
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
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 */
18 #if defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_KASAN_SW_TAGS)
19 bool __kasan_check_read(const volatile void *p, unsigned int size);
20 bool __kasan_check_write(const volatile void *p, unsigned int size);
21 #else
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 }
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
39 #else
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 }
48 #endif
49
50 #endif