From: Al Boldi <a1426z@gawab.com>
To: Chuck Ebbert <76306.1226@compuserve.com>
Cc: Paulo Marques <pmarques@grupopie.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
Arjan van de Ven <arjan@infradead.org>,
Frank van Maarseveen <frankvm@frankvm.com>
Subject: Re: [PATCH] x86: Don't randomize stack unless current->personality permits it
Date: Tue, 25 Jul 2006 07:57:04 +0300 [thread overview]
Message-ID: <200607250757.04664.a1426z@gawab.com> (raw)
In-Reply-To: <200607242023_MC3-1-C5FE-CADA@compuserve.com>
Chuck Ebbert wrote:
> On Mon, 24 Jul 2006 18:57:46 +0300, Al Boldi wrote:
> > > With your changes on:
> > >
> > > stock kernel, randomize_va_space=0, gcc.322 -Os tstExec.c,
> > > while :; do ./a.out; done
> > > &x = 0xbffff874, &y = 0xbffff86c 28 28
> > > &x = 0xbffff874, &y = 0xbffff86c 27 27
> > > &x = 0xbffff874, &y = 0xbffff86c 27 27
> > > &x = 0xbffff874, &y = 0xbffff86c 28 27
> > > &x = 0xbffff874, &y = 0xbffff86c 27 30
> > > &x = 0xbffff874, &y = 0xbffff86c 27 29
> > >
> > > stock kernel, randomize_va_space=1, gcc.322 -Os tstExec.c,
> > > while :; do ./a.out; done
> > > &x = 0xbfe2e614, &y = 0xbfe2e60c 29 28
> > > &x = 0xbfd6a104, &y = 0xbfd6a0fc 55 56
> > > &x = 0xbf91d454, &y = 0xbf91d44c 27 27
> > > &x = 0xbf941e84, &y = 0xbf941e7c 55 56
> > > &x = 0xbfa75834, &y = 0xbfa7582c 28 27
> > > &x = 0xbfb58634, &y = 0xbfb5862c 27 30
> >
> > After closer inspection, it looks like addresses ending with 3c,7c,bc,fc
> > cause a slowdown on P4, while addresses ending with
> > 1c,3c,5c,7c,9c,bc,dc,fc cause a slowdown on P2.
>
> Those addresses cause 'y' to span a cacheline (P4 = 64 bytes, P2 = 32.)
> Even when the kernel aligns to 128 bytes this could happen depending
> on how deeply you nest functions.
>
> > Any easy way to instruct the kernel to skip those addresses?
>
> First, I think you need to define locals in order of decreasing size.
> IOW 'x' and 'y' need to be first inside fn(), but that may not work
> when things get inlined. So using the '-malign-double' GCC option,
> or forcing alignment with '__attribute__ ((aligned(8)))' for each variable
> might be better.
>
> Then you have to make sure the stack is aligned. See
> '-mpreferred-stack-boundary'.
This would imply a recompile, what about precompiled dists? Do they compile
the sources this way?
> I still think the kernel should be aligning the stack to 128 bytes anyway.
I think so too, but can you see how randomization aggravates the situation?
Thanks!
--
Al
next prev parent reply other threads:[~2006-07-25 4:55 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-25 0:21 [PATCH] x86: Don't randomize stack unless current->personality permits it Chuck Ebbert
2006-07-25 4:57 ` Al Boldi [this message]
-- strict thread matches above, loose matches on Subject: below --
2006-07-19 17:02 Chuck Ebbert
2006-07-20 17:23 ` Al Boldi
2006-07-24 15:57 ` Al Boldi
2006-07-16 3:58 Chuck Ebbert
2006-07-16 19:49 ` Al Boldi
2006-07-11 19:57 Al Boldi
2006-07-12 16:03 ` Andi Kleen
2006-07-12 20:12 ` Al Boldi
2006-07-12 20:27 ` Arjan van de Ven
2006-07-12 21:13 ` Al Boldi
2006-07-13 9:44 ` Frank van Maarseveen
2006-07-13 20:51 ` Al Boldi
2006-07-13 20:54 ` Arjan van de Ven
2006-07-15 11:29 ` Al Boldi
2006-07-15 12:22 ` Arjan van de Ven
2006-07-15 14:09 ` Al Boldi
2006-07-15 16:15 ` Arjan van de Ven
2006-07-15 17:39 ` Al Boldi
2006-07-17 15:50 ` Paulo Marques
2006-07-18 5:21 ` Al Boldi
2006-07-11 15:22 Frank van Maarseveen
2006-07-11 20:11 ` Arjan van de Ven
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=200607250757.04664.a1426z@gawab.com \
--to=a1426z@gawab.com \
--cc=76306.1226@compuserve.com \
--cc=arjan@infradead.org \
--cc=frankvm@frankvm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=pmarques@grupopie.com \
/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;
as well as URLs for NNTP newsgroup(s).