+ stack-overflow-safe-kdump-safe_smp_processor_id.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled

     stack overflow safe kdump: safe_smp_processor_id()

has been added to the -mm tree.  Its filename is

     stack-overflow-safe-kdump-safe_smp_processor_id.patch

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: stack overflow safe kdump: safe_smp_processor_id()
From: Fernando Vazquez <fernando@xxxxxxxxxxxxxxxxx>


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@xxxxxxxxxxxxxxxxx>
Looks-reasonable-to: Andi Kleen <ak@xxxxxx>
Acked-by: "Eric W. Biederman" <ebiederm@xxxxxxxxxxxx>
Cc: Vivek Goyal <vgoyal@xxxxxxxxxx>
Cc: James Bottomley <James.Bottomley@xxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 arch/i386/kernel/smp.c |   26 ++++++++++++++++++++++++++
 include/asm-i386/smp.h |    2 ++
 2 files changed, 28 insertions(+)

diff -puN arch/i386/kernel/smp.c~stack-overflow-safe-kdump-safe_smp_processor_id arch/i386/kernel/smp.c
--- a/arch/i386/kernel/smp.c~stack-overflow-safe-kdump-safe_smp_processor_id
+++ a/arch/i386/kernel/smp.c
@@ -634,3 +634,29 @@ fastcall void smp_call_function_interrup
 	}
 }
 
+static int convert_apicid_to_cpu(int apic_id)
+{
+	int i;
+
+	for (i = 0; i < NR_CPUS; i++) {
+		if (x86_cpu_to_apicid[i] == apic_id)
+			return i;
+	}
+	return -1;
+}
+
+int safe_smp_processor_id(void)
+{
+	int apicid, cpuid;
+
+	if (!boot_cpu_has(X86_FEATURE_APIC))
+		return 0;
+
+	apicid = hard_smp_processor_id();
+	if (apicid == BAD_APICID)
+		return 0;
+
+	cpuid = convert_apicid_to_cpu(apicid);
+
+	return cpuid >= 0 ? cpuid : 0;
+}
diff -puN include/asm-i386/smp.h~stack-overflow-safe-kdump-safe_smp_processor_id include/asm-i386/smp.h
--- a/include/asm-i386/smp.h~stack-overflow-safe-kdump-safe_smp_processor_id
+++ a/include/asm-i386/smp.h
@@ -82,6 +82,7 @@ static inline int hard_smp_processor_id(
 #endif
 #endif
 
+extern int safe_smp_processor_id(void);
 extern int __cpu_disable(void);
 extern void __cpu_die(unsigned int cpu);
 extern unsigned int num_processors;
@@ -90,6 +91,7 @@ extern unsigned int num_processors;
 
 #else /* CONFIG_SMP */
 
+#define safe_smp_processor_id()		0
 #define cpu_physical_id(cpu)		boot_cpu_physical_apicid
 
 #define NO_PROC_ID		0xFF		/* No processor magic marker */
_

Patches currently in -mm which might be from fernando@xxxxxxxxxxxxxxxxx are

stack-overflow-safe-kdump-safe_smp_processor_id.patch
stack-overflow-safe-kdump-safe_smp_processor_id_voyager.patch
stack-overflow-safe-kdump-crash_use_safe_smp_processor_id.patch
stack-overflow-safe-kdump-safe_smp_send_nmi_allbutself.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux