Patch "arm64/ptrace: Don't flush ZA/ZT storage when writing ZA via ptrace" has been added to the 6.6-stable tree

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

 



This is a note to let you know that I've just added the patch titled

    arm64/ptrace: Don't flush ZA/ZT storage when writing ZA via ptrace

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     arm64-ptrace-don-t-flush-za-zt-storage-when-writing-.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 6f0ade78b3058199ac4a2d86210a11f1562b3ad8
Author: Mark Brown <broonie@xxxxxxxxxx>
Date:   Mon Jan 15 18:42:38 2024 +0000

    arm64/ptrace: Don't flush ZA/ZT storage when writing ZA via ptrace
    
    [ Upstream commit b7c510d049049409e8945b932f4b0b357fa17415 ]
    
    When writing ZA we currently unconditionally flush the buffer used to store
    it as part of ensuring that it is allocated. Since this buffer is shared
    with ZT0 this means that a write to ZA when PSTATE.ZA is already set will
    corrupt the value of ZT0 on a SME2 system. Fix this by only flushing the
    backing storage if PSTATE.ZA was not previously set.
    
    This will mean that short or failed writes may leave stale data in the
    buffer, this seems as correct as our current behaviour and unlikely to be
    something that userspace will rely on.
    
    Fixes: f90b529bcbe5 ("arm64/sme: Implement ZT0 ptrace support")
    Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20240115-arm64-fix-ptrace-za-zt-v1-1-48617517028a@xxxxxxxxxx
    Signed-off-by: Will Deacon <will@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c
index 20d7ef82de90..b3f64144b5cd 100644
--- a/arch/arm64/kernel/ptrace.c
+++ b/arch/arm64/kernel/ptrace.c
@@ -1107,12 +1107,13 @@ static int za_set(struct task_struct *target,
 		}
 	}
 
-	/* Allocate/reinit ZA storage */
-	sme_alloc(target, true);
-	if (!target->thread.sme_state) {
-		ret = -ENOMEM;
-		goto out;
-	}
+	/*
+	 * Only flush the storage if PSTATE.ZA was not already set,
+	 * otherwise preserve any existing data.
+	 */
+	sme_alloc(target, !thread_za_enabled(&target->thread));
+	if (!target->thread.sme_state)
+		return -ENOMEM;
 
 	/* If there is no data then disable ZA */
 	if (!count) {




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux