Skip to content

Commit 97891bb

Browse files
committed
Merge tag 'sched-urgent-2021-11-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull scheduler fix from Thomas Gleixner: "A single scheduler fix to ensure that there is no stale KASAN shadow state left on the idle task's stack when a CPU is brought up after it was brought down before" * tag 'sched-urgent-2021-11-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: sched/scs: Reset task stack state in bringup_cpu()
2 parents 1ed1d3a + dce1ca0 commit 97891bb

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

kernel/cpu.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <linux/smpboot.h>
3232
#include <linux/relay.h>
3333
#include <linux/slab.h>
34+
#include <linux/scs.h>
3435
#include <linux/percpu-rwsem.h>
3536
#include <linux/cpuset.h>
3637

@@ -587,6 +588,12 @@ static int bringup_cpu(unsigned int cpu)
587588
struct task_struct *idle = idle_thread_get(cpu);
588589
int ret;
589590

591+
/*
592+
* Reset stale stack state from the last time this CPU was online.
593+
*/
594+
scs_task_reset(idle);
595+
kasan_unpoison_task_stack(idle);
596+
590597
/*
591598
* Some architectures have to walk the irq descriptors to
592599
* setup the vector space for the cpu which comes online.

kernel/sched/core.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8619,9 +8619,6 @@ void __init init_idle(struct task_struct *idle, int cpu)
86198619
idle->flags |= PF_IDLE | PF_KTHREAD | PF_NO_SETAFFINITY;
86208620
kthread_set_per_cpu(idle, cpu);
86218621

8622-
scs_task_reset(idle);
8623-
kasan_unpoison_task_stack(idle);
8624-
86258622
#ifdef CONFIG_SMP
86268623
/*
86278624
* It's possible that init_idle() gets called multiple times on a task,
@@ -8777,7 +8774,6 @@ void idle_task_exit(void)
87778774
finish_arch_post_lock_switch();
87788775
}
87798776

8780-
scs_task_reset(current);
87818777
/* finish_cpu(), as ran on the BP, will clean up the active_mm state */
87828778
}
87838779

0 commit comments

Comments
 (0)