Commit 75fdf823 authored by Mark Brown's avatar Mark Brown Committed by Will Deacon
Browse files

arm64/gcs: Don't call gcs_free() when releasing task_struct



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: default avatarMark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/20250714-arm64-gcs-release-task-v2-1-8a83cadfc846@kernel.org


Signed-off-by: default avatarWill Deacon <will@kernel.org>
parent 344b6580
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -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)
+0 −6
Original line number Diff line number Diff line
@@ -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;