Skip to content

Commit dc7eb87

Browse files
brooniewilldeacon
authored andcommitted
arm64/sme: Always exit sme_alloc() early with existing storage
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: 5d0a8d2 ("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>
1 parent 8410186 commit dc7eb87

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

arch/arm64/kernel/fpsimd.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,8 +1217,10 @@ void fpsimd_release_task(struct task_struct *dead_task)
12171217
*/
12181218
void sme_alloc(struct task_struct *task, bool flush)
12191219
{
1220-
if (task->thread.sme_state && flush) {
1221-
memset(task->thread.sme_state, 0, sme_state_size(task));
1220+
if (task->thread.sme_state) {
1221+
if (flush)
1222+
memset(task->thread.sme_state, 0,
1223+
sme_state_size(task));
12221224
return;
12231225
}
12241226

0 commit comments

Comments
 (0)