lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240130115107.GB13551@willie-the-truck>
Date: Tue, 30 Jan 2024 11:51:07 +0000
From: Will Deacon <will@...nel.org>
To: Mark Brown <broonie@...nel.org>
Cc: Catalin Marinas <catalin.marinas@....com>,
	Dave Martin <dave.martin@....com>,
	linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
	stable@...r.kernel.org
Subject: Re: [PATCH] arm64/signal: Don't assume that TIF_SVE means we saved
 SVE state

On Fri, Jan 19, 2024 at 12:29:13PM +0000, Mark Brown wrote:
> When we are in a syscall we will only save the FPSIMD subset even though
> the task still has access to the full register set, and on context switch
> we will only remove TIF_SVE when loading the register state. This means
> that the signal handling code should not assume that TIF_SVE means that
> the register state is stored in SVE format, it should instead check the
> format that was recorded during save.
> 
> Fixes: 8c845e273104 ("arm64/sve: Leave SVE enabled on syscall if we don't context switch")
> Signed-off-by: Mark Brown <broonie@...nel.org>
> Cc:  <stable@...r.kernel.org>
> ---
>  arch/arm64/kernel/fpsimd.c | 2 +-
>  arch/arm64/kernel/signal.c | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
> index 1559c706d32d..80133c190136 100644
> --- a/arch/arm64/kernel/fpsimd.c
> +++ b/arch/arm64/kernel/fpsimd.c
> @@ -1626,7 +1626,7 @@ void fpsimd_preserve_current_state(void)
>  void fpsimd_signal_preserve_current_state(void)
>  {
>  	fpsimd_preserve_current_state();
> -	if (test_thread_flag(TIF_SVE))
> +	if (current->thread.fp_type == FP_STATE_SVE)
>  		sve_to_fpsimd(current);
>  }

I don't think this hunk applies on -rc2 ^^.

> diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
> index 0e8beb3349ea..425b1bc17a3f 100644
> --- a/arch/arm64/kernel/signal.c
> +++ b/arch/arm64/kernel/signal.c
> @@ -242,7 +242,7 @@ static int preserve_sve_context(struct sve_context __user *ctx)
>  		vl = task_get_sme_vl(current);
>  		vq = sve_vq_from_vl(vl);
>  		flags |= SVE_SIG_FLAG_SM;
> -	} else if (test_thread_flag(TIF_SVE)) {
> +	} else if (current->thread.fp_type == FP_STATE_SVE) {
>  		vq = sve_vq_from_vl(vl);
>  	}
>  
> @@ -878,7 +878,7 @@ static int setup_sigframe_layout(struct rt_sigframe_user_layout *user,
>  	if (system_supports_sve() || system_supports_sme()) {
>  		unsigned int vq = 0;
>  
> -		if (add_all || test_thread_flag(TIF_SVE) ||
> +		if (add_all || current->thread.fp_type == FP_STATE_SVE ||
>  		    thread_sm_enabled(&current->thread)) {
>  			int vl = max(sve_max_vl(), sme_max_vl());

I think this code is preemptible, so I'm struggling to understand what
happens if the fp_type changes under our feet as a result of a context
switch.

Will

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