]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
arm64/gcs: Don't call gcs_free() when releasing task_struct
authorMark Brown <broonie@kernel.org>
Mon, 14 Jul 2025 11:21:27 +0000 (12:21 +0100)
committerWill Deacon <will@kernel.org>
Tue, 15 Jul 2025 13:58:23 +0000 (14:58 +0100)
Currently we call gcs_free() when releasing task_struct but this is
redundant, it attempts to deallocate any kernel managed userspace GCS
which should no longer be relevant and resets values in the struct we're
in the process of freeing.

By the time arch_release_task_struct() is called the mm will have been
disassociated from the task so the check for a mm in gcs_free() will
always be false, for threads that are exiting leaving the mm active
deactivate_mm() will have been called previously and freed any kernel
managed GCS.

Signed-off-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20250714-arm64-gcs-release-task-v2-1-8a83cadfc846@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/kernel/process.c
arch/arm64/mm/gcs.c

index a5ca15daeb8a6cca9b4f009eae8cdc27c6bf4d0a..f53608ecaf4b6320a1ce0dbbff30c3636ef5938e 100644 (file)
@@ -339,7 +339,6 @@ void flush_thread(void)
 void arch_release_task_struct(struct task_struct *tsk)
 {
        fpsimd_release_task(tsk);
-       gcs_free(tsk);
 }
 
 int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
index 5c46ec527b1cdaa8f52cff445d70ba0f8509d086..6e93f78de79b17652867025435d705c70295ae70 100644 (file)
@@ -157,12 +157,6 @@ void gcs_free(struct task_struct *task)
        if (!system_supports_gcs())
                return;
 
-       /*
-        * When fork() with CLONE_VM fails, the child (tsk) already
-        * has a GCS allocated, and exit_thread() calls this function
-        * to free it.  In this case the parent (current) and the
-        * child share the same mm struct.
-        */
        if (!task->mm || task->mm != current->mm)
                return;