xref: /linux/lib/test_fortify/test_fortify.h (revision 03ab8e6297acd1bc0eedaa050e2a1635c576fd11)
1*be58f710SKees Cook /* SPDX-License-Identifier: GPL-2.0-only */
2*be58f710SKees Cook #include <linux/kernel.h>
3*be58f710SKees Cook #include <linux/printk.h>
4*be58f710SKees Cook #include <linux/slab.h>
5*be58f710SKees Cook #include <linux/string.h>
6*be58f710SKees Cook 
7*be58f710SKees Cook void do_fortify_tests(void);
8*be58f710SKees Cook 
9*be58f710SKees Cook #define __BUF_SMALL	16
10*be58f710SKees Cook #define __BUF_LARGE	32
11*be58f710SKees Cook struct fortify_object {
12*be58f710SKees Cook 	int a;
13*be58f710SKees Cook 	char buf[__BUF_SMALL];
14*be58f710SKees Cook 	int c;
15*be58f710SKees Cook };
16*be58f710SKees Cook 
17*be58f710SKees Cook #define LITERAL_SMALL "AAAAAAAAAAAAAAA"
18*be58f710SKees Cook #define LITERAL_LARGE "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
19*be58f710SKees Cook const char small_src[__BUF_SMALL] = LITERAL_SMALL;
20*be58f710SKees Cook const char large_src[__BUF_LARGE] = LITERAL_LARGE;
21*be58f710SKees Cook 
22*be58f710SKees Cook char small[__BUF_SMALL];
23*be58f710SKees Cook char large[__BUF_LARGE];
24*be58f710SKees Cook struct fortify_object instance;
25*be58f710SKees Cook size_t size;
26*be58f710SKees Cook 
do_fortify_tests(void)27*be58f710SKees Cook void do_fortify_tests(void)
28*be58f710SKees Cook {
29*be58f710SKees Cook 	/* Normal initializations. */
30*be58f710SKees Cook 	memset(&instance, 0x32, sizeof(instance));
31*be58f710SKees Cook 	memset(small, 0xA5, sizeof(small));
32*be58f710SKees Cook 	memset(large, 0x5A, sizeof(large));
33*be58f710SKees Cook 
34*be58f710SKees Cook 	TEST;
35*be58f710SKees Cook }
36