An error occurred while fetching folder content.
smpboot: Add missing get_online_cpus() in smpboot_register_percpu_thread()
Lai Jiangshan authored
commit 4bee9686

 upstream.

The following race exists in the smpboot percpu threads management:

CPU0	      	   	     CPU1
cpu_up(2)
  get_online_cpus();
  smpboot_create_threads(2);
			     smpboot_register_percpu_thread();
			     for_each_online_cpu();
			       __smpboot_create_thread();
  __cpu_up(2);

This results in a missing per cpu thread for the newly onlined cpu2 and
in a NULL pointer dereference on a consecutive offline of that cpu.

Proctect smpboot_register_percpu_thread() with get_online_cpus() to
prevent that.

[ tglx: Massaged changelog and removed the change in
        smpboot_unregister_percpu_thread() because that's an
        optimization and therefor not stable material. ]
Signed-off-by: default avatarLai Jiangshan <laijs@cn.fujitsu.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Cc: David Rientjes <rientjes@google.com>
Link: http://lkml.kernel.org/r/1406777421-12830-1-git-send-email-laijs@cn.fujitsu.com

Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
4748a404
Name Last commit Last update
..
cpu sched/preempt: Fix up missed PREEMPT_NEED_RESCHED folding
debug mm: per-thread vma caching
events perf: Fix events installation during moving group
gcov gcov: reuse kbasename helper
irq genirq: Prevent proc race against freeing of irq descriptors
locking rtmutex: Plug slow unlock race
power PM / Sleep: fix recovery during resuming from hibernation
printk printk: rename printk_sched to printk_deferred
rcu rcu: Use rcu_gp_kthread_wake() to wake up grace period kthreads
sched sched/deadline: Avoid double-accounting in case of missed deadlines
time time: adjtimex: Validate the ADJ_FREQUENCY values
trace tracing/syscalls: Ignore numbers outside NR_syscalls' range
.gitignore Ignore generated file kernel/x509_certificate_list
Kconfig.freezer container freezer: implement freezer cgroup subsystem
Kconfig.hz kernel: remove CONFIG_USE_GENERIC_SMP_HELPERS
Kconfig.locks locking/mutex: Disable optimistic spinning on some architectures
Kconfig.preempt locking/kconfig: Simplify INLINE_SPIN_UNLOCK usage
Makefile KEYS: Remove files generated when SYSTEM_TRUSTED_KEYRING=y
acct.c fs: Fix hang with BSD accounting on frozen filesystem
async.c async: rename and redefine async_func_ptr
audit.c audit: AUDIT_FEATURE_CHANGE message format missing delimiting space
audit.h audit: Use struct net not pid_t to remember the network namespce to reply in
audit_tree.c audit: keep inode pinned
audit_watch.c inotify: Fix reporting of cookies for inotify events
auditfilter.c audit: restore AUDIT_LOGINUID unset ABI
auditsc.c audit: remove superfluous new- prefix in AUDIT_LOGIN messages
backtracetest.c backtrace: replace timer with tasklet + completions
bounds.c mm: do not allocate page->ptl dynamically, if spinlock_t fits to long
capability.c CAPABILITIES: remove undefined caps from all processes
cgroup.c cgroup: fix unbalanced locking
cgroup_freezer.c cgroup: replace cftype->read_seq_string() with cftype->seq_show()
compat.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal
configs.c proc: Supply PDE attribute setting accessor functions
context_tracking.c context_tracking: Wrap static key check into more intuitive function name
cpu.c sched: Fix hotplug vs. set_cpus_allowed_ptr()
cpu_pm.c kernel/cpu_pm.c: fix various typos
cpuset.c mm: page_alloc: use jump labels to avoid checking number_of_cpusets
crash_dump.c Merge branch 'modsplit-Oct31_2011' of git://git.kernel.org/pub/scm/linux/kernel/git/paulg/linux
cred.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace
delayacct.c kernel/delayacct.c: remove redundant checking in __delayacct_add_tsk()
dma.c Remove all #inclusions of asm/system.h
elfcore.c switch elf_core_write_extra_phdrs() to dump_emit()
exec_domain.c sys_personality: remove the bogus checks in sys_personality()->__set_personality() path
exit.c exit: call disassociate_ctty() before exit_task_namespaces()
extable.c kernel/extable: fix address-checks for core_kernel and init areas
fork.c mm: per-thread vma caching
freezer.c freezer: Do not freeze tasks killed by OOM killer
futex.c futex: Ensure get_futex_key_refs() always implies a barrier
futex_compat.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/signal
groups.c userns: Don't allow setgroups until a gid mapping has been setablished
hrtimer.c
hung_task.c
irq_work.c
itimer.c
jump_label.c
kallsyms.c
kcmp.c
kexec.c
kmod.c
kprobes.c
ksysfs.c
kthread.c
latencytop.c
module-internal.h
module.c
module_signing.c
notifier.c
nsproxy.c
padata.c
panic.c
params.c
pid.c
pid_namespace.c
posix-cpu-timers.c
posix-timers.c
profile.c
ptrace.c
range.c
reboot.c
relay.c
res_counter.c
resource.c
seccomp.c
signal.c
smp.c
smpboot.c
smpboot.h
softirq.c
stacktrace.c
stop_machine.c
sys.c
sys_ni.c
sysctl.c
sysctl_binary.c
system_certificates.S
system_keyring.c
task_work.c
taskstats.c
test_kprobes.c
time.c