Andrey Ryabinin | 0b24bec | 2015-02-13 14:39:17 -0800 | [diff] [blame] | 1 | #ifndef __MM_KASAN_KASAN_H |
| 2 | #define __MM_KASAN_KASAN_H |
| 3 | |
| 4 | #include <linux/kasan.h> |
| 5 | |
| 6 | #define KASAN_SHADOW_SCALE_SIZE (1UL << KASAN_SHADOW_SCALE_SHIFT) |
| 7 | #define KASAN_SHADOW_MASK (KASAN_SHADOW_SCALE_SIZE - 1) |
| 8 | |
Andrey Ryabinin | b8c73fc | 2015-02-13 14:39:28 -0800 | [diff] [blame] | 9 | #define KASAN_FREE_PAGE 0xFF /* page was freed */ |
Andrey Ryabinin | 0316bec | 2015-02-13 14:39:42 -0800 | [diff] [blame^] | 10 | #define KASAN_FREE_PAGE 0xFF /* page was freed */ |
| 11 | #define KASAN_PAGE_REDZONE 0xFE /* redzone for kmalloc_large allocations */ |
| 12 | #define KASAN_KMALLOC_REDZONE 0xFC /* redzone inside slub object */ |
| 13 | #define KASAN_KMALLOC_FREE 0xFB /* object was freed (kmem_cache_free/kfree) */ |
| 14 | |
Andrey Ryabinin | b8c73fc | 2015-02-13 14:39:28 -0800 | [diff] [blame] | 15 | |
Andrey Ryabinin | 0b24bec | 2015-02-13 14:39:17 -0800 | [diff] [blame] | 16 | struct kasan_access_info { |
| 17 | const void *access_addr; |
| 18 | const void *first_bad_addr; |
| 19 | size_t access_size; |
| 20 | bool is_write; |
| 21 | unsigned long ip; |
| 22 | }; |
| 23 | |
| 24 | void kasan_report_error(struct kasan_access_info *info); |
| 25 | void kasan_report_user_access(struct kasan_access_info *info); |
| 26 | |
| 27 | static inline const void *kasan_shadow_to_mem(const void *shadow_addr) |
| 28 | { |
| 29 | return (void *)(((unsigned long)shadow_addr - KASAN_SHADOW_OFFSET) |
| 30 | << KASAN_SHADOW_SCALE_SHIFT); |
| 31 | } |
| 32 | |
| 33 | static inline bool kasan_enabled(void) |
| 34 | { |
| 35 | return !current->kasan_depth; |
| 36 | } |
| 37 | |
| 38 | void kasan_report(unsigned long addr, size_t size, |
| 39 | bool is_write, unsigned long ip); |
| 40 | |
| 41 | #endif |