blob: 5b052ab40cf9f780ac64bd74841dd7745a3e613b [file] [log] [blame]
Andrey Ryabinin0b24bec2015-02-13 14:39:17 -08001#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 Ryabininb8c73fc2015-02-13 14:39:28 -08009#define KASAN_FREE_PAGE 0xFF /* page was freed */
Andrey Ryabinin0316bec2015-02-13 14:39:42 -080010#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 Ryabininb8c73fc2015-02-13 14:39:28 -080015
Andrey Ryabinin0b24bec2015-02-13 14:39:17 -080016struct 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
24void kasan_report_error(struct kasan_access_info *info);
25void kasan_report_user_access(struct kasan_access_info *info);
26
27static 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
33static inline bool kasan_enabled(void)
34{
35 return !current->kasan_depth;
36}
37
38void kasan_report(unsigned long addr, size_t size,
39 bool is_write, unsigned long ip);
40
41#endif