hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/include/linux/kasan-checks.h
....@@ -2,14 +2,49 @@
22 #ifndef _LINUX_KASAN_CHECKS_H
33 #define _LINUX_KASAN_CHECKS_H
44
5
-#if defined(__SANITIZE_ADDRESS__) || defined(__KASAN_INTERNAL)
6
-void kasan_check_read(const volatile void *p, unsigned int size);
7
-void kasan_check_write(const volatile void *p, unsigned int size);
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);
821 #else
9
-static inline void kasan_check_read(const volatile void *p, unsigned int size)
10
-{ }
11
-static inline void kasan_check_write(const volatile void *p, unsigned int size)
12
-{ }
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
+}
1348 #endif
1449
1550 #endif