Re: [PATCH] 126.96.36.199 Parameter-controlled mmap/stack randomization
From: John Richard Moser
Date: Fri May 19 2006 - 23:41:30 EST
-----BEGIN PGP SIGNED MESSAGE-----
Oh, some of my stuff is 4096 hard-coded instead of PAGE_SIZE. I fixed
this in mmap() randomization here, but there's iffiness coming up for
The stack is page aligned and randomized in the VMA; then randomized to
16 byte intervals. This is fine, PAGE_SIZE is 4096, our intervals are
16, 256 positions, we randomize 2^(stack_random_bits - 8) VMA and 2^8
inside; unless we have less than 8 bits, then we randomize
2^stack_random_bits and align to PAGE_SIZE / (2^stack_random_bits).
Easy enough. Now what if PAGE_SIZE isn't 4096?
That's an easy problem too. This can easily be calculated straight
forward with the number ... 8. In fact that's how I did it. 2^8 is
4096 / 16. Thus, the solution is log_base_2(PAGE_SIZE/16) instead of 8!
Now. How do I find the base 2 log of a number in the kernel?
John Richard Moser wrote:
> Any comments on this one?
> I'm trying to control the stack and heap randomization via command-line
> parameters. I wrote this in a 2.6.15 Ubuntu Dapper kernel and then
> patched it into a 188.8.131.52 tree and cleaned it up. It does a few
> simple things:
All content of all messages exchanged herein are left in the
Public Domain, unless otherwise explicitly stated.
Creative brains are a valuable, limited resource. They shouldn't be
wasted on re-inventing the wheel when there are so many fascinating
new problems waiting out there.
-- Eric Steven Raymond
We will enslave their women, eat their children and rape their
-- Bosc, Evil alien overlord from the fifth dimension
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v184.108.40.206 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
-----END PGP SIGNATURE-----
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/