Skip to content

Commit

Permalink
Merge tag 'sched-urgent-2021-11-28' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/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()
  • Loading branch information
Linus Torvalds committed Nov 28, 2021
2 parents 1ed1d3a + dce1ca0 commit 97891bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 7 additions & 0 deletions kernel/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <linux/smpboot.h>
#include <linux/relay.h>
#include <linux/slab.h>
#include <linux/scs.h>
#include <linux/percpu-rwsem.h>
#include <linux/cpuset.h>

Expand Down Expand Up @@ -587,6 +588,12 @@ static int bringup_cpu(unsigned int cpu)
struct task_struct *idle = idle_thread_get(cpu);
int ret;

/*
* Reset stale stack state from the last time this CPU was online.
*/
scs_task_reset(idle);
kasan_unpoison_task_stack(idle);

/*
* Some architectures have to walk the irq descriptors to
* setup the vector space for the cpu which comes online.
Expand Down
4 changes: 0 additions & 4 deletions kernel/sched/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -8619,9 +8619,6 @@ void __init init_idle(struct task_struct *idle, int cpu)
idle->flags |= PF_IDLE | PF_KTHREAD | PF_NO_SETAFFINITY;
kthread_set_per_cpu(idle, cpu);

scs_task_reset(idle);
kasan_unpoison_task_stack(idle);

#ifdef CONFIG_SMP
/*
* It's possible that init_idle() gets called multiple times on a task,
Expand Down Expand Up @@ -8777,7 +8774,6 @@ void idle_task_exit(void)
finish_arch_post_lock_switch();
}

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

Expand Down

0 comments on commit 97891bb

Please sign in to comment.