Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why do `sbrk`, `mmap` etc. return very long addresses?

When I mmap a block of memory, the returned pointer might be something like 2607194112 or 3614339072 (both actual values I’ve gotten).

Why are these values seemingly so random? It’s all virtual anyway, so why not just give me address 4096 to start us off?

I suppose this question extends also to something like malloc, but that will use one of these under the hood anyways.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Like @erik258 mentioned, it’s because of Address space layout randomization (ASLR). Without that feature, it would be pretty easier for attackers to predict addresses of your code and libc functions and execute return-to-libc attacks. It implemented under the kernel – so far all this functions get such random values (malloc, mmap, etc).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading