0

In an answer to How do ASLR and DEP work? Polynomial says:

In a non-ASLR and non-DEP process, the stack address is the same every time we run the process. We know exactly where it is in memory.

I don't understand how that could be. Isn't RAM allocated dynamically at run time? What about when the program (X) exits and another process comes along (Y)? Could'nt the OS give (Y) that RAM at the same location?

closed as off-topic by Steffen Ullrich, schroeder May 13 '17 at 7:21

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not appear to be about Information security within the scope defined in the help center." – Steffen Ullrich, schroeder
If this question can be reworded to fit the rules in the help center, please edit the question.

  • This is actually not a question about security but how computers and modern OS work. And it is also not about ASLR because you ask about the case where ASLR is not done. I think if you read about the concept virtual memory you understand why all processes can have the same memory layout from the view of the process. Apart from that, please give proper credit when citing somebody instead of doing a verbatim quoting but giving the source as "I've heard". – Steffen Ullrich May 13 '17 at 5:51
  • Thanks for the comments and links Steffen!! Outstanding resource as usual!!! – james6125 May 13 '17 at 14:25
1

Addresses that you are seeing through your debugging tool are logical memory addresses. Every time a program is spawned, the CPU allocates certain bytes of memory to the program. On the hardware, this may be allocated in one single chunk or it may be strewn over in parts all over the place. However, to make it simpler for the program to refer to memory locations, the CPU maps these hardware or physical memory address to logical address.

A program interacting within this address space does not see other programs. Only the CPU knows which physical address to fetch when the program refers to some logical memory address within the code.

So, two different programs can refer to the same logical memory location, say 0x7c900000. But the CPU knows where to point this instruction to on the physical RAM. This makes life simpler for the programmer when memory management is taken care of by the CPU.

About ASLR (Adress Space Layout Randomization):

ASLR was introduced because it was fairly easy to reach the exact point in memory during program execution to find buffer overflow vulnerable variables. This made writing exploits easy. ASLR randomized the placement of variables making it difficult for hackers to exploit buffer overflow vulnerabilities.

So without ASLR, the variables in your program and instructions are going to be loaded in the exact same (logical) locations every time you execute it.

Not the answer you're looking for? Browse other questions tagged or ask your own question.