1 /* $NetBSD: asan.h,v 1.15 2020/09/10 14:10:46 maxv Exp $ */
4 * Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net
7 * This code is part of the KASAN subsystem of the NetBSD kernel.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
23 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
25 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #include <sys/types.h>
37 /* ASAN constants. Part of the compiler ABI. */
38 #define KASAN_SHADOW_SCALE 8
39 #define KASAN_SHADOW_SCALE_SHIFT 3
41 /* Stack redzone values. Part of the compiler ABI. */
42 #define KASAN_STACK_LEFT 0xF1
43 #define KASAN_STACK_MID 0xF2
44 #define KASAN_STACK_RIGHT 0xF3
45 #define KASAN_USE_AFTER_RET 0xF5
46 #define KASAN_USE_AFTER_SCOPE 0xF8
48 /* Our redzone values. */
49 #define KASAN_GENERIC_REDZONE 0xFA
50 #define KASAN_MALLOC_REDZONE 0xFB
51 #define KASAN_KMEM_REDZONE 0xFC
52 #define KASAN_UMA_FREED 0xFD
53 #define KASAN_KSTACK_FREED 0xFE
54 #define KASAN_EXEC_ARGS_FREED 0xFF
56 void kasan_init(void);
57 void kasan_init_early(vm_offset_t, size_t);
58 void kasan_shadow_map(vm_offset_t, size_t);
59 void kasan_mark(const void *, size_t, size_t, uint8_t);
62 #define kasan_shadow_map(a, s)
63 #define kasan_mark(p, s, l, c)
66 #endif /* !_SYS_ASAN_H_ */