![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0 */ 0002 0003 /* 0004 * This header provides generic wrappers for memory access instrumentation that 0005 * the compiler cannot emit for: KASAN, KCSAN. 0006 */ 0007 #ifndef _LINUX_INSTRUMENTED_H 0008 #define _LINUX_INSTRUMENTED_H 0009 0010 #include <linux/compiler.h> 0011 #include <linux/kasan-checks.h> 0012 #include <linux/kcsan-checks.h> 0013 #include <linux/types.h> 0014 0015 /** 0016 * instrument_read - instrument regular read access 0017 * 0018 * Instrument a regular read access. The instrumentation should be inserted 0019 * before the actual read happens. 0020 * 0021 * @ptr address of access 0022 * @size size of access 0023 */ 0024 static __always_inline void instrument_read(const volatile void *v, size_t size) 0025 { 0026 kasan_check_read(v, size); 0027 kcsan_check_read(v, size); 0028 } 0029 0030 /** 0031 * instrument_write - instrument regular write access 0032 * 0033 * Instrument a regular write access. The instrumentation should be inserted 0034 * before the actual write happens. 0035 * 0036 * @ptr address of access 0037 * @size size of access 0038 */ 0039 static __always_inline void instrument_write(const volatile void *v, size_t size) 0040 { 0041 kasan_check_write(v, size); 0042 kcsan_check_write(v, size); 0043 } 0044 0045 /** 0046 * instrument_read_write - instrument regular read-write access 0047 * 0048 * Instrument a regular write access. The instrumentation should be inserted 0049 * before the actual write happens. 0050 * 0051 * @ptr address of access 0052 * @size size of access 0053 */ 0054 static __always_inline void instrument_read_write(const volatile void *v, size_t size) 0055 { 0056 kasan_check_write(v, size); 0057 kcsan_check_read_write(v, size); 0058 } 0059 0060 /** 0061 * instrument_atomic_read - instrument atomic read access 0062 * 0063 * Instrument an atomic read access. The instrumentation should be inserted 0064 * before the actual read happens. 0065 * 0066 * @ptr address of access 0067 * @size size of access 0068 */ 0069 static __always_inline void instrument_atomic_read(const volatile void *v, size_t size) 0070 { 0071 kasan_check_read(v, size); 0072 kcsan_check_atomic_read(v, size); 0073 } 0074 0075 /** 0076 * instrument_atomic_write - instrument atomic write access 0077 * 0078 * Instrument an atomic write access. The instrumentation should be inserted 0079 * before the actual write happens. 0080 * 0081 * @ptr address of access 0082 * @size size of access 0083 */ 0084 static __always_inline void instrument_atomic_write(const volatile void *v, size_t size) 0085 { 0086 kasan_check_write(v, size); 0087 kcsan_check_atomic_write(v, size); 0088 } 0089 0090 /** 0091 * instrument_atomic_read_write - instrument atomic read-write access 0092 * 0093 * Instrument an atomic read-write access. The instrumentation should be 0094 * inserted before the actual write happens. 0095 * 0096 * @ptr address of access 0097 * @size size of access 0098 */ 0099 static __always_inline void instrument_atomic_read_write(const volatile void *v, size_t size) 0100 { 0101 kasan_check_write(v, size); 0102 kcsan_check_atomic_read_write(v, size); 0103 } 0104 0105 /** 0106 * instrument_copy_to_user - instrument reads of copy_to_user 0107 * 0108 * Instrument reads from kernel memory, that are due to copy_to_user (and 0109 * variants). The instrumentation must be inserted before the accesses. 0110 * 0111 * @to destination address 0112 * @from source address 0113 * @n number of bytes to copy 0114 */ 0115 static __always_inline void 0116 instrument_copy_to_user(void __user *to, const void *from, unsigned long n) 0117 { 0118 kasan_check_read(from, n); 0119 kcsan_check_read(from, n); 0120 } 0121 0122 /** 0123 * instrument_copy_from_user - instrument writes of copy_from_user 0124 * 0125 * Instrument writes to kernel memory, that are due to copy_from_user (and 0126 * variants). The instrumentation should be inserted before the accesses. 0127 * 0128 * @to destination address 0129 * @from source address 0130 * @n number of bytes to copy 0131 */ 0132 static __always_inline void 0133 instrument_copy_from_user(const void *to, const void __user *from, unsigned long n) 0134 { 0135 kasan_check_write(to, n); 0136 kcsan_check_write(to, n); 0137 } 0138 0139 #endif /* _LINUX_INSTRUMENTED_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |