Skip to content

Commit 9cc2fa4

Browse files
committed
task_stack: Fix end_of_stack() for architectures with upwards-growing stack
The function end_of_stack() returns a pointer to the last entry of a stack. For architectures like parisc where the stack grows upwards return the pointer to the highest address in the stack. Without this change I faced a crash on parisc, because the stackleak functionality wrote STACKLEAK_POISON to the lowest address and thus overwrote the first 4 bytes of the task_struct which included the TIF_FLAGS. Signed-off-by: Helge Deller <[email protected]>
1 parent f06d6e9 commit 9cc2fa4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

include/linux/sched/task_stack.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ static inline void *task_stack_page(const struct task_struct *task)
2525

2626
static inline unsigned long *end_of_stack(const struct task_struct *task)
2727
{
28+
#ifdef CONFIG_STACK_GROWSUP
29+
return (unsigned long *)((unsigned long)task->stack + THREAD_SIZE) - 1;
30+
#else
2831
return task->stack;
32+
#endif
2933
}
3034

3135
#elif !defined(__HAVE_THREAD_FUNCTIONS)

0 commit comments

Comments
 (0)