Linux kernel -stable discussions
 help / color / mirror / Atom feed
* [PATCH 1/2] arm64/fpsimd: signal: Require ZA context when restoring ZT context
       [not found] <20261110221836.3265929-1-bradley.morgan@linux.dev>
@ 2026-11-10 22:18 ` Bradley Morgan
  2026-11-16 22:48   ` Mark Brown
  0 siblings, 1 reply; 3+ messages in thread
From: Bradley Morgan @ 2026-11-10 22:18 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon
  Cc: Mark Rutland, Mark Brown, linux-arm-kernel, linux-kernel,
	bradley.morgan, stable

When restoring the signal frame, restore_zt_context() checks whether ZA
is enabled via thread_za_enabled(&current->thread). However, if user.za
is omitted from the signal frame, restore_za_context() is skipped entirely.
If the signal handler touched SME prior to rt_sigreturn(), ZA remains
enabled in current->thread.svcr from the handler context, causing
thread_za_enabled() to succeed and restore_zt_context() to write userspace
ZT data without restoring ZA state.

Require user->za to be present in the signal frame before restoring ZT.

Fixes: ee072cf70804 ("arm64/sme: Implement signal handling for ZT")
Cc: stable@vger.kernel.org
Signed-off-by: Bradley Morgan <bradley.morgan@linux.dev>
---
 arch/arm64/kernel/signal.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c
index 6a06a4e352b1d..20d5f19921e0d 100644
--- a/arch/arm64/kernel/signal.c
+++ b/arch/arm64/kernel/signal.c
@@ -678,7 +678,7 @@ static int restore_zt_context(struct user_ctxs *user)
 	u16 nregs;
 
 	/* ZA must be restored first for this check to be valid */
-	if (!thread_za_enabled(&current->thread))
+	if (!user->za || !thread_za_enabled(&current->thread))
 		return -EINVAL;
 
 	if (user->zt_size != ZT_SIG_CONTEXT_SIZE(1))
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] arm64/fpsimd: signal: Require ZA context when restoring ZT context
  2026-11-10 22:18 ` [PATCH 1/2] arm64/fpsimd: signal: Require ZA context when restoring ZT context Bradley Morgan
@ 2026-11-16 22:48   ` Mark Brown
  2026-11-16 23:07     ` Bradley Morgan
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Brown @ 2026-11-16 22:48 UTC (permalink / raw)
  To: Bradley Morgan
  Cc: Catalin Marinas, Will Deacon, Mark Rutland, linux-arm-kernel,
	linux-kernel, stable

[-- Attachment #1: Type: text/plain, Size: 1162 bytes --]

On Tue, Nov 10, 2026 at 10:18:35PM +0000, Bradley Morgan wrote:
> When restoring the signal frame, restore_zt_context() checks whether ZA
> is enabled via thread_za_enabled(&current->thread). However, if user.za
> is omitted from the signal frame, restore_za_context() is skipped entirely.
> If the signal handler touched SME prior to rt_sigreturn(), ZA remains
> enabled in current->thread.svcr from the handler context, causing
> thread_za_enabled() to succeed and restore_zt_context() to write userspace
> ZT data without restoring ZA state.
> 
> Require user->za to be present in the signal frame before restoring ZT.

I supposed there's an argument that the signal handler might've intended
this but still, this does feel more sensible:

Reviewed-by: Mark Brown <broonie@kernel.org>

though as the Sashiko report identifies we still leave ZA untouched if
both ZA and ZT are omitted from the signal frame.  I'm not sure if it's
safer to reject any attempt to return from a signal with PSTATE.ZA set
but no ZA signal frame or if we should restore PSTATE.ZA to 0, the
former is safer but the latter is more in line with the handling here.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/2] arm64/fpsimd: signal: Require ZA context when restoring ZT context
  2026-11-16 22:48   ` Mark Brown
@ 2026-11-16 23:07     ` Bradley Morgan
  0 siblings, 0 replies; 3+ messages in thread
From: Bradley Morgan @ 2026-11-16 23:07 UTC (permalink / raw)
  To: Mark Brown
  Cc: Catalin Marinas, Will Deacon, Mark Rutland, linux-arm-kernel,
	linux-kernel, stable


On 11/16/26 10:48 PM, Mark Brown wrote:
> On Tue, Nov 10, 2026 at 10:18:35PM +0000, Bradley Morgan wrote:
>> When restoring the signal frame, restore_zt_context() checks whether ZA
>> is enabled via thread_za_enabled(&current->thread). However, if user.za
>> is omitted from the signal frame, restore_za_context() is skipped entirely.
>> If the signal handler touched SME prior to rt_sigreturn(), ZA remains
>> enabled in current->thread.svcr from the handler context, causing
>> thread_za_enabled() to succeed and restore_zt_context() to write userspace
>> ZT data without restoring ZA state.
>>
>> Require user->za to be present in the signal frame before restoring ZT.
> I supposed there's an argument that the signal handler might've intended
> this but still, this does feel more sensible:
>
> Reviewed-by: Mark Brown <broonie@kernel.org>
>
> though as the Sashiko report identifies we still leave ZA untouched if
> both ZA and ZT are omitted from the signal frame.  I'm not sure if it's
> safer to reject any attempt to return from a signal with PSTATE.ZA set
> but no ZA signal frame or if we should restore PSTATE.ZA to 0, the
> former is safer but the latter is more in line with the handling here.


Thx, do you suggest any remedies, id say sashiko is correct, but id hate 
for code

to get hairy :)


--- Thanks!


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-16 23:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20261110221836.3265929-1-bradley.morgan@linux.dev>
2026-11-10 22:18 ` [PATCH 1/2] arm64/fpsimd: signal: Require ZA context when restoring ZT context Bradley Morgan
2026-11-16 22:48   ` Mark Brown
2026-11-16 23:07     ` Bradley Morgan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox