Lesson 1 of 14 · 10m
The Address Space: Reading /proc/self/maps
How execve maps an ELF into virtual memory — r-xp code, rw-p data, the stack — and why page-table permissions, not conventions, decide what you can run.
The address space is a fiction that happens to be convenient
Here is what happens when your program starts. The kernel's loader — execve() down through load_elf_binary() in fs/binfmt_elf.c — reads the ELF headers, mmap()s the loadable segments into a fresh virtual address space, maps the stack near the top, and hands the CPU a starting rip. Your process never touches physical RAM directly. Every address it will ever see is virtual, translated per-page by hardware page tables the kernel maintains.
You can watch the whole map without a debugger:
cat /proc/self/mapsYou'll get lines like:
555555554000-555555558000 r-xp 00001000 08:01 ... /bin/cat
7ffff7dd9000-7ffff7fae000 r-xp 00022000 08:01 ... /usr/lib/libc.so.6
7ffffffde000-7ffffffff000 rw-p 00000000 00:00 [stack]Three regions matter for everything that follows: the executable mapping (.text, r-xp — read/execute, not writable), the writable data (rw-p — .data, .bss, and every heap allocation malloc ever gives you), and the stack, growing downward from near 0x7ffffffff000 on x86-64. The r-xp/rw-p flags are not suggestions. They are page-table permission bits the CPU enforces on every access. When a lesson later says "NX stops you from executing the stack," this is the mechanism: the stack's pages are mapped rw-p, and the MMU refuses to fetch instructions from them.
The wrong mental model
The model you probably have is "memory is a flat array and C indexes into it." That fails the first time you meet two facts: the stack grows down while buffers fill up, and every region you can see is private to the process. Your 0x7fffffffe450 is not my 0x7fffffffe450; identical virtual addresses in two processes resolve to different physical pages. Pointer addresses are only meaningful inside one process's map — which is why leaking an address is half of every real exploit. The address tells you where a gadget lives this run. ASLR exists to make that answer change every run.
What's actually in the map
.text— your compiled code. Mappedr-xp.w^xmeans the loader can't write it after mapping withoutmprotect..data/.bss— globals..dataholds initialized values;.bssis zeroed-on-demand and costs no bytes in the file.- Heap — what
brk/sbrkgrows upward and what glibc's malloc carves into chunks. Large allocations skip the heap entirely:malloc(200 * 1024 * 1024)goes throughmmapand gets its own region. - Libraries — libc, ld.so, everything
dlopenpulls in, eachmmap'd asr-xpfor code plusrw-pfor its globals (including the GOT — remember that for RELRO). - Stack — per-thread,
rw-p, default 8 MB (ulimit -s). The kernel seeds it with argv, envp, and the ELF auxiliary vector. [vdso]/[vvar]— kernel-provided code pages mapped into your address space sogettimeofdaydoesn't need a syscall.
GDB will show you the same thing with better labels: info proc mappings inside a session, or gef vmmap if you run GEF. checksec reads PT_GNU_STACK and friends out of the ELF — the binary itself declares whether its stack may execute, and the loader honors the declaration. (pwninit is the other tool you'll meet in this lane, but it's a patchelf wrapper — it relinks the binary against the libc/ld you hand it; it doesn't inspect mitigations.)
Land on practice
Before you exploit anything, read the map. checksec --file=./target tells you which permissions and mitigations are compiled in. /proc/<pid>/maps on a running process tells you where ASLR put libc this run — attach GDB and the debugger disables ASLR by default, so maps under GDB will show you stable addresses that will not match the real world. That's the trap that eats beginners' first ret2libc: addresses captured under gdb are wrong outside it. Either set disable-randomization off, or leak addresses at runtime like every working exploit does.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
A Password-Free Path to Root: Inside the macOS Screen Sharing Vulnerability Now Under Attack
A logic bug in screensharingd let attackers skip authentication entirely and land as root — no password required. Here's how it was found, patched, reverse-engineered, and finally weaponized.
BlueHammer: The Unpatched Windows Zero-Day That Weaponizes Microsoft Defender Against Your Own System
BlueHammer is an unpatched, publicly released Windows local privilege escalation exploit that chains Microsoft Defender's update workflow, Volume Shadow Copy, Cloud Files callbacks, and opportunistic locks to reach NT AUTHORITY\SYSTEM from a standard user account.
What is Privilege Escalation? How Attackers Go From Foothold to Full Control
An attacker starts with a low-privileged shell or user account and escalates to root or Administrator using misconfigurations, SUID binaries, kernel exploits, and Active Directory attacks. Here's every technique, the tools professionals use, and how to harden against it.
Jellyfin's Threat Model Is Your Brother-in-Law
Four Jellyfin CVEs landed in 2026 and not one of them needs an admin account. One needs only the ability to name a file. Meanwhile Jellyfin 12 shipped in September, the version numbers stopped starting with 10, and every "am I patched" check you wrote is now wrong.