|
8 | 8 | #define KASAN_SHADOW_SCALE_SIZE (1UL << KASAN_SHADOW_SCALE_SHIFT) |
9 | 9 | #define KASAN_SHADOW_MASK (KASAN_SHADOW_SCALE_SIZE - 1) |
10 | 10 |
|
| 11 | +#define KASAN_TAG_KERNEL 0xFF /* native kernel pointers tag */ |
| 12 | +#define KASAN_TAG_INVALID 0xFE /* inaccessible memory tag */ |
| 13 | +#define KASAN_TAG_MAX 0xFD /* maximum value for random tags */ |
| 14 | + |
11 | 15 | #define KASAN_FREE_PAGE 0xFF /* page was freed */ |
12 | 16 | #define KASAN_PAGE_REDZONE 0xFE /* redzone for kmalloc_large allocations */ |
13 | 17 | #define KASAN_KMALLOC_REDZONE 0xFC /* redzone inside slub object */ |
@@ -126,6 +130,33 @@ static inline void quarantine_reduce(void) { } |
126 | 130 | static inline void quarantine_remove_cache(struct kmem_cache *cache) { } |
127 | 131 | #endif |
128 | 132 |
|
| 133 | +#ifdef CONFIG_KASAN_SW_TAGS |
| 134 | + |
| 135 | +u8 random_tag(void); |
| 136 | + |
| 137 | +#else |
| 138 | + |
| 139 | +static inline u8 random_tag(void) |
| 140 | +{ |
| 141 | + return 0; |
| 142 | +} |
| 143 | + |
| 144 | +#endif |
| 145 | + |
| 146 | +#ifndef arch_kasan_set_tag |
| 147 | +#define arch_kasan_set_tag(addr, tag) ((void *)(addr)) |
| 148 | +#endif |
| 149 | +#ifndef arch_kasan_reset_tag |
| 150 | +#define arch_kasan_reset_tag(addr) ((void *)(addr)) |
| 151 | +#endif |
| 152 | +#ifndef arch_kasan_get_tag |
| 153 | +#define arch_kasan_get_tag(addr) 0 |
| 154 | +#endif |
| 155 | + |
| 156 | +#define set_tag(addr, tag) ((void *)arch_kasan_set_tag((addr), (tag))) |
| 157 | +#define reset_tag(addr) ((void *)arch_kasan_reset_tag(addr)) |
| 158 | +#define get_tag(addr) arch_kasan_get_tag(addr) |
| 159 | + |
129 | 160 | /* |
130 | 161 | * Exported functions for interfaces called from assembly or from generated |
131 | 162 | * code. Declarations here to avoid warning about missing declarations. |
|
0 commit comments