linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] idle/x86: remove the call to boot_init_stack_canary() from cpu_startup_entry()
@ 2018-10-19  9:29 Christophe Leroy
  2018-10-19 10:01 ` Juergen Gross
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Christophe Leroy @ 2018-10-19  9:29 UTC (permalink / raw)
  To: Boris Ostrovsky, Juergen Gross, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, H. Peter Anvin, Peter Zijlstra
  Cc: x86, xen-devel, linux-kernel, Michael Ellerman, linuxppc-dev

commit d7880812b359 ("idle: Add the stack canary init to
cpu_startup_entry()") added the call to boot_init_stack_canary()
in cpu_startup_entry() in an #ifdef CONFIG_X86 statement, with
the intention to remove that #ifdef later.

While implementing stack protector for powerpc, it has been
observed that calling boot_init_stack_canary() is also needed
for powerpc which uses per task (TLS) stack canary like the X86.

However, calling boot_init_stack_canary() would break arches
using global stack canary (ARM, SH, MIPS and XTENSA).

Instead of adding modifying the #ifdef in a
implemented the call to boot_init_stack_canary() in the function
calling cpu_startup_entry()

On x86, we have two functions calling cpu_startup_entry():
- start_secondary()
- cpu_bringup_and_idle()

start_secondary() already calls boot_init_stack_canary().

This patch adds the call to boot_init_stack_canary() in
cpu_bringup_and_idle() and removes it from cpu_startup_entry()

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
 arch/x86/xen/smp_pv.c |  1 +
 kernel/sched/idle.c   | 15 ---------------
 2 files changed, 1 insertion(+), 15 deletions(-)

diff --git a/arch/x86/xen/smp_pv.c b/arch/x86/xen/smp_pv.c
index e3b18ad49889..0e05e8e23998 100644
--- a/arch/x86/xen/smp_pv.c
+++ b/arch/x86/xen/smp_pv.c
@@ -88,6 +88,7 @@ static void cpu_bringup(void)
 asmlinkage __visible void cpu_bringup_and_idle(void)
 {
 	cpu_bringup();
+	boot_init_stack_canary();
 	cpu_startup_entry(CPUHP_AP_ONLINE_IDLE);
 }
 
diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
index 16f84142f2f4..f5516bae0c1b 100644
--- a/kernel/sched/idle.c
+++ b/kernel/sched/idle.c
@@ -347,21 +347,6 @@ EXPORT_SYMBOL_GPL(play_idle);
 
 void cpu_startup_entry(enum cpuhp_state state)
 {
-	/*
-	 * This #ifdef needs to die, but it's too late in the cycle to
-	 * make this generic (ARM and SH have never invoked the canary
-	 * init for the non boot CPUs!). Will be fixed in 3.11
-	 */
-#ifdef CONFIG_X86
-	/*
-	 * If we're the non-boot CPU, nothing set the stack canary up
-	 * for us. The boot CPU 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();
-#endif
 	arch_cpu_idle_prepare();
 	cpuhp_online_idle(state);
 	while (1)
-- 
2.13.3


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] idle/x86: remove the call to boot_init_stack_canary() from cpu_startup_entry()
  2018-10-19  9:29 [PATCH] idle/x86: remove the call to boot_init_stack_canary() from cpu_startup_entry() Christophe Leroy
@ 2018-10-19 10:01 ` Juergen Gross
  2018-10-19 10:33   ` Christophe LEROY
  2018-10-19 19:24 ` kbuild test robot
  2018-10-19 20:08 ` kbuild test robot
  2 siblings, 1 reply; 5+ messages in thread
From: Juergen Gross @ 2018-10-19 10:01 UTC (permalink / raw)
  To: Christophe Leroy, Boris Ostrovsky, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, H. Peter Anvin, Peter Zijlstra
  Cc: x86, xen-devel, linux-kernel, Michael Ellerman, linuxppc-dev

On 19/10/2018 11:29, Christophe Leroy wrote:
> commit d7880812b359 ("idle: Add the stack canary init to
> cpu_startup_entry()") added the call to boot_init_stack_canary()
> in cpu_startup_entry() in an #ifdef CONFIG_X86 statement, with
> the intention to remove that #ifdef later.
> 
> While implementing stack protector for powerpc, it has been
> observed that calling boot_init_stack_canary() is also needed
> for powerpc which uses per task (TLS) stack canary like the X86.
> 
> However, calling boot_init_stack_canary() would break arches
> using global stack canary (ARM, SH, MIPS and XTENSA).
> 
> Instead of adding modifying the #ifdef in a
> implemented the call to boot_init_stack_canary() in the function
> calling cpu_startup_entry()

I can't parse this sentence.

> 
> On x86, we have two functions calling cpu_startup_entry():
> - start_secondary()
> - cpu_bringup_and_idle()
> 
> start_secondary() already calls boot_init_stack_canary().
> 
> This patch adds the call to boot_init_stack_canary() in
> cpu_bringup_and_idle() and removes it from cpu_startup_entry()
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>

With the commit message made understandable you can add my

Reviewed-by: Juergen Gross <jgross@suse.com>


Juergen

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] idle/x86: remove the call to boot_init_stack_canary() from cpu_startup_entry()
  2018-10-19 10:01 ` Juergen Gross
