linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] arm64/ptrace: Don't clear calling process' TIF_SME on OOM
@ 2022-09-02 13:28 Mark Brown
  2022-09-06 16:27 ` Will Deacon
  2022-09-08 14:06 ` Will Deacon
  0 siblings, 2 replies; 4+ messages in thread
From: Mark Brown @ 2022-09-02 13:28 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon; +Cc: linux-arm-kernel, Mark Brown

If allocating memory for the target SVE state in za_set() fails we clear
TIF_SME for the ptracing task which is obviously not correct.  If we are
here we know that the target task already had neither TIF_SVE nor
TIF_SME set since we only need to allocate if either the target had not
used either SVE or SME and had no need to allocate state before or we
just changed the vector length with vec_set_vector_length() which clears
TIF_ for us on allocation failure so just remove the clear entirely.

Reported-by: Wang ShaoBo <bobo.shaobowang@huawei.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 arch/arm64/kernel/ptrace.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index eb7c08dfb834..041d2ae5c30a 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -1084,7 +1084,6 @@ static int za_set(struct task_struct *target,
 	if (!target->thread.sve_state) {
 		sve_alloc(target, false);
 		if (!target->thread.sve_state) {
-			clear_thread_flag(TIF_SME);
 			ret = -ENOMEM;
 			goto out;
 		}
@@ -1094,7 +1093,6 @@ static int za_set(struct task_struct *target,
 	sme_alloc(target);
 	if (!target->thread.za_state) {
 		ret = -ENOMEM;
-		clear_tsk_thread_flag(target, TIF_SME);
 		goto out;
 	}
 
-- 
2.30.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] arm64/ptrace: Don't clear calling process' TIF_SME on OOM
  2022-09-02 13:28 [PATCH] arm64/ptrace: Don't clear calling process' TIF_SME on OOM Mark Brown
@ 2022-09-06 16:27 ` Will Deacon
  2022-09-06 16:37   ` Mark Brown
  2022-09-08 14:06 ` Will Deacon
  1 sibling, 1 reply; 4+ messages in thread
From: Will Deacon @ 2022-09-06 16:27 UTC (permalink / raw)
  To: Mark Brown; +Cc: Catalin Marinas, linux-arm-kernel

On Fri, Sep 02, 2022 at 02:28:02PM +0100, Mark Brown wrote:
> If allocating memory for the target SVE state in za_set() fails we clear
> TIF_SME for the ptracing task which is obviously not correct.  If we are
> here we know that the target task already had neither TIF_SVE nor
> TIF_SME set since we only need to allocate if either the target had not
> used either SVE or SME and had no need to allocate state before or we
> just changed the vector length with vec_set_vector_length() which clears
> TIF_ for us on allocation failure so just remove the clear entirely.
> 
> Reported-by: Wang ShaoBo <bobo.shaobowang@huawei.com>
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
>  arch/arm64/kernel/ptrace.c | 2 --
>  1 file changed, 2 deletions(-)

Is this fixing a real (i.e. user-observable) issue, or is it removing some
redundant code? I'm afraid I can't tell from the commit message and I'm
trying to figure out whether we should be queueing it for -rc (and CC'ing
stable) or not.

Thanks,

Will

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] arm64/ptrace: Don't clear calling process' TIF_SME on OOM
  2022-09-06 16:27 ` Will Deacon
@ 2022-09-06 16:37   ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2022-09-06 16:37 UTC (permalink / raw)
  To: Will Deacon; +Cc: Catalin Marinas, linux-arm-kernel


[-- Attachment #1.1: Type: text/plain, Size: 774 bytes --]

On Tue, Sep 06, 2022 at 05:27:15PM +0100, Will Deacon wrote:
> On Fri, Sep 02, 2022 at 02:28:02PM +0100, Mark Brown wrote:
> > If allocating memory for the target SVE state in za_set() fails we clear
> > TIF_SME for the ptracing task which is obviously not correct.  If we are

> Is this fixing a real (i.e. user-observable) issue, or is it removing some
> redundant code? I'm afraid I can't tell from the commit message and I'm
> trying to figure out whether we should be queueing it for -rc (and CC'ing
> stable) or not.

Since we're clearing TIF_SME for the process doing the ptrace there's
the potential for causing an issue in that process where we trap a new
SME usage and flush the SME state in the process which is a data
corruption issue which would be observable.

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

[-- Attachment #2: Type: text/plain, Size: 176 bytes --]

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] arm64/ptrace: Don't clear calling process' TIF_SME on OOM
  2022-09-02 13:28 [PATCH] arm64/ptrace: Don't clear calling process' TIF_SME on OOM Mark Brown
  2022-09-06 16:27 ` Will Deacon
@ 2022-09-08 14:06 ` Will Deacon
  1 sibling, 0 replies; 4+ messages in thread
From: Will Deacon @ 2022-09-08 14:06 UTC (permalink / raw)
  To: Catalin Marinas, Mark Brown; +Cc: kernel-team, Will Deacon, linux-arm-kernel

On Fri, 2 Sep 2022 14:28:02 +0100, Mark Brown wrote:
> If allocating memory for the target SVE state in za_set() fails we clear
> TIF_SME for the ptracing task which is obviously not correct.  If we are
> here we know that the target task already had neither TIF_SVE nor
> TIF_SME set since we only need to allocate if either the target had not
> used either SVE or SME and had no need to allocate state before or we
> just changed the vector length with vec_set_vector_length() which clears
> TIF_ for us on allocation failure so just remove the clear entirely.
> 
> [...]

Applied to arm64 (for-next/fixes), thanks!

[1/1] arm64/ptrace: Don't clear calling process' TIF_SME on OOM
      https://git.kernel.org/arm64/c/d105d6920ec7

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-09-08 14:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-02 13:28 [PATCH] arm64/ptrace: Don't clear calling process' TIF_SME on OOM Mark Brown
2022-09-06 16:27 ` Will Deacon
2022-09-06 16:37   ` Mark Brown
2022-09-08 14:06 ` Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).