stackleak.h 902 B

1234567891011121314151617181920212223242526272829303132333435
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_STACKLEAK_H
  3. #define _LINUX_STACKLEAK_H
  4. #include <linux/sched.h>
  5. #include <linux/sched/task_stack.h>
  6. /*
  7. * Check that the poison value points to the unused hole in the
  8. * virtual memory map for your platform.
  9. */
  10. #define STACKLEAK_POISON -0xBEEF
  11. #define STACKLEAK_SEARCH_DEPTH 128
  12. #ifdef CONFIG_GCC_PLUGIN_STACKLEAK
  13. #include <asm/stacktrace.h>
  14. static inline void stackleak_task_init(struct task_struct *t)
  15. {
  16. t->lowest_stack = (unsigned long)end_of_stack(t) + sizeof(unsigned long);
  17. # ifdef CONFIG_STACKLEAK_METRICS
  18. t->prev_lowest_stack = t->lowest_stack;
  19. # endif
  20. }
  21. #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
  22. int stack_erasing_sysctl(struct ctl_table *table, int write,
  23. void *buffer, size_t *lenp, loff_t *ppos);
  24. #endif
  25. #else /* !CONFIG_GCC_PLUGIN_STACKLEAK */
  26. static inline void stackleak_task_init(struct task_struct *t) { }
  27. #endif
  28. #endif