From: Ingo Molnar <mingo@elte.hu>
To: Tejun Heo <tj@kernel.org>
Cc: hpa@zytor.com, jeremy@goop.org, tglx@linutronix.de,
linux-kernel@vger.kernel.org, x86@kernel.org,
rusty@rustcorp.com.au
Subject: [PATCH] stackprotector: fix multi-word cross-builds
Date: Wed, 11 Feb 2009 12:18:46 +0100 [thread overview]
Message-ID: <20090211111846.GA22772@elte.hu> (raw)
In-Reply-To: <20090211105729.GO20518@elte.hu>
* Ingo Molnar <mingo@elte.hu> wrote:
>
> * Tejun Heo <tj@kernel.org> wrote:
>
> > Ingo Molnar wrote:
> > >>> I'll try other compilers but which version are you using? The
> > >>> difference is that before the patchset, -fno-stack-protector was
> > >>> always added whether stackprotector was enabled or not so this problem
> > >>> wasn't visible (at the cost of bogus stackprotector of course). We'll
> > >>> probably need to add __stack_chk_guard or disable if gcc generates
> > >>> such symbol. I'll play with different gccs.
> > >> Can't reproduce with gcc-4.1 or 4.2. Any chance you're using distcc
> > >> w/ a build machine w/ glibc < 2.4? __stack_chk_guard is the symbol
> > >> gcc fetches stack canary from if TLS is not supported, so somehow gcc
> > >> thought that TLS wasn't available while building head64.
> > >
> > > yeah - i also used distcc. Maybe the nostackp makefile magic gets confused
> > > about that?
> >
> > It seems that even with the same gcc versions, gcc built against libc
> > w/o TLS support generates __stack_chk_guard, so if you mix the two
> > flavors, the has-stack-protector check can be compiled on machines w/
> > TLS while some other files end up being built on machines w/o TLS
> > support thus circumventing the support check. Can you please see
> > whether non-distcc build fails too?
>
> That build succeeds:
>
> rhea:~/tip> make -j30 bzImage ARCH=x86_64 CROSS_COMPILE='/opt/crosstool/gcc-4.2.3-glibc-2.3.6/x86_64-unknown-linux-gnu/bin/x86_64-unknown-linux-gnu-'
> /home/mingo/tip/arch/x86/Makefile:82: stack protector enabled but no compiler support
> CHK include/linux/version.h
> [...]
> BFD: arch/x86/boot/compressed/vmlinux.bin: warning: allocated section `.bss' not in segment
> [...]
> Root device is (8, 3)
> Setup is 11996 bytes (padded to 12288 bytes).
> System is 5690 kB
> CRC be1b2e21
> Kernel: arch/x86/boot/bzImage is ready (#3)
>
> Some shell variable expansion bug? If CROSS_COMPILE is not a single word
> we fail to detect the compiler borkage at arch/x86/Makefile line 82?
Yep - i'm testing the fix below now - it's looking good so far.
Ingo
---------->
>From ebd9026d9f8499abc60d82d949bd37f88fe34a41 Mon Sep 17 00:00:00 2001
From: Ingo Molnar <mingo@elte.hu>
Date: Wed, 11 Feb 2009 12:17:29 +0100
Subject: [PATCH] stackprotector: fix multi-word cross-builds
Stackprotector builds were failing if CROSS_COMPILER was more than
a single world (such as when distcc was used) - because the check
scripts used $1 instead of $*.
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
scripts/gcc-x86_32-has-stack-protector.sh | 2 +-
scripts/gcc-x86_64-has-stack-protector.sh | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/gcc-x86_32-has-stack-protector.sh b/scripts/gcc-x86_32-has-stack-protector.sh
index 4fdf6ce..29493dc 100644
--- a/scripts/gcc-x86_32-has-stack-protector.sh
+++ b/scripts/gcc-x86_32-has-stack-protector.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-echo "int foo(void) { char X[200]; return 3; }" | $1 -S -xc -c -O0 -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
+echo "int foo(void) { char X[200]; return 3; }" | $* -S -xc -c -O0 -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
if [ "$?" -eq "0" ] ; then
echo y
else
diff --git a/scripts/gcc-x86_64-has-stack-protector.sh b/scripts/gcc-x86_64-has-stack-protector.sh
index 2d69fcd..afaec61 100644
--- a/scripts/gcc-x86_64-has-stack-protector.sh
+++ b/scripts/gcc-x86_64-has-stack-protector.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-echo "int foo(void) { char X[200]; return 3; }" | $1 -S -xc -c -O0 -mcmodel=kernel -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
+echo "int foo(void) { char X[200]; return 3; }" | $* -S -xc -c -O0 -mcmodel=kernel -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
if [ "$?" -eq "0" ] ; then
echo y
else
next prev parent reply other threads:[~2009-02-11 11:19 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-09 13:39 [PATCHSET x86/master] add stack protector support for x86_32 Tejun Heo
2009-02-09 13:39 ` [PATCH 01/11] x86: include correct %gs in a.out core dump Tejun Heo
2009-02-09 17:12 ` Jeremy Fitzhardinge
2009-02-09 13:39 ` [PATCH 02/11] x86: math_emu info cleanup Tejun Heo
2009-02-09 13:42 ` Ingo Molnar
2009-02-09 13:45 ` Ingo Molnar
2009-02-09 13:52 ` Tejun Heo
2009-02-09 13:39 ` [PATCH 03/11] x86: fix math_emu register frame access Tejun Heo
2009-02-09 17:13 ` Brian Gerst
2009-02-09 23:40 ` Ingo Molnar
2009-02-10 1:08 ` Tejun Heo
2009-02-09 13:39 ` [PATCH 04/11] elf: add ELF_CORE_COPY_KERNEL_REGS() Tejun Heo
2009-02-09 13:39 ` [PATCH 05/11] x86: stackprotector.h misc update Tejun Heo
2009-02-09 13:39 ` [PATCH 06/11] stackprotector: update make rules Tejun Heo
2009-02-09 13:39 ` [PATCH 07/11] x86: no stack protector for vdso Tejun Heo
2009-02-09 13:39 ` [PATCH 08/11] x86: use asm .macro instead of cpp #define in entry_32.S Tejun Heo
2009-02-09 18:34 ` Jeremy Fitzhardinge
2009-02-10 1:14 ` Tejun Heo
2009-02-10 1:18 ` Jeremy Fitzhardinge
2009-02-10 11:11 ` Ingo Molnar
2009-02-09 13:39 ` [PATCH 09/11] x86: add %gs accessors for x86_32 Tejun Heo
2009-02-09 13:39 ` [PATCH 10/11] x86: make lazy %gs optional on x86_32 Tejun Heo
2009-02-09 18:12 ` Jeremy Fitzhardinge
2009-02-10 1:27 ` Tejun Heo
2009-02-10 1:51 ` Jeremy Fitzhardinge
2009-02-09 13:39 ` [PATCH 11/11] x86: implement x86_32 stack protector Tejun Heo
2009-02-10 15:25 ` Brian Gerst
2009-02-10 15:39 ` Tejun Heo
2009-02-11 7:31 ` [PATCH x86#core/percpu] x86: fix x86_32 stack protector bugs Tejun Heo
2009-02-11 10:34 ` Ingo Molnar
2009-02-11 14:18 ` Tejun Heo
2009-02-09 13:55 ` [PATCHSET x86/master] add stack protector support for x86_32 Ingo Molnar
2009-02-09 14:06 ` Ingo Molnar
2009-02-09 20:30 ` Ingo Molnar
2009-02-10 13:56 ` Tejun Heo
2009-02-10 14:16 ` Ingo Molnar
2009-02-09 14:12 ` Ingo Molnar
2009-02-10 13:54 ` Tejun Heo
2009-02-10 14:16 ` Tejun Heo
2009-02-10 14:20 ` Ingo Molnar
2009-02-10 14:26 ` Tejun Heo
2009-02-11 10:57 ` Ingo Molnar
2009-02-11 11:18 ` Ingo Molnar [this message]
2009-02-11 14:19 ` [PATCH] stackprotector: fix multi-word cross-builds Tejun Heo
2009-02-10 14:19 ` [PATCHSET x86/master] add stack protector support for x86_32 Ingo Molnar
2009-02-09 14:09 ` Brian Gerst
2009-02-09 14:15 ` Ingo Molnar
2009-02-10 1:36 ` Tejun Heo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090211111846.GA22772@elte.hu \
--to=mingo@elte.hu \
--cc=hpa@zytor.com \
--cc=jeremy@goop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rusty@rustcorp.com.au \
--cc=tglx@linutronix.de \
--cc=tj@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox