test_fortify.h 775 B

1234567891011121314151617181920212223242526272829303132333435
  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. void do_fortify_tests(void);
  7. #define __BUF_SMALL 16
  8. #define __BUF_LARGE 32
  9. struct fortify_object {
  10. int a;
  11. char buf[__BUF_SMALL];
  12. int c;
  13. };
  14. #define LITERAL_SMALL "AAAAAAAAAAAAAAA"
  15. #define LITERAL_LARGE "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
  16. const char small_src[__BUF_SMALL] = LITERAL_SMALL;
  17. const char large_src[__BUF_LARGE] = LITERAL_LARGE;
  18. char small[__BUF_SMALL];
  19. char large[__BUF_LARGE];
  20. struct fortify_object instance;
  21. size_t size;
  22. void do_fortify_tests(void)
  23. {
  24. /* Normal initializations. */
  25. memset(&instance, 0x32, sizeof(instance));
  26. memset(small, 0xA5, sizeof(small));
  27. memset(large, 0x5A, sizeof(large));
  28. TEST;
  29. }