summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Brown <broonie@kernel.org>2024-01-15 20:15:46 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-05-22 14:10:10 +0200
commitf6421555dbd7cb3d4d70b69f33f998aaeca1e3b5 (patch)
tree2a34366ddabfae8ddc3d72b24f27648882b7958b
parentb0f013bebf94fe7ae75e5a53be2f2bd1cc1841e3 (diff)
arm64/sme: Always exit sme_alloc() early with existing storage
commit dc7eb8755797ed41a0d1b5c0c39df3c8f401b3d9 upstream. When sme_alloc() is called with existing storage and we are not flushing we will always allocate new storage, both leaking the existing storage and corrupting the state. Fix this by separating the checks for flushing and for existing storage as we do for SVE. Callers that reallocate (eg, due to changing the vector length) should call sme_free() themselves. Fixes: 5d0a8d2fba50 ("arm64/ptrace: Ensure that SME is set up for target when writing SSVE state") Signed-off-by: Mark Brown <broonie@kernel.org> Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20240115-arm64-sme-flush-v1-1-7472bd3459b7@kernel.org Signed-off-by: Will Deacon <will@kernel.org> Signed-off-by: Zhaoyang Li <lizy04@hust.edu.cn> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--arch/arm64/kernel/fpsimd.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c
index 47425311acc5..b3e101a7d04f 100644
--- a/arch/arm64/kernel/fpsimd.c
+++ b/arch/arm64/kernel/fpsimd.c
@@ -1259,8 +1259,10 @@ void fpsimd_release_task(struct task_struct *dead_task)
*/
void sme_alloc(struct task_struct *task, bool flush)
{
- if (task->thread.za_state && flush) {
- memset(task->thread.za_state, 0, za_state_size(task));
+ if (task->thread.za_state) {
+ if (flush)
+ memset(task->thread.za_state, 0,
+ za_state_size(task));
return;
}