ASLR bits of Entropy of mmap()

泪湿孤枕 提交于 2019-12-08 03:32:53

问题


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?


回答1:


PAGE_SHIFT is shifting that randomness to a different bit position. The difference between your mmap addresses is indeed:

 b774b000
-b76e2000
---------
    69000

I don't know what the value of PAGE_SHIFT is, but if it's 12 for example, then you have 0x69 difference which perfectly fits in 8-bits.



来源:https://stackoverflow.com/questions/13826479/aslr-bits-of-entropy-of-mmap

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!