From: David Stevens <[email protected]> The vm_stack struct used to free stacks via an RCU callback is stored directly in the stack being freed. Make sure it's stored at the beginning of the stack regardless of stack growth direction, to avoid faults on partially allocated stacks.
Signed-off-by: David Stevens <[email protected]> Signed-off-by: Mostafa Saleh <[email protected]> --- kernel/fork.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/fork.c b/kernel/fork.c index ec4431bf309a..473878d7f62f 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -285,7 +285,12 @@ static void thread_stack_free_rcu(struct rcu_head *rh) static void thread_stack_delayed_free(struct task_struct *tsk) { - struct vm_stack *vm_stack = tsk->stack; + struct vm_stack *vm_stack; + + if (IS_ENABLED(CONFIG_STACK_GROWSUP)) + vm_stack = tsk->stack; + else + vm_stack = tsk->stack + THREAD_SIZE - sizeof(*vm_stack); vm_stack->stack_vm_area = tsk->stack_vm_area; call_rcu(&vm_stack->rcu, thread_stack_free_rcu); -- 2.56.0.rc1.315.gc6ed9934b7-goog

