DEV Community

Hyunseung Ha
Hyunseung Ha

Posted on

[PWN.01] Memory Layout

Memory Layout Image

What is Memory Layout

If an attacker can maliciously manipulate memory, the manipulated memory value can cause the CPU to misbehave.
We call it Memory Corruption
Memory in Linux System is divided into 5 major Segments.

1. Code segment(Text Segment)

where Executable machine code is located in.
Code segment has READ and EXECUTE permission.

2. Data segment

Global variables and global constants whose values ​​are set at compile time are located.
Data segment has READ permissions.
And This segment is divided into Two parts.

  • data segment : writable
  • rodata(read-only Data) segment : No writable

3. BSS segment (Block Started by Symbol)

Global variables whose values ​​are not set at compile time are located.
The variables are set to Zero all

4. Heap segment(Lower β†’ High)

Segment to store dynamically allocated data.
This segment has READ and WRITE permissions.

5. Stack segment(High β†’ Lower)

Temporary variables such as function arguments or Local variables are stored here during execution.
Stack segment has READ and WRITE permissions.
This segment has Stack Frame which is created when a function is called and freed when the function returns.

Top comments (0)