RE: [tip:x86/mrst] x86: Initialize stack canary in secondary start

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

 



>So with that patch applied we can remove the boot_init_stack_canary()
>in process_32/64.c cpu_idle(), can't we ?
>

[[JPAN]] i agree, bsp stack canary will be initialized in start_kernel() and
ap stack canary will be covered in start_secondary().
arjan, do you have any comments? here is the new patch.

>From 1073c9f6e1e3b0012f85b5a9c7c83e35bcc16107 Mon Sep 17 00:00:00 2001
From: Jacob Pan <jacob.jun.pan@xxxxxxxxx>
Date: Mon, 22 Feb 2010 04:14:11 -0800
Subject: [PATCH] x86/boot: reduce redundant stack canary init

move secondary cpu boot stack canary initialization prior to cpu_idle()
then remove boot_init_stack_canary() calls from cpu_idle().
this change reduced redundent stack canary init for the bsp also avoid
fake stack check failure for secondary if early schedule needed before
cpu_idle.

Signed-off-by: Jacob Pan <jacob.jun.pan@xxxxxxxxx>
---
 arch/x86/kernel/process_32.c |    9 ---------
 arch/x86/kernel/process_64.c |    9 ---------
 arch/x86/kernel/smpboot.c    |    4 ++++
 3 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index f6c6266..d4c764a 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -85,15 +85,6 @@ void cpu_idle(void)
 {
 	int cpu = smp_processor_id();
 
-	/*
-	 * If we're the non-boot CPU, nothing set the stack canary up
-	 * for us.  CPU0 already has it initialized but no harm in
-	 * doing it again.  This is a good place for updating it, as
-	 * we wont ever return from this function (so the invalid
-	 * canaries already on the stack wont ever trigger).
-	 */
-	boot_init_stack_canary();
-
 	current_thread_info()->status |= TS_POLLING;
 
 	/* endless idle loop with no priority at all */
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index fc6ad4b..1fd6713 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -110,15 +110,6 @@ void cpu_idle(void)
 {
 	current_thread_info()->status |= TS_POLLING;
 
-	/*
-	 * If we're the non-boot CPU, nothing set the stack canary up
-	 * for us.  CPU0 already has it initialized but no harm in
-	 * doing it again.  This is a good place for updating it, as
-	 * we wont ever return from this function (so the invalid
-	 * canaries already on the stack wont ever trigger).
-	 */
-	boot_init_stack_canary();
-
 	/* endless idle loop with no priority at all */
 	while (1) {
 		tick_nohz_stop_sched_tick(1);
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index c08829a..820638d 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -48,6 +48,7 @@
 #include <linux/err.h>
 #include <linux/nmi.h>
 #include <linux/tboot.h>
+#include <linux/stackprotector.h>
 
 #include <asm/acpi.h>
 #include <asm/desc.h>
@@ -328,6 +329,9 @@ notrace static void __cpuinit start_secondary(void *unused)
 	/* enable local interrupts */
 	local_irq_enable();
 
+	/* to prevent fake stack check failure in clock setup */
+	boot_init_stack_canary();
+
 	x86_cpuinit.setup_percpu_clockev();
 
 	wmb();
-- 
1.5.6.5


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

[Index of Archives]     [Linux Stable Commits]     [Linux Stable Kernel]     [Linux Kernel]     [Linux USB Devel]     [Linux Video &Media]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux