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