Re: [PATCH v2] x86: signal: move save_altstack_ex out of generic headers

From: Oleg Nesterov
Date: Sat Apr 04 2020 - 12:02:17 EST


On 04/03, Nick Desaulniers wrote:
>
> --- a/arch/x86/kernel/signal.c
> +++ b/arch/x86/kernel/signal.c
> @@ -416,6 +416,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
> return 0;
> Efault:
> user_access_end();
> + reset_altstack();
> return -EFAULT;
> }
> #else /* !CONFIG_X86_32 */
> @@ -507,6 +508,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
>
> Efault:
> user_access_end();
> + reset_altstack();
> return -EFAULT;
> }

I must have missed something, but this looks just wrong.

reset_altstack() should be called when __setup_rt_frame() (and
unsafe_save_altstack() in particular) succeeds, not when it fails.

Nevermind, Al has already suggested to use signal_delivered()...

Oleg.