Skip to content

Commit

Permalink
[PATCH] x86_64: Fix fast check in safe_smp_processor_id
Browse files Browse the repository at this point in the history
The APIC ID returned by hard_smp_processor_id can be beyond
NR_CPUS and then overflow the x86_cpu_to_apic[] array.

Add a check for overflow. If it happens then the slow loop below
will catch.

Bug pointed out by Doug Thompson

Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Andi Kleen authored and Linus Torvalds committed Jun 26, 2006
1 parent e42f943 commit 75bd665
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions arch/x86_64/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,13 +520,13 @@ asmlinkage void smp_call_function_interrupt(void)

int safe_smp_processor_id(void)
{
int apicid, i;
unsigned apicid, i;

if (disable_apic)
return 0;

apicid = hard_smp_processor_id();
if (x86_cpu_to_apicid[apicid] == apicid)
if (apicid < NR_CPUS && x86_cpu_to_apicid[apicid] == apicid)
return apicid;

for (i = 0; i < NR_CPUS; ++i) {
Expand Down

0 comments on commit 75bd665

Please sign in to comment.