Re: Stack protector build failure (was Re: 2.6.25-mm1: not looking good)

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Arjan van de Ven <arjan@...>
Cc: Andrew Morton <akpm@...>, Ingo Molnar <mingo@...>, Thomas Gleixner <tglx@...>, <sam@...>, <linux-kernel@...>
Date: Friday, April 18, 2008 - 12:57 pm

Arjan van de Ven wrote:

ok I found a way that works for me:

From: Arjan van de Ven <arjan@linux.intel.com>
Subject: [PATCH] stackprotector: turn not having the right gcc into an #error

If the user selects the stack-protector config option, but does not have
a gcc that has the right bits enabled (for example because it isn't build
with a glibc that supports TLS, as is common for cross-compilers, but also
because it may be too old), then the runtime test fails right now.

Andrew rightfully points out that this is a condition we can detect at
build time, and we should error out at that point instead.

This patch adds an error message for this scenario. This error accomplishes
two goals
1) the user is informed that the security option he selective isn't available
2) the user has enough info to turn of the CONFIG option that won't work for him,
    and would make the runtime test fail anyway.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
---
  arch/x86/Makefile |    2 +-
  kernel/panic.c    |    3 +++
  2 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/arch/x86/Makefile b/arch/x86/Makefile
index 3cff3c8..c3e0eee 100644
--- a/arch/x86/Makefile
+++ b/arch/x86/Makefile
@@ -73,7 +73,7 @@ else

          stackp := $(CONFIG_SHELL) $(srctree)/scripts/gcc-x86_64-has-stack-protector.sh
          stackp-$(CONFIG_CC_STACKPROTECTOR) := $(shell $(stackp) \
-                "$(CC)" -fstack-protector )
+                "$(CC)" "-fstack-protector -DGCC_HAS_SP" )
          stackp-$(CONFIG_CC_STACKPROTECTOR_ALL) += $(shell $(stackp) \
                  "$(CC)" -fstack-protector-all )

diff --git a/kernel/panic.c b/kernel/panic.c
index c92c1e2..7cbcd8e 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -321,6 +321,9 @@ EXPORT_SYMBOL(warn_on_slowpath);

  #ifdef CONFIG_CC_STACKPROTECTOR

