Re: [PATCH] x86: Don't randomize stack unless current->personality permits it

From: Chuck Ebbert
Date: Wed Jul 19 2006 - 13:05:04 EST


In-Reply-To: <200607180821.45346.a1426z@xxxxxxxxx>

On Tue, 18 Jul 2006 08:21:45 +0300. Al Boldi wrote:

> Going one step further,
> with #define arch_stack_align(x) (x)
> all blips/hits/weirdness are gone
>
> Which means that either arch_stack_align isn't necessary at all, or
> randomization isn't working as intended.
>
> Can somebody prove me wrong here?

Your program seems highly sensitive to any changes, e.g. with the
following code, results with and without the commented lines are
different. (I changed i to 5555555 because my cpu is slower than
yours and changed main() to call it 10 times.) This on an AMD
Turion64 1.6GHz running an i386 kernel with stock arch_stack_align()
and randomize_va_space == 1.

void fn()
{
double x = 0.0, y = 0.0;
long i = 5555555;
// static int printed = 0;
//
// if (!printed) {
// printed++;
// printf("&x = %p, &y = %p\n", &x, &y);
// }

elapsed(1);
while (i--)
fn2(&x,&y);
printf("%4lu ", elapsed(0));
}

$ ./tst.ex
&x = 0xbfb32d90, &y = 0xbfb32d98
10 6 10 10 6 10 7 10 10 10 10 10 10 10 10 10 10 10 10 10 msec
$ ./tst.ex
7 10 6 6 6 6 10 10 6 6 6 10 10 6 6 6 6 10 6 6 msec

BTW when compiled with gcc 4.1.1 using -O3 it just prints all zeros,
so I had to use 3.3.3.
--
Chuck
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/