1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_POISON_H
3 #define _LINUX_POISON_H
4 
5 /********** include/linux/list.h **********/
6 
7 /*
8  * Architectures might want to move the poison pointer offset
9  * into some well-recognized area such as 0xdead000000000000,
10  * that is also not mappable by user-space exploits:
11  */
12 #ifdef CONFIG_ILLEGAL_POINTER_VALUE
13 # define POISON_POINTER_DELTA _AC(CONFIG_ILLEGAL_POINTER_VALUE, UL)
14 #else
15 # define POISON_POINTER_DELTA 0
16 #endif
17 
18 /*
19  * These are non-NULL pointers that will result in page faults
20  * under normal circumstances, used to verify that nobody uses
21  * non-initialized list entries.
22  */
23 #define LIST_POISON1  ((void *) 0x100 + POISON_POINTER_DELTA)
24 #define LIST_POISON2  ((void *) 0x200 + POISON_POINTER_DELTA)
25 
26 /********** include/linux/timer.h **********/
27 /*
28  * Magic number "tsta" to indicate a static timer initializer
29  * for the object debugging code.
30  */
31 #define TIMER_ENTRY_STATIC	((void *) 0x300 + POISON_POINTER_DELTA)
32 
33 /********** mm/debug-pagealloc.c **********/
34 #ifdef CONFIG_PAGE_POISONING_ZERO
35 #define PAGE_POISON 0x00
36 #else
37 #define PAGE_POISON 0xaa
38 #endif
39 
40 /********** mm/page_alloc.c ************/
41 
42 #define TAIL_MAPPING	((void *) 0x400 + POISON_POINTER_DELTA)
43 
44 /********** mm/slab.c **********/
45 /*
46  * Magic nums for obj red zoning.
47  * Placed in the first word before and the first word after an obj.
48  */
49 #define	RED_INACTIVE	0x09F911029D74E35BULL	/* when obj is inactive */
50 #define	RED_ACTIVE	0xD84156C5635688C0ULL	/* when obj is active */
51 
52 #define SLUB_RED_INACTIVE	0xbb
53 #define SLUB_RED_ACTIVE		0xcc
54 
55 /* ...and for poisoning */
56 #define	POISON_INUSE	0x5a	/* for use-uninitialised poisoning */
57 #define POISON_FREE	0x6b	/* for use-after-free poisoning */
58 #define	POISON_END	0xa5	/* end-byte of poisoning */
59 
60 /********** arch/$ARCH/mm/init.c **********/
61 #define POISON_FREE_INITMEM	0xcc
62 
63 /********** arch/ia64/hp/common/sba_iommu.c **********/
64 /*
65  * arch/ia64/hp/common/sba_iommu.c uses a 16-byte poison string with a
66  * value of "SBAIOMMU POISON\0" for spill-over poisoning.
67  */
68 
69 /********** fs/jbd/journal.c **********/
70 #define JBD_POISON_FREE		0x5b
71 #define JBD2_POISON_FREE	0x5c
72 
73 /********** drivers/base/dmapool.c **********/
74 #define	POOL_POISON_FREED	0xa7	/* !inuse */
75 #define	POOL_POISON_ALLOCATED	0xa9	/* !initted */
76 
77 /********** drivers/atm/ **********/
78 #define ATM_POISON_FREE		0x12
79 #define ATM_POISON		0xdeadbeef
80 
81 /********** kernel/mutexes **********/
82 #define MUTEX_DEBUG_INIT	0x11
83 #define MUTEX_DEBUG_FREE	0x22
84 #define MUTEX_POISON_WW_CTX	((void *) 0x500 + POISON_POINTER_DELTA)
85 
86 /********** lib/flex_array.c **********/
87 #define FLEX_ARRAY_FREE	0x6c	/* for use-after-free poisoning */
88 
89 /********** security/ **********/
90 #define KEY_DESTROY		0xbd
91 
92 #endif
93