BUG() the kernel via the hotplug target sysfs file

From: Sebastian Andrzej Siewior
Date: Fri Jun 02 2017 - 10:47:58 EST


It is possible to BUG() the kernel via the hotplug target interface via:
|echo 91 > /sys/devices/system/cpu/cpu7/hotplug/target
| Unregister pv shared memory for cpu 7
| ------------[ cut here ]------------
| kernel BUG at kernel/cpu.c:747!

which is:

| void cpuhp_report_idle_dead(void)
| {
| struct cpuhp_cpu_state *st = this_cpu_ptr(&cpuhp_state);
|
=> BUG_ON(st->state != CPUHP_AP_OFFLINE);
| â
| }

So the states are:
89: idle:dead
90: ap:offline
91: sched:starting
92: RCU/tree:dying
132: ap:online
133: cpu:teardown

and cpu:teardown (takedown_cpu()) invokes:
cpu_stopper_thread()
multi_cpu_stop()
take_cpu_down()
native_cpu_disable()
cpu_disable_common()

which clears the CPU from cpu_online_mask. This means, as things are
now, we can't stop at any state between cpu:teardown and idle:dead.

Sebastian