Skip to content

Commit cbbcfb9

Browse files
jlintonarmctmarinas
authored andcommitted
arm64/gcs: task_gcs_el0_enable() should use passed task
Mark Rutland noticed that the task parameter is ignored and 'current' is being used instead. Since this is usually what its passed, it hasn't yet been causing problems but likely will as the code gets more testing. But, once this is fixed, it creates a new bug in copy_thread_gcs() since the gcs_el_mode isn't yet set for the task before its being checked. Move gcs_alloc_thread_stack() after the new task's gcs_el0_mode initialization to avoid this. Fixes: fc84bc5 ("arm64/gcs: Context switch GCS state for EL0") Signed-off-by: Jeremy Linton <[email protected]> Reviewed-by: Mark Brown <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 1a665a7 commit cbbcfb9

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

arch/arm64/include/asm/gcs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static inline u64 gcsss2(void)
5858

5959
static inline bool task_gcs_el0_enabled(struct task_struct *task)
6060
{
61-
return current->thread.gcs_el0_mode & PR_SHADOW_STACK_ENABLE;
61+
return task->thread.gcs_el0_mode & PR_SHADOW_STACK_ENABLE;
6262
}
6363

6464
void gcs_set_el0_mode(struct task_struct *task);

arch/arm64/kernel/process.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,13 @@ static int copy_thread_gcs(struct task_struct *p,
305305
p->thread.gcs_base = 0;
306306
p->thread.gcs_size = 0;
307307

308+
p->thread.gcs_el0_mode = current->thread.gcs_el0_mode;
309+
p->thread.gcs_el0_locked = current->thread.gcs_el0_locked;
310+
308311
gcs = gcs_alloc_thread_stack(p, args);
309312
if (IS_ERR_VALUE(gcs))
310313
return PTR_ERR((void *)gcs);
311314

312-
p->thread.gcs_el0_mode = current->thread.gcs_el0_mode;
313-
p->thread.gcs_el0_locked = current->thread.gcs_el0_locked;
314-
315315
return 0;
316316
}
317317

0 commit comments

Comments
 (0)