+#ifndef GCC_HAS_SP
+#error You have selected the CONFIG_CC_STACKPROTECTOR option, but the gcc used does not support this.
+#endif
  static unsigned long __stack_check_testing;
  /*
   * Self test function for the stack-protector feature.
-- 
1.5.4.5
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
2.6.25-mm1: not looking good, Andrew Morton, (Thu Apr 17, 7:03 pm)
2.6.25-mm1: Failing to probe IDE interface, Mel Gorman, (Mon Apr 28, 12:42 pm)
Re: 2.6.25-mm1: Failing to probe IDE interface, Bartlomiej Zolnierkiewicz..., (Mon Apr 28, 2:44 pm)
Re: 2.6.25-mm1: Failing to probe IDE interface, Mel Gorman, (Tue Apr 29, 5:43 am)
Re: 2.6.25-mm1: Failing to probe IDE interface, Mel Gorman, (Tue Apr 29, 11:49 am)
Re: 2.6.25-mm1: Failing to probe IDE interface, Mel Gorman, (Tue Apr 29, 12:58 pm)
Re: 2.6.25-mm1: Failing to probe IDE interface, Bartlomiej Zolnierkiewicz..., (Tue Apr 29, 5:37 pm)
Re: 2.6.25-mm1: Failing to probe IDE interface, Mel Gorman, (Wed Apr 30, 7:16 am)
Re: 2.6.25-mm1: Failing to probe IDE interface, Andrew Morton, (Mon Apr 28, 12:59 pm)
Re: 2.6.25-mm1: Failing to probe IDE interface, Mel Gorman, (Tue Apr 29, 5:39 am)
Re: 2.6.25-mm1: not looking good, Andrew Morton, (Fri Apr 18, 3:50 am)
Re: 2.6.25-mm1: not looking good, Andrew Morton, (Fri Apr 18, 3:53 am)
Re: 2.6.25-mm1: not looking good, Pavel Machek, (Fri Apr 18, 7:07 am)
Re: 2.6.25-mm1: not looking good, Pavel Machek, (Fri Apr 18, 5:42 am)
Re: 2.6.25-mm1: not looking good, Alan Stern, (Fri Apr 18, 11:22 am)
Re: 2.6.25-mm1: not looking good, Andrew Morton, (Fri Apr 18, 3:57 am)
Re: 2.6.25-mm1: not looking good, Ingo Molnar, (Fri Apr 18, 5:22 am)
Re: 2.6.25-mm1: not looking good, Ingo Molnar, (Fri Apr 18, 8:18 am)
Re: 2.6.25-mm1: not looking good, Ingo Molnar, (Fri Apr 18, 3:09 am)
Re: 2.6.25-mm1: not looking good, Pekka Enberg, (Fri Apr 18, 2:40 am)
Re: 2.6.25-mm1: not looking good, Ingo Molnar, (Fri Apr 18, 3:24 am)
Re: 2.6.25-mm1: not looking good, James Morris, (Fri Apr 18, 6:32 am)
Re: 2.6.25-mm1: not looking good, Pekka Enberg, (Fri Apr 18, 3:25 am)
Re: 2.6.25-mm1: not looking good, Andrew Morton, (Fri Apr 18, 2:56 am)
Re: 2.6.25-mm1: not looking good, Arjan van de Ven, (Fri Apr 18, 1:49 am)
Re: 2.6.25-mm1: not looking good, Andrew Morton, (Fri Apr 18, 2:10 am)
Re: 2.6.25-mm1: not looking good, Ingo Molnar, (Fri Apr 18, 3:19 am)
Re: 2.6.25-mm1: not looking good, Andrew Morton, (Fri Apr 18, 3:28 am)
Re: Stack protector build failure (was Re: 2.6.25-mm1: not l..., Arjan van de Ven, (Fri Apr 18, 12:57 pm)
Re: 2.6.25-mm1: not looking good, Ingo Molnar, (Fri Apr 18, 5:28 am)
Re: 2.6.25-mm1: not looking good, Paul Moore, (Thu Apr 17, 7:55 pm)
Re: 2.6.25-mm1: not looking good, Andrew Morton, (Thu Apr 17, 9:35 pm)
Re: 2.6.25-mm1: not looking good, Paul Moore, (Fri Apr 18, 10:57 am)
Re: 2.6.25-mm1: not looking good, Andrew Morton, (Thu Apr 17, 8:04 pm)
Re: 2.6.25-mm1: not looking good, Paul Moore, (Fri Apr 18, 10:55 am)
Re: 2.6.25-mm1: not looking good, Andrew Morton, (Thu Apr 17, 7:40 pm)
Re: 2.6.25-mm1: not looking good, Andrew Morton, (Thu Apr 17, 8:14 pm)
Re: 2.6.25-mm1: not looking good, Jason Wessel, (Thu Apr 17, 11:05 pm)
Re: 2.6.25-mm1: not looking good, Ingo Molnar, (Fri Apr 18, 3:37 am)
Re: 2.6.25-mm1: not looking good, Jason Wessel, (Fri Apr 18, 5:54 pm)
Re: 2.6.25-mm1: not looking good, Vegard Nossum, (Fri Apr 18, 7:46 am)
Re: 2.6.25-mm1: not looking good, Ingo Molnar, (Fri Apr 18, 8:34 am)
Re: 2.6.25-mm1: not looking good, Vegard Nossum, (Fri Apr 18, 8:41 am)
Re: 2.6.25-mm1: not looking good, Jason Wessel, (Fri Apr 18, 9:02 am)
Re: 2.6.25-mm1: not looking good, Vegard Nossum, (Fri Apr 18, 9:22 am)
Re: 2.6.25-mm1: not looking good, Jason Wessel, (Fri Apr 18, 9:27 am)
Re: 2.6.25-mm1: not looking good, Vegard Nossum, (Fri Apr 18, 10:47 am)
Re: 2.6.25-mm1: not looking good, Vegard Nossum, (Fri Apr 18, 12:02 pm)
Re: 2.6.25-mm1: not looking good, Greg KH, (Thu Apr 17, 7:24 pm)
Re: 2.6.25-mm1: not looking good, Kay Sievers, (Thu Apr 17, 8:48 pm)
Re: 2.6.25-mm1: not looking good, Andrew Morton, (Fri Apr 18, 12:07 am)
Re: 2.6.25-mm1: not looking good, Andrew Morton, (Thu Apr 17, 9:12 pm)
Re: 2.6.25-mm1: not looking good, Dan Williams, (Thu Apr 17, 7:24 pm)