@ 2018-10-19 10:33   ` Christophe LEROY
  0 siblings, 0 replies; 5+ messages in thread
From: Christophe LEROY @ 2018-10-19 10:33 UTC (permalink / raw)
  To: Juergen Gross, Boris Ostrovsky, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, H. Peter Anvin, Peter Zijlstra
  Cc: x86, xen-devel, linux-kernel, Michael Ellerman, linuxppc-dev



Le 19/10/2018 à 12:01, Juergen Gross a écrit :
> On 19/10/2018 11:29, Christophe Leroy wrote:
>> commit d7880812b359 ("idle: Add the stack canary init to
>> cpu_startup_entry()") added the call to boot_init_stack_canary()
>> in cpu_startup_entry() in an #ifdef CONFIG_X86 statement, with
>> the intention to remove that #ifdef later.
>>
>> While implementing stack protector for powerpc, it has been
>> observed that calling boot_init_stack_canary() is also needed
>> for powerpc which uses per task (TLS) stack canary like the X86.
>>
>> However, calling boot_init_stack_canary() would break arches
>> using global stack canary (ARM, SH, MIPS and XTENSA).
>>
>> Instead of adding modifying the #ifdef in a
>> implemented the call to boot_init_stack_canary() in the function
>> calling cpu_startup_entry()
> 
> I can't parse this sentence.

Oops, git commit took the #if for a comment and droped it. Fixed in v2.

> 
>>
>> On x86, we have two functions calling cpu_startup_entry():
>> - start_secondary()
>> - cpu_bringup_and_idle()
>>
>> start_secondary() already calls boot_init_stack_canary().
>>
>> This patch adds the call to boot_init_stack_canary() in
>> cpu_bringup_and_idle() and removes it from cpu_startup_entry()
>>
>> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
> 
> With the commit message made understandable you can add my
> 
> Reviewed-by: Juergen Gross <jgross@suse.com>
> 

Thanks
Christophe

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] idle/x86: remove the call to boot_init_stack_canary() from cpu_startup_entry()
  2018-10-19  9:29 [PATCH] idle/x86: remove the call to boot_init_stack_canary() from cpu_startup_entry() Christophe Leroy
  2018-10-19 10:01 ` Juergen Gross
@ 2018-10-19 19:24 ` kbuild test robot
  2018-10-19 20:08 ` kbuild test robot
  2 siblings, 0 replies; 5+ messages in thread
