Ubuntu-focal-kernel/kernel
Peter Zijlstra c99d49e861 sched/core: Fix illegal RCU from offline CPUs
BugLink: https://bugs.launchpad.net/bugs/1885023

[ Upstream commit bf2c59fce4 ]

In the CPU-offline process, it calls mmdrop() after idle entry and the
subsequent call to cpuhp_report_idle_dead(). Once execution passes the
call to rcu_report_dead(), RCU is ignoring the CPU, which results in
lockdep complaining when mmdrop() uses RCU from either memcg or
debugobjects below.

Fix it by cleaning up the active_mm state from BP instead. Every arch
which has CONFIG_HOTPLUG_CPU should have already called idle_task_exit()
from AP. The only exception is parisc because it switches them to
&init_mm unconditionally (see smp_boot_one_cpu() and smp_cpu_init()),
but the patch will still work there because it calls mmgrab(&init_mm) in
smp_cpu_init() and then should call mmdrop(&init_mm) in finish_cpu().

  WARNING: suspicious RCU usage
  -----------------------------
  kernel/workqueue.c:710 RCU or wq_pool_mutex should be held!

  other info that might help us debug this:

  RCU used illegally from offline CPU!
  Call Trace:
   dump_stack+0xf4/0x164 (unreliable)
   lockdep_rcu_suspicious+0x140/0x164
   get_work_pool+0x110/0x150
   __queue_work+0x1bc/0xca0
   queue_work_on+0x114/0x120
   css_release+0x9c/0xc0
   percpu_ref_put_many+0x204/0x230
   free_pcp_prepare+0x264/0x570
   free_unref_page+0x38/0xf0
   __mmdrop+0x21c/0x2c0
   idle_task_exit+0x170/0x1b0
   pnv_smp_cpu_kill_self+0x38/0x2e0
   cpu_die+0x48/0x64
   arch_cpu_idle_dead+0x30/0x50
   do_idle+0x2f4/0x470
   cpu_startup_entry+0x38/0x40
   start_secondary+0x7a8/0xa80
   start_secondary_resume+0x10/0x14

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Qian Cai <cai@lca.pw>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
Link: https://lkml.kernel.org/r/20200401214033.8448-1-cai@lca.pw
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
2020-08-08 01:53:12 -04:00
..
bpf bpf: Support llvm-objcopy for vmlinux BTF 2020-08-08 01:53:12 -04:00
cgroup cgroup1: don't call release_agent when it is "" 2020-04-03 15:17:23 +02:00
configs
debug kgdb: Prevent infinite recursive entries to the debugger 2020-08-08 01:53:12 -04:00
dma dma-direct: fix data truncation in dma_direct_get_required_mask() 2020-05-25 10:41:36 +02:00
events perf: Add cond_resched() to task_function_call() 2020-08-08 01:53:12 -04:00
gcov kernel/gcov/fs.c: gcov_seq_next() should increase position index 2020-05-25 10:41:36 +02:00
irq genirq/debugfs: Add missing sanity checks to interrupt injection 2020-05-05 12:32:22 +02:00
livepatch livepatch: Nullify obj->mod in klp_module_coming()'s error path 2019-08-19 13:03:37 +02:00
locking locktorture: Print ratio of acquisitions, not failures 2020-05-25 10:41:28 +02:00
power PM: hibernate: Freeze kernel threads in software_resume() 2020-05-25 10:42:21 +02:00
printk printk: queue wake_up_klogd irq_work only if per-CPU areas are ready 2020-05-25 10:42:00 +02:00
rcu rcu: Allow only one expedited GP to run concurrently with wakeups 2020-03-06 14:05:59 +01:00
sched sched/core: Fix illegal RCU from offline CPUs 2020-08-08 01:53:12 -04:00
time time/sched_clock: Expire timer in hardirq context 2020-05-05 12:32:22 +02:00
trace Stop the ad-hoc games with -Wno-maybe-initialized 2020-06-22 17:21:58 -03:00
.gitignore
Kconfig.freezer
Kconfig.hz
Kconfig.locks
Kconfig.preempt sched/rt, Kconfig: Unbreak def/oldconfig with CONFIG_PREEMPT=y 2019-07-22 18:05:11 +02:00
Makefile Merge branch 'next-integrity' of git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity 2019-09-27 19:37:27 -07:00
acct.c
async.c
audit.c audit: fix a net reference leak in audit_list_rules_send() 2020-08-08 01:53:12 -04:00
audit.h audit: fix a net reference leak in audit_list_rules_send() 2020-08-08 01:53:12 -04:00
audit_fsnotify.c
audit_tree.c
audit_watch.c audit_get_nd(): don't unlock parent too early 2019-11-10 11:56:55 -05:00
auditfilter.c audit: fix a net reference leak in audit_list_rules_send() 2020-08-08 01:53:12 -04:00
auditsc.c
backtracetest.c
bounds.c
capability.c
compat.c
configs.c kernel/configs: Replace GPL boilerplate code with SPDX identifier 2019-07-30 18:34:15 +02:00
context_tracking.c
cpu.c sched/core: Fix illegal RCU from offline CPUs 2020-08-08 01:53:12 -04:00
cpu_pm.c
crash_core.c
crash_dump.c
cred.c keys: Fix request_key() cache 2020-01-30 16:24:47 +01:00
delayacct.c
dma.c
elfcore.c kernel/elfcore.c: include proper prototypes 2019-09-25 17:51:39 -07:00
exec_domain.c
exit.c exit: Move preemption fixup up, move blocking operations down 2020-08-08 01:53:12 -04:00
extable.c extable: Add function to search only kernel exception table 2019-08-21 22:23:48 +10:00
fail_function.c
fork.c fork: prevent accidental access to clone3 features 2020-06-22 17:21:51 -03:00
freezer.c Revert "libata, freezer: avoid block device removal while system is frozen" 2019-10-06 09:11:37 -06:00
futex.c futex: Unbreak futex hashing 2020-04-03 15:17:23 +02:00
gen_kheaders.sh kheaders: substituting --sort in archive creation 2019-10-17 09:08:19 +09:00
groups.c
hung_task.c
iomem.c mm/nvdimm: add is_ioremap_addr and use that to check ioremap address 2019-07-12 11:05:40 -07:00
irq_work.c
jump_label.c jump_label: Don't warn on __exit jump entries 2019-08-29 15:10:10 +01:00
kallsyms.c kallsyms: Don't let kallsyms_lookup_size_offset() fail on retrieving the first symbol 2019-08-27 16:19:56 +01:00
kcmp.c
kcov.c
kexec.c kexec_load: Disable at runtime if the kernel is locked down 2019-08-19 21:54:15 -07:00
kexec_core.c kexec: bail out upon SIGKILL when allocating memory. 2019-09-25 17:51:40 -07:00
kexec_elf.c kexec_elf: support 32 bit ELF files 2019-09-06 23:58:44 +02:00
kexec_file.c Merge branch 'next-lockdown' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security 2019-09-28 08:14:15 -07:00
kexec_internal.h
kheaders.c
kmod.c kmod: make request_module() return an error when autoloading is disabled 2020-05-05 12:32:22 +02:00
kprobes.c kprobes: Fix optimize_kprobe()/unoptimize_kprobe() cancellation logic 2020-03-12 18:01:58 +01:00
ksysfs.c
kthread.c UBUNTU: SAUCE: kthread: Do not leave kthread_create() immediately upon SIGKILL. 2019-11-25 14:56:25 +01:00
latencytop.c
module-internal.h
module.c module: avoid setting info->name early in case we can fall back to info->mod->name 2020-02-24 16:20:02 +01:00
module_signature.c MODSIGN: Export module signature definitions 2019-08-05 18:39:56 -04:00
module_signing.c UBUNTU: SAUCE: (lockdown) KEYS: Make use of platform keyring for module signature verify 2019-11-25 14:56:44 +01:00
notifier.c x86/mm: split vmalloc_sync_all() 2020-04-03 15:17:23 +02:00
nsproxy.c
padata.c padata: add separate cpuhp node for CPUHP_PADATA_DEAD 2020-08-08 01:53:12 -04:00
panic.c panic: ensure preemption is disabled during panic() 2019-10-07 15:47:19 -07:00
params.c lockdown: Lock down module params that specify hardware parameters (eg. ioport) 2019-08-19 21:54:16 -07:00
pid.c kernel/pid.c: convert struct pid count to refcount_t 2019-07-16 19:23:24 -07:00
pid_namespace.c proc/sysctl: add shared variables for range check 2019-07-18 17:08:07 -07:00
profile.c
ptrace.c ptrace: reintroduce usage of subjective credentials in ptrace_has_cap() 2020-01-30 16:25:58 +01:00
range.c
reboot.c
relay.c kernel/relay.c: handle alloc_percpu returning NULL in relay_open 2020-07-02 12:53:51 +02:00
resource.c mm/memory_hotplug.c: use PFN_UP / PFN_DOWN in walk_system_ram_range() 2019-09-24 15:54:09 -07:00
rseq.c
seccomp.c seccomp: Add missing compat_ioctl for notify 2020-05-05 12:32:22 +02:00
signal.c signal: check sig before setting info in kill_pid_usb_asyncio 2020-05-25 10:42:10 +02:00
smp.c smp: Warn on function calls from softirq context 2019-07-20 11:27:16 +02:00
smpboot.c
smpboot.h
softirq.c Merge branch 'irq-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2019-07-08 11:01:13 -07:00
stackleak.c
stacktrace.c stacktrace: Don't skip first entry on noncurrent tasks 2019-11-04 21:19:25 +01:00
stop_machine.c stop_machine: Avoid potential race behaviour 2019-10-17 12:47:12 +02:00
sys.c UBUNTU: SAUCE: (no-up) add compat_uts_machine= kernel command line override 2019-11-25 14:56:24 +01:00
sys_ni.c
sysctl.c kernel: sysctl: make drop_caches write-only 2020-01-06 10:11:54 -06:00
sysctl_binary.c
task_work.c UBUNTU: SAUCE: import aufs driver 2019-11-25 14:56:45 +01:00
taskstats.c taskstats: fix data-race 2020-01-30 16:21:42 +01:00
test_kprobes.c
torture.c torture: Remove exporting of internal functions 2019-08-01 14:30:22 -07:00
tracepoint.c The main changes in this release include: 2019-07-18 11:51:00 -07:00
tsacct.c
ucount.c proc/sysctl: add shared variables for range check 2019-07-18 17:08:07 -07:00
uid16.c
uid16.h
umh.c umh: fix memory leak on execve failure 2020-06-22 17:21:38 -03:00
up.c
user-return-notifier.c
user.c Keyrings namespacing 2019-07-08 19:36:47 -07:00
user_namespace.c UBUNTU: SAUCE: add a sysctl to disable unprivileged user namespace unsharing 2019-11-25 14:56:26 +01:00
utsname.c
utsname_sysctl.c
watchdog.c watchdog/softlockup: Enforce that timestamp is valid on boot 2020-02-24 16:20:00 +01:00
watchdog_hld.c
workqueue.c workqueue: don't use wq_select_unbound_cpu() for bound works 2020-03-18 11:39:15 +01:00
workqueue_internal.h