DEV Community

Hyunseung Ha
Hyunseung Ha

Posted on

1

[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.

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

đź‘‹ Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay