From: Ingo Molnar <mingo@elte.hu>
To: Brian Gerst <brgerst@gmail.com>
Cc: Tejun Heo <tj@kernel.org>,
hpa@zytor.com, jeremy@goop.org, tglx@linutronix.de,
linux-kernel@vger.kernel.org, x86@kernel.org,
rusty@rustcorp.com.au
Subject: Re: [PATCHSET x86/master] add stack protector support for x86_32
Date: Mon, 9 Feb 2009 15:15:25 +0100 [thread overview]
Message-ID: <20090209141525.GA24897@elte.hu> (raw)
In-Reply-To: <73c1f2160902090609qeabc926nc5579f87c1ca5207@mail.gmail.com>
* Brian Gerst <brgerst@gmail.com> wrote:
> On Mon, Feb 9, 2009 at 8:39 AM, Tejun Heo <tj@kernel.org> wrote:
> >
> > Hello,
> >
> > This patchset adds stack protector support for x86_32. The basics are
> > the same with x86_64 but there are some noticeable differences.
> >
> > * x86_32 uses %fs for percpu base. %gs is unused by the kernel and
> > managed lazily. %gs is used for userland TLS and loading %gs with
> > different value on kernel entry is known to cost quite a bit on some
> > chips.
> >
> > Lazy %gs handling is made optional and disabled if stack protector
> > is enabled. To do this, entry for %gs is added to pt_regs. This
> > adds one "pushl $0" to SAVE_ALL in entry_32.S when lazy %gs is on.
> > However, no overhead is added to common exit path and error_code
> > entry path shed a few instructions. I don't think there will be
> > noticeable overhead but then again it does add an instruction to a
> > very hot path. Would this be okay?
> >
> > * x86_32 doesn't support direct access to shadow part of %gs and
> > there's no swapgs, so GDT entry should be built for stack canary.
> >
> > GDT entry 28 is used for this. The boot cpu one is setup from
> > head_32.S. Others while setting up percpu areas.
> >
> > * math_emu register access was completely broken. Fixed.
> >
> > * x86_32 exception handlers take register frame verbatim as struct
> > pt_regs. With -fstack-protector, gcc copies pt_regs into the
> > callee's stack frame to put it after the stack canary. Of course it
> > doesn't copy back (as the callee owns the argument) and any change
> > made to pt_regs is lost on return. This is currently worked around
> > by adding -fno-stack-protector to any file containing such
> > functions. We really need to teach gcc about the calling
> > convention.
>
> I had a patch a while back that would convert those function to take a
> pointer to pt_regs instead of assuming that the struct was passed by
> value. [...]
Yes, that's the right solution. Getting a new call convention recognized
is a 3 years timeframe project for a whole team of hackers. Adding a
pointer is a 30 minutes project for one good kernel hacker ;)
> [...] I'll take a stab at reworking it on top of this series.
Cool!
Ingo
next prev parent reply other threads:[~2009-02-09 14:17 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 ` [PATCH] stackprotector: fix multi-word cross-builds Ingo Molnar
2009-02-11 14:19 ` 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 [this message]
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=20090209141525.GA24897@elte.hu \
--to=mingo@elte.hu \
--cc=brgerst@gmail.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.