I am studying ASLR randomization of mmap(), on x86 system. I have read in a lot of places that there are 16bits of randomization on the address loaded with mmap().
But in the source code i have found:
static unsigned long mmap_rnd(void)
02 {
03 unsigned long rnd = 0;
04
05 /*
06 * 8 bits of randomness in 32bit mmaps, 20 address space bits
07 * 28 bits of randomness in 64bit mmaps, 40 address space bits
08 */
09 if (current->flags & PF_RANDOMIZE) {
10 if (mmap_is_ia32())
11 rnd = (long)get_random_int() % (1<<8);
12 else
13 rnd = (long)(get_random_int() % (1<<28));
14 }
15 return rnd << PAGE_SHIFT;
16 }
So, that would be only 8bits of randomness.
But in fact, running some test, i get the following address (stack-heap-mmap) bf937000,09a60000,b774b000
bfa86000,090ef000,b76e2000
Its more than 16 bits if it can be b77XX000 and b76XX000!!!!
Any help on this?