xref: /linux/include/linux/poison.h (revision 6d2bef9df7ccf3a2db0160be24f8b92a3f24708a)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2c9cf5528SRandy Dunlap #ifndef _LINUX_POISON_H
3c9cf5528SRandy Dunlap #define _LINUX_POISON_H
4c9cf5528SRandy Dunlap 
5c9cf5528SRandy Dunlap /********** include/linux/list.h **********/
6a29815a3SAvi Kivity 
7a29815a3SAvi Kivity /*
8a29815a3SAvi Kivity  * Architectures might want to move the poison pointer offset
9a29815a3SAvi Kivity  * into some well-recognized area such as 0xdead000000000000,
10a29815a3SAvi Kivity  * that is also not mappable by user-space exploits:
11a29815a3SAvi Kivity  */
12a29815a3SAvi Kivity #ifdef CONFIG_ILLEGAL_POINTER_VALUE
13a29815a3SAvi Kivity # define POISON_POINTER_DELTA _AC(CONFIG_ILLEGAL_POINTER_VALUE, UL)
14a29815a3SAvi Kivity #else
15a29815a3SAvi Kivity # define POISON_POINTER_DELTA 0
16a29815a3SAvi Kivity #endif
17a29815a3SAvi Kivity 
18c9cf5528SRandy Dunlap /*
19c9cf5528SRandy Dunlap  * These are non-NULL pointers that will result in page faults
20c9cf5528SRandy Dunlap  * under normal circumstances, used to verify that nobody uses
21c9cf5528SRandy Dunlap  * non-initialized list entries.
22c9cf5528SRandy Dunlap  */
238a5e5e02SVasily Kulikov #define LIST_POISON1  ((void *) 0x100 + POISON_POINTER_DELTA)
248a5e5e02SVasily Kulikov #define LIST_POISON2  ((void *) 0x200 + POISON_POINTER_DELTA)
25c9cf5528SRandy Dunlap 
26c6f3a97fSThomas Gleixner /********** include/linux/timer.h **********/
27c6f3a97fSThomas Gleixner /*
28c6f3a97fSThomas Gleixner  * Magic number "tsta" to indicate a static timer initializer
29c6f3a97fSThomas Gleixner  * for the object debugging code.
30c6f3a97fSThomas Gleixner  */
31b8a0255dSVasily Kulikov #define TIMER_ENTRY_STATIC	((void *) 0x300 + POISON_POINTER_DELTA)
32c6f3a97fSThomas Gleixner 
33*6d2bef9dSMichael S. Tsirkin /********** mm/page_poison.c **********/
341414c7f4SLaura Abbott #ifdef CONFIG_PAGE_POISONING_ZERO
351414c7f4SLaura Abbott #define PAGE_POISON 0x00
361414c7f4SLaura Abbott #else
376a11f75bSAkinobu Mita #define PAGE_POISON 0xaa
381414c7f4SLaura Abbott #endif
396a11f75bSAkinobu Mita 
401c290f64SKirill A. Shutemov /********** mm/page_alloc.c ************/
411c290f64SKirill A. Shutemov 
42b8a0255dSVasily Kulikov #define TAIL_MAPPING	((void *) 0x400 + POISON_POINTER_DELTA)
431c290f64SKirill A. Shutemov 
44c9cf5528SRandy Dunlap /********** mm/slab.c **********/
45c9cf5528SRandy Dunlap /*
46c9cf5528SRandy Dunlap  * Magic nums for obj red zoning.
47c9cf5528SRandy Dunlap  * Placed in the first word before and the first word after an obj.
48c9cf5528SRandy Dunlap  */
49b46b8f19SDavid Woodhouse #define	RED_INACTIVE	0x09F911029D74E35BULL	/* when obj is inactive */
50b46b8f19SDavid Woodhouse #define	RED_ACTIVE	0xD84156C5635688C0ULL	/* when obj is active */
51c9cf5528SRandy Dunlap 
5281819f0fSChristoph Lameter #define SLUB_RED_INACTIVE	0xbb
5381819f0fSChristoph Lameter #define SLUB_RED_ACTIVE		0xcc
5481819f0fSChristoph Lameter 
55c9cf5528SRandy Dunlap /* ...and for poisoning */
56c9cf5528SRandy Dunlap #define	POISON_INUSE	0x5a	/* for use-uninitialised poisoning */
57c9cf5528SRandy Dunlap #define POISON_FREE	0x6b	/* for use-after-free poisoning */
58c9cf5528SRandy Dunlap #define	POISON_END	0xa5	/* end-byte of poisoning */
59c9cf5528SRandy Dunlap 
60c9cf5528SRandy Dunlap /********** arch/$ARCH/mm/init.c **********/
61c9cf5528SRandy Dunlap #define POISON_FREE_INITMEM	0xcc
62c9cf5528SRandy Dunlap 
63c9cf5528SRandy Dunlap /********** arch/ia64/hp/common/sba_iommu.c **********/
64c9cf5528SRandy Dunlap /*
65c9cf5528SRandy Dunlap  * arch/ia64/hp/common/sba_iommu.c uses a 16-byte poison string with a
66c9cf5528SRandy Dunlap  * value of "SBAIOMMU POISON\0" for spill-over poisoning.
67c9cf5528SRandy Dunlap  */
68c9cf5528SRandy Dunlap 
69c9cf5528SRandy Dunlap /********** fs/jbd/journal.c **********/
70c9cf5528SRandy Dunlap #define JBD_POISON_FREE		0x5b
71cd02ff0bSMingming Cao #define JBD2_POISON_FREE	0x5c
72c9cf5528SRandy Dunlap 
73c9cf5528SRandy Dunlap /********** drivers/base/dmapool.c **********/
74c9cf5528SRandy Dunlap #define	POOL_POISON_FREED	0xa7	/* !inuse */
75c9cf5528SRandy Dunlap #define	POOL_POISON_ALLOCATED	0xa9	/* !initted */
76c9cf5528SRandy Dunlap 
77b3c681e0SRandy Dunlap /********** drivers/atm/ **********/
78b3c681e0SRandy Dunlap #define ATM_POISON_FREE		0x12
793c6b3773SRandy Dunlap #define ATM_POISON		0xdeadbeef
80b3c681e0SRandy Dunlap 
81a7807a32SRandy Dunlap /********** kernel/mutexes **********/
82a7807a32SRandy Dunlap #define MUTEX_DEBUG_INIT	0x11
83a7807a32SRandy Dunlap #define MUTEX_DEBUG_FREE	0x22
84977625a6SNicolai Hähnle #define MUTEX_POISON_WW_CTX	((void *) 0x500 + POISON_POINTER_DELTA)
85a7807a32SRandy Dunlap 
8619da3dd1SDavid Rientjes /********** lib/flex_array.c **********/
8719da3dd1SDavid Rientjes #define FLEX_ARRAY_FREE	0x6c	/* for use-after-free poisoning */
8819da3dd1SDavid Rientjes 
89a7807a32SRandy Dunlap /********** security/ **********/
90a7807a32SRandy Dunlap #define KEY_DESTROY		0xbd
91a7807a32SRandy Dunlap 
92c9cf5528SRandy Dunlap #endif
93