Search code examples
stackemulation32bit-64bitmmapvirtual-address-space

why stack, heap's virtual address are changed at each time?


when i run program 'A', heap and stack's virtual addresses are changed although i run the same program 'A'.

i know that stack, heap's virtual addresses are not defined in the executable object file(elf format). They are variable things. i can check it out by 'readelf -l' command.

but, Why does kernal have to change the address of the stack every time although same program is runned? here is reason why i asked like that.

I am making a simple process emulator. I'm trying to emulate a progam from raspbian(32bit) in the intel cpu environment(64bit).

So, I have to design 32 bit stack. but i don't know how i emulate stack system.

I mmaped ANONYMOUS page, then i have to use it as a stack to emulate a program. i have to imitate the way the program(32bit) use stack. But program's stack virtual address change at every single running time. I need a help.


Solution

  • It can be that operational system makes address space randomization in stack, heap to avoid security vulnerabilities. If a attacker knows always were to find this information for processes, it could be easier to harm the system.