Re: [PATCH] MIPS: Prevent "restoration" of MSA context in non-MSA kernels

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 21 Apr 2016, Paul Burton wrote:

> diff --git a/arch/mips/kernel/signal.c b/arch/mips/kernel/signal.c
> index bf792e2..a304b70 100644
> --- a/arch/mips/kernel/signal.c
> +++ b/arch/mips/kernel/signal.c
> @@ -195,6 +195,9 @@ static int restore_msa_extcontext(void __user *buf, unsigned int size)
>  	unsigned int csr;
>  	int i, err;
>  
> +	if (!config_enabled(CONFIG_CPU_HAS_MSA))
> +		return SIGSYS;
> +
>  	if (size != sizeof(*msa))
>  		return -EINVAL;

 The priciple of your change looks reasonable itself to me, however its 
call site is ill-formed making it possible to return a nonsensical error 
code:

	if (used & USED_EXTCONTEXT)
		err |= restore_extcontext(sc_to_extcontext(sc));

	return err ?: sig;
}

(`restore_extcontext' takes the result from `restore_msa_extcontext' and 
passes it on) so if an earlier call has set `err' to -EINVAL (which I take 
it is the only value expected here or we'd have a preexisting problem), 
then `protected_restore_fp_context' (which is where this code comes from) 
will return (-EINVAL | SIGSYS).

 So you need to redesign this code somehow I'm afraid, maybe just changing 
the condition to:

	if (!err && (used & USED_EXTCONTEXT))

will do (although while at it I'd double-check that `err' can really only 
be -EINVAL here).

  Maciej
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]