Skip to contentSkip to conversation

x86/x2apic: fix x2apic_cluster_probe null pointer

PATCH In review Huaitong Han 2 participants 3 messages Aug 12, 2016 x86

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/x2apic: fix x2apic_cluster_probe null pointer

percpu cpus_in_cluster is a pointer with CONFIG_CPUMASK_OFFSTACK, cpu_in_cluster is not alloced memory before x2apic_prepare_cpu is invoked, so cpumask_set_cpu would get a NULL pointer bug:

 BUG: unable to handle kernel NULL pointer dereference at (null)
 IP: [<ffffffff8105ac25>] x2apic_cluster_probe+0x35/0x70
---
 arch/x86/kernel/apic/x2apic_cluster.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
arch/x86/kernel/apic/x2apic_cluster.c +2 -1
index 6368fa6..6acb055 100644
@@ -190,9 +190,10 @@ static int x2apic_cluster_probe(void)
 	if (!x2apic_mode)
 		return 0;
 
-	cpumask_set_cpu(cpu, per_cpu(cpus_in_cluster, cpu));
 	cpuhp_setup_state(CPUHP_X2APIC_PREPARE, "X2APIC_PREPARE",
 			  x2apic_prepare_cpu, x2apic_dead_cpu);
+	cpumask_set_cpu(cpu, per_cpu(cpus_in_cluster, cpu));
+
 	return 1;
 }
 
Signature · 1 line
1.8.3.1
#1 lore raw

2016-08-12 13:30 GMT+08:00 Huaitong Han <[email protected]>:

Quoted 5 lines

percpu cpus_in_cluster is a pointer with CONFIG_CPUMASK_OFFSTACK, cpu_in_cluster is not alloced memory before x2apic_prepare_cpu is invoked, so cpumask_set_cpu would get a NULL pointer bug:

 BUG: unable to handle kernel NULL pointer dereference at (null)
 IP: [<ffffffff8105ac25>] x2apic_cluster_probe+0x35/0x70

Could you try this? https://lkml.org/lkml/2016/8/4/345

Regards,
Wanpeng Li

#2 lore raw
Quoted 8 lines · Wanpeng Li

2016-08-12 13:30 GMT+08:00 Huaitong Han <[email protected]>:

Quoted 5 lines

percpu cpus_in_cluster is a pointer with CONFIG_CPUMASK_OFFSTACK, cpu_in_cluster is not alloced memory before x2apic_prepare_cpu is invoked, so cpumask_set_cpu would get a NULL pointer bug:

 BUG: unable to handle kernel NULL pointer dereference at (null)
 IP: [<ffffffff8105ac25>] x2apic_cluster_probe+0x35/0x70

Could you try this? https://lkml.org/lkml/2016/8/4/345

Get, it has been fixed,
http://git.kernel.org/cgit/linux/kernel/git/tip/tip.git/commit/?id=d52c0569bab4edc888832df44dc7ac28517134f6

Quoted 3 lines

Regards,
Wanpeng Li