x86/apic/x2apic: Fix a NULL pointer deref when handling a dying cpu
commit7a22e03b0cupstream. Check that the per-cpu cluster mask pointer has been set prior to clearing a dying cpu's bit. The per-cpu pointer is not set until the target cpu reaches smp_callin() during CPUHP_BRINGUP_CPU, whereas the teardown function, x2apic_dead_cpu(), is associated with the earlier CPUHP_X2APIC_PREPARE. If an error occurs before the cpu is awakened, e.g. if do_boot_cpu() itself fails, x2apic_dead_cpu() will dereference the NULL pointer and cause a panic. smpboot: do_boot_cpu failed(-22) to wakeup CPU#1 BUG: kernel NULL pointer dereference, address: 0000000000000008 RIP: 0010:x2apic_dead_cpu+0x1a/0x30 Call Trace: cpuhp_invoke_callback+0x9a/0x580 _cpu_up+0x10d/0x140 do_cpu_up+0x69/0xb0 smp_init+0x63/0xa9 kernel_init_freeable+0xd7/0x229 ? rest_init+0xa0/0xa0 kernel_init+0xa/0x100 ret_from_fork+0x35/0x40 Fixes:023a611748("x86/apic/x2apic: Simplify cluster management") Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: stable@vger.kernel.org Link: https://lkml.kernel.org/r/20191001205019.5789-1-sean.j.christopherson@intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
1709917289
commit
4dedaa73c4
1 changed files with 2 additions and 1 deletions
|
|
@ -158,7 +158,8 @@ static int x2apic_dead_cpu(unsigned int dead_cpu)
|
|||
{
|
||||
struct cluster_mask *cmsk = per_cpu(cluster_masks, dead_cpu);
|
||||
|
||||
cpumask_clear_cpu(dead_cpu, &cmsk->mask);
|
||||
if (cmsk)
|
||||
cpumask_clear_cpu(dead_cpu, &cmsk->mask);
|
||||
free_cpumask_var(per_cpu(ipi_mask, dead_cpu));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue