Skip to content

Commit f642155

Browse files
brooniegregkh
authored andcommitted
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 <[email protected]> Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]> Signed-off-by: Zhaoyang Li <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent b0f013b commit f642155

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
@@ -1259,8 +1259,10 @@ void fpsimd_release_task(struct task_struct *dead_task)
12591259
*/
12601260
void sme_alloc(struct task_struct *task, bool flush)
12611261
{
1262-
if (task->thread.za_state && flush) {
1263-
memset(task->thread.za_state, 0, za_state_size(task));
1262+
if (task->thread.za_state) {
1263+
if (flush)
1264+
memset(task->thread.za_state, 0,
1265+
za_state_size(task));
12641266
return;
12651267
}
12661268

0 commit comments

Comments
 (0)