1 /* SPDX-License-Identifier: GPL-2.0-only */
8 #define ASAN_SHADOW_SCALE_SHIFT 3
10 #define ASAN_SHADOW_SCALE_SIZE (1UL << ASAN_SHADOW_SCALE_SHIFT)
11 #define ASAN_SHADOW_MASK (ASAN_SHADOW_SCALE_SIZE - 1)
13 #define ASAN_GLOBAL_REDZONE 0xFA
14 #define ASAN_STACK_LEFT 0xF1
15 #define ASAN_STACK_MID 0xF2
16 #define ASAN_STACK_RIGHT 0xF3
17 #define ASAN_STACK_PARTIAL 0xF4
18 #define ASAN_USE_AFTER_SCOPE 0xF8
20 #define _RET_IP_ ((unsigned long)__builtin_return_address(0))
21 #define likely(x) __builtin_expect(!!(x), 1)
22 #define unlikely(x) __builtin_expect(!!(x), 0)
24 #define WARN_ON(condition) ({ \
25 int __ret_warn_on = !!(condition); \
26 unlikely(__ret_warn_on); \
29 #ifndef ASAN_ABI_VERSION
30 #define ASAN_ABI_VERSION 5
33 /* The layout of struct dictated by compiler */
34 struct asan_source_location
{
40 /* The layout of struct dictated by compiler */
42 const void *beg
; /* Address of the beginning of the global variable. */
43 size_t size
; /* Size of the global variable. */
44 size_t size_with_redzone
; /* Size of the variable + size of the red zone
47 const void *module_name
; /* Name of the module where the global variable
49 unsigned long has_dynamic_init
; /* This needed for C++. */
50 #if ASAN_ABI_VERSION >= 4
51 struct asan_source_location
*location
;
53 #if ASAN_ABI_VERSION >= 5
58 void asan_unpoison_shadow(const void *address
, size_t size
);
59 void asan_report(unsigned long addr
, size_t size
, bool is_write
,
62 void check_memory_region(unsigned long addr
, size_t size
, bool write
,
63 unsigned long ret_ip
);
65 uintptr_t __asan_shadow_offset(uintptr_t addr
);
66 void __asan_register_globals(struct asan_global
*globals
, size_t size
);
67 void __asan_unregister_globals(struct asan_global
*globals
, size_t size
);
68 void __asan_poison_stack_memory(const void *addr
, size_t size
);
69 void __asan_unpoison_stack_memory(const void *addr
, size_t size
);
71 void __asan_load1(unsigned long addr
);
72 void __asan_store1(unsigned long addr
);
73 void __asan_load2(unsigned long addr
);
74 void __asan_store2(unsigned long addr
);
75 void __asan_load4(unsigned long addr
);
76 void __asan_store4(unsigned long addr
);
77 void __asan_load8(unsigned long addr
);
78 void __asan_store8(unsigned long addr
);
79 void __asan_load16(unsigned long addr
);
80 void __asan_store16(unsigned long addr
);
81 void __asan_loadN(unsigned long addr
, size_t size
);
82 void __asan_storeN(unsigned long addr
, size_t size
);
84 void __asan_load1_noabort(unsigned long addr
);
85 void __asan_store1_noabort(unsigned long addr
);
86 void __asan_load2_noabort(unsigned long addr
);
87 void __asan_store2_noabort(unsigned long addr
);
88 void __asan_load4_noabort(unsigned long addr
);
89 void __asan_store4_noabort(unsigned long addr
);
90 void __asan_load8_noabort(unsigned long addr
);
91 void __asan_store8_noabort(unsigned long addr
);
92 void __asan_load16_noabort(unsigned long addr
);
93 void __asan_store16_noabort(unsigned long addr
);
94 void __asan_loadN_noabort(unsigned long addr
, size_t size
);
95 void __asan_storeN_noabort(unsigned long addr
, size_t size
);
96 void __asan_handle_no_return(void);
98 void __asan_set_shadow_00(const void *addr
, size_t size
);
99 void __asan_set_shadow_f1(const void *addr
, size_t size
);
100 void __asan_set_shadow_f2(const void *addr
, size_t size
);
101 void __asan_set_shadow_f3(const void *addr
, size_t size
);
102 void __asan_set_shadow_f5(const void *addr
, size_t size
);
103 void __asan_set_shadow_f8(const void *addr
, size_t size
);
105 void __asan_report_load1_noabort(unsigned long addr
);
106 void __asan_report_store1_noabort(unsigned long addr
);
107 void __asan_report_load2_noabort(unsigned long addr
);
108 void __asan_report_store2_noabort(unsigned long addr
);
109 void __asan_report_load4_noabort(unsigned long addr
);
110 void __asan_report_store4_noabort(unsigned long addr
);
111 void __asan_report_load8_noabort(unsigned long addr
);
112 void __asan_report_store8_noabort(unsigned long addr
);
113 void __asan_report_load16_noabort(unsigned long addr
);
114 void __asan_report_store16_noabort(unsigned long addr
);
115 void __asan_report_load_n_noabort(unsigned long addr
, size_t size
);
116 void __asan_report_store_n_noabort(unsigned long addr
, size_t size
);