Re: [PATCH v11 16/29] x86/fpu/xstate: Support both legacy and expanded signal XSTATE size

From: Thomas Gleixner
Date: Tue Oct 05 2021 - 08:31:03 EST


On Fri, Oct 01 2021 at 15:37, Chang S. Bae wrote:
> static int
> do_sigaltstack (const stack_t *ss, stack_t *oss, unsigned long sp,
> size_t min_ss_size)
> @@ -4187,6 +4192,9 @@ do_sigaltstack (const stack_t *ss, stack_t *oss, unsigned long sp,
> return -ENOMEM;
> }
>
> + if (!arch_enough_sigaltstack(t, ss_size))
> + return -EINVAL;
> +

How is this even remotely correct?

sigaltstack(2):

To disable an existing stack, specify ss.ss_flags as SS_DISABLE. In
this case, the kernel ignores any other flags in ss.ss_flags and the
remaining fields in ss.

So for SS_DISABLE ss_size can be legitimately 0 or any other random
number smaller than the required stack.

The min_ss_minsize check is conditional for this very reason.

Thanks,

tglx