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