From: kbuild test robot @ 2018-10-19 19:24 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: kbuild-all, Boris Ostrovsky, Juergen Gross, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, H. Peter Anvin, Peter Zijlstra,
	x86, xen-devel, linux-kernel, Michael Ellerman, linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 1465 bytes --]

Hi Christophe,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on xen-tip/linux-next]
[also build test ERROR on v4.19-rc8 next-20181019]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Christophe-Leroy/idle-x86-remove-the-call-to-boot_init_stack_canary-from-cpu_startup_entry/20181020-015124
base:   https://git.kernel.org/pub/scm/linux/kernel/git/xen/tip.git linux-next
config: x86_64-randconfig-s1-10200246 (attached as .config)
compiler: gcc-6 (Debian 6.4.0-9) 6.4.0 20171026
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   arch/x86//xen/smp_pv.c: In function 'cpu_bringup_and_idle':
>> arch/x86//xen/smp_pv.c:91:2: error: implicit declaration of function 'boot_init_stack_canary' [-Werror=implicit-function-declaration]
     boot_init_stack_canary();
     ^~~~~~~~~~~~~~~~~~~~~~
   cc1: some warnings being treated as errors

vim +/boot_init_stack_canary +91 arch/x86//xen/smp_pv.c

    87	
    88	asmlinkage __visible void cpu_bringup_and_idle(void)
    89	{
    90		cpu_bringup();
  > 91		boot_init_stack_canary();
    92		cpu_startup_entry(CPUHP_AP_ONLINE_IDLE);
    93	}
    94	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 31357 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] idle/x86: remove the call to boot_init_stack_canary() from cpu_startup_entry()
  2018-10-19  9:29 [PATCH] idle/x86: remove the call to boot_init_stack_canary() from cpu_startup_entry() Christophe Leroy
  2018-10-19 10:01 ` Juergen Gross
  2018-10-19 19:24 ` kbuild test robot
@ 2018-10-19 20:08 ` kbuild test robot
  2 siblings, 0 replies; 5+ messages in thread
From: kbuild test robot @ 2018-10-19 20:08 UTC (permalink / raw)
  To: Christophe Leroy
  Cc: kbuild-all, Boris Ostrovsky, Juergen Gross, Thomas Gleixner,
	Ingo Molnar, Borislav Petkov, H. Peter Anvin, Peter Zijlstra,
	x86, xen-devel, linux-kernel, Michael Ellerman, linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 1480 bytes --]

Hi Christophe,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on xen-tip/linux-next]
[also build test ERROR on v4.19-rc8 next-20181019]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Christophe-Leroy/idle-x86-remove-the-call-to-boot_init_stack_canary-from-cpu_startup_entry/20181020-015124
base:   https://git.kernel.org/pub/scm/linux/kernel/git/xen/tip.git linux-next
config: x86_64-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   arch/x86/xen/smp_pv.c: In function 'cpu_bringup_and_idle':
>> arch/x86/xen/smp_pv.c:91:2: error: implicit declaration of function 'boot_init_stack_canary'; did you mean 'snprint_stack_trace'? [-Werror=implicit-function-declaration]
     boot_init_stack_canary();
     ^~~~~~~~~~~~~~~~~~~~~~
     snprint_stack_trace
   cc1: some warnings being treated as errors

vim +91 arch/x86/xen/smp_pv.c

    87	
    88	asmlinkage __visible void cpu_bringup_and_idle(void)
    89	{
    90		cpu_bringup();
  > 91		boot_init_stack_canary();
    92		cpu_startup_entry(CPUHP_AP_ONLINE_IDLE);
    93	}
    94	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 65769 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-10-19 20:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-19  9:29 [PATCH] idle/x86: remove the call to boot_init_stack_canary() from cpu_startup_entry() Christophe Leroy
2018-10-19 10:01 ` Juergen Gross
2018-10-19 10:33   ` Christophe LEROY
2018-10-19 19:24 ` kbuild test robot
2018-10-19 20:08 ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).