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