aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386/kernel/smp.c
diff options
context:
space:
mode:
authorFernando Vazquez <fernando@intellilink.co.jp>2006-10-01 02:29:07 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-01 03:39:30 -0400
commitdc2bc768a009b9ad8711894c544dc6b0d8c0ce57 (patch)
treeadc89a0b0a4d049b2a5387e330454809b9af6be2 /arch/i386/kernel/smp.c
parentce71ec36840368b877fb63bd14c8e67ab62d08b1 (diff)
[PATCH] stack overflow safe kdump: safe_smp_processor_id()
This is a the first of a series of patch-sets aiming at making kdump more robust against stack overflows. This patch set does the following: * Add safe_smp_processor_id function to i386 architecture (this function was inspired by the x86_64 function of the same name). * Substitute "smp_processor_id" with the stack overflow-safe "safe_smp_processor_id" in the reboot path to the second kernel. This patch: On the event of a stack overflow critical data that usually resides at the bottom of the stack is likely to be stomped and, consequently, its use should be avoided. In particular, in the i386 and IA64 architectures the macro smp_processor_id ultimately makes use of the "cpu" member of struct thread_info which resides at the bottom of the stack. x86_64, on the other hand, is not affected by this problem because it benefits from the use of the PDA infrastructure. To circumvent this problem I suggest implementing "safe_smp_processor_id()" (it already exists in x86_64) for i386 and IA64 and use it as a replacement for smp_processor_id in the reboot path to the dump capture kernel. This is a possible implementation for i386. Signed-off-by: Fernando Vazquez <fernando@intellilink.co.jp> Looks-reasonable-to: Andi Kleen <ak@muc.de> Acked-by: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Vivek Goyal <vgoyal@in.ibm.com> Cc: James Bottomley <James.Bottomley@steeleye.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/i386/kernel/smp.c')
-rw-r--r--arch/i386/kernel/smp.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/arch/i386/kernel/smp.c b/arch/i386/kernel/smp.c
index 465188e2d701..1b080ab8a49f 100644
--- a/arch/i386/kernel/smp.c
+++ b/arch/i386/kernel/smp.c
@@ -700,3 +700,30 @@ int smp_call_function_single(int cpu, void (*func) (void *info), void *info,
700 return 0; 700 return 0;
701} 701}
702EXPORT_SYMBOL(smp_call_function_single); 702EXPORT_SYMBOL(smp_call_function_single);
703
704static int convert_apicid_to_cpu(int apic_id)
705{
706 int i;
707
708 for (i = 0; i < NR_CPUS; i++) {
709 if (x86_cpu_to_apicid[i] == apic_id)
710 return i;
711 }
712 return -1;
713}
714
715int safe_smp_processor_id(void)
716{
717 int apicid, cpuid;
718
719 if (!boot_cpu_has(X86_FEATURE_APIC))
720 return 0;
721
722 apicid = hard_smp_processor_id();
723 if (apicid == BAD_APICID)
724 return 0;
725
726 cpuid = convert_apicid_to_cpu(apicid);
727
728 return cpuid >= 0 ? cpuid : 0;
729}