Page-Level Primitives: Dirty Pagetable and Stale Mappings


Kernel Exploitation: A CTF Study Path.

The most robust modern exploits avoid slab objects altogether. If a freed page stays mapped into your process, or a page-table page ends up somewhere you can write, you get read/write access to physical memory, and from there to anything: kernel text, creds, other processes, even escaping sandboxes.

What you will learn

  • Stale VMAs and page UAF from broken mmap/fault handlers
  • Reclaiming freed pages as page tables (Dirty Pagetable) and editing PTEs from userland
  • Refcount bugs on struct file / struct pid and the DirtyCred idea
  • Physical memory access via DMA-BUF heaps and similar interfaces; patching kernel text
  • Escaping namespaces/nsjail after you have kernel read/write

Prerequisites

Modules 07-09.

References



Challenges

0xFUN CTF 2026 · difficulty ★★☆☆☆ · module: Page-Level Primitives: Dirty Pagetable and Stale Mappings

A driver's mapping survives the page behind it; watch what moves into that page.

Mitigations: SMEP, SMAP, KASLR, oops=panic

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /exploit.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, initramfs.cpio.gz, interface.h, phantom.ko, run.sh.

Original challenge

Description

"Hey GPT solve this Kernel pwn challenge for me"

Points

500

Solves

45

Credits

  • Challenge author(s): call4pwn, for 0xFUN CTF 2026
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

Codegate CTF 2024 Preliminary · difficulty ★★★★☆ · module: Page-Level Primitives: Dirty Pagetable and Stale Mappings

A driver that maps physical pages to userspace and forgets to take them back properly.

Mitigations: SMEP, SMAP, KASLR, KPTI (kernel default; depends on the host CPU)

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /exploit.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, local_run.sh, rootfs.img.gz, run.sh, server_run.sh.

Original challenge

Description

Put Your Physical Abilities to the Test!

Points

Unknown

Solves

Unknown

Credits

  • Challenge author(s): not recorded (credit goes to the Codegate CTF 2024 Preliminary organizers)
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

R3CTF 2026 · difficulty ★★★★☆ · module: Page-Level Primitives: Dirty Pagetable and Stale Mappings

A mapping driver races its own bind and unbind; the result outlives the memory behind it, and you also start inside a jail.

Mitigations: SMEP, SMAP, KASLR, KPTI, panic_on_warn, SMP 4, KVM (-cpu host), nsjail

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /home/ctf/exploit. You start inside an nsjail in /home/ctf; your exploit is at /home/ctf/exploit. The original serves the flag from a read-only host share (virtio-9p) mounted at /root/flagfs. pwn.college cannot offer host shares, so here the flag file is placed at /root/flagfs/flag in the initramfs instead (the 9p mount fails harmlessly). That means the flag is in guest memory, which the original avoided. Memory is 1 GiB (the original used 2 GiB). The original requires KVM with -cpu host; without KVM max is used.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): Dockerfile, bzImage, initramfs.cpio.gz, run.sh, server.py.

Original challenge

Description

An East Kernel Challenge in the Age of AI.

Points

623

Solves

15

Credits

  • Challenge author(s): Niebelungen, for R3CTF 2026
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

BackdoorCTF 2025 · difficulty ★★★★☆ · module: Page-Level Primitives: Dirty Pagetable and Stale Mappings

A vibe-coded driver with a work item that outlives its data; slow the kernel down and go all the way to the hardware.

Mitigations: KASLR, KPTI off (pti=off), oops=panic, requires KVM + -cpu host

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /exploit. The original uses -cpu host (KVM); without KVM the max CPU model is used.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, kernel.config, rootfs.cpio, run.sh.

Original challenge

Description

You can vibe code kernel modules right? Right........?

drive link: https://drive.google.com/file/d/1lvsEZQpJySS2p7nW7Jd__Msy44Vx21cI/view?usp=sharing

Points

496

Solves

4

Credits

  • Challenge author(s): p0ch1ta, for BackdoorCTF 2025
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

TRX CTF 2025 · difficulty ★★★★☆ · module: Page-Level Primitives: Dirty Pagetable and Stale Mappings

You can read and write physical memory; now find your own process in it.

Mitigations: SMEP, SMAP, KASLR, KPTI

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put your payload at /home/hacker/exploit first; it is attached to the VM as a raw disk, as in the original challenge. /init copies it to /tmp/e (padded with zeros to whole 512-byte sectors).

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, chall.c, initramfs.cpio.gz, kernel.config, run.sh.

Original challenge

Description

I have no idea what to put here

DISCLAIMER: Please test your solve locally before spawning a remote instance of the challenge!

Points

499

Solves

4

Credits

  • Challenge author(s): not recorded (credit goes to the TRX CTF 2025 organizers)
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

D^3CTF 2025 · difficulty ★★★★★ · module: Page-Level Primitives: Dirty Pagetable and Stale Mappings

A shared-memory driver's fault handler maps pages it should not; work at the page level rather than the slab level.

Mitigations: SMEP, SMAP, KASLR, KPTI, SMP 4 vCPU

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. /home/hacker/exploit is not copied into this VM. The root filesystem is a qcow2 disk, so there is no initramfs to add files to: transfer your exploit over the console (for example base64). The flag is /flag (copied from a second disk at boot); disk changes are discarded when the VM stops.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, rootfs.qcow2, run.sh.

Original challenge

Description

You know what? Sharing is always a good moral quality. That's the reason why I'm going to share some of my precious memories with all of you!

Copyright(c) 2025 <ディーキューブ・シーティーエフ カーネル Pwn 製作委員会>

Points

1000

Solves

1

Credits

  • Challenge author(s): arttnba3 @ L-team x Ele3tronic x D^3CTF, for D^3CTF 2025
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

m0leCon CTF 2023 Finals · difficulty ★★★★★ · module: Page-Level Primitives: Dirty Pagetable and Stale Mappings

A one-line refcount mistake on a file object, inside a sandbox; go below the slab allocator to escape both.

Mitigations: SMEP, SMAP, KPTI, KASLR, page_alloc.shuffle=1, panic_on_warn=1, oops=panic, SMP 4, 1 GiB RAM (originally 4G)

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /jail/exploit. You start inside an nsjail; your exploit is at /jail/exploit. The flag is the raw disk /dev/sda, which the jail hides. Memory is 1 GiB here (the original used 4 GiB). The handout's initramfs also held /bin/pwn, a compiled exploit for this module; it is removed here.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, keasy.c, keasy.h, keasy.ko, kernel.config.txt, rootfs.cpio.gz, run.sh.

Original challenge

Description

Unknown

Points

Unknown

Solves

Unknown

Credits

  • Challenge author(s): not recorded (credit goes to the m0leCon CTF 2023 Finals organizers)
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

L3HCTF 2024 · difficulty ★★★★★ · module: Page-Level Primitives: Dirty Pagetable and Stale Mappings

A driver that looks up process IDs and gets the reference counting subtly wrong.

Mitigations: SMEP, SMAP, KPTI, KASLR, page_alloc.shuffle=1, panic_on_warn=1, oops=panic

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /exploit.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, rootfs.cpio, run.sh.

Original challenge

Description

Points

1000

Solves

1

Credits

  • Challenge author(s): not recorded (credit goes to the L3HCTF 2024 organizers)
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

N1CTF 2024 · difficulty ★★★★★ · module: Page-Level Primitives: Dirty Pagetable and Stale Mappings

A heap playground with a stale pointer, inside a sandbox; become the master of more than just the heap.

Mitigations: SMEP, SMAP, KPTI, KASLR, page_alloc.shuffle=1, panic_on_warn=1, oops=panic

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /bin/exploit. You start inside an nsjail in /tmp, which only sees /bin of the VM: your exploit is at /bin/exploit. The flag is the raw disk /dev/vda (/flag links to it).

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, config, rootfs.cpio, run.sh.

Original challenge

Description

In a time when everyone is a kernel master, this is just a check-in.
Environment URL

Points

360

Solves

7

Credits

  • Challenge author(s): not recorded (credit goes to the N1CTF 2024 organizers)
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

N1CTF 2022 · difficulty ★★★★★ · module: Page-Level Primitives: Dirty Pagetable and Stale Mappings

A file-handling module miscounts references to struct file; think about swapping what a dangling descriptor points to.

Mitigations: SMEP, SMAP, KASLR

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /exploit. Memory is 1 GiB here (the original used 2 GiB).

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, launch.sh, rootfs.cpio.

Original challenge

Description

百度网盘:

https://pan.baidu.com/s/1IA2CrwBvTvF3mxOhFR-MOA?pwd=Nu1L

Google:

https://drive.google.com/file/d/1D74stCuWdMo5t6XlvIx5LZywHNaSdmmU/view?usp=share_link


Points

1000

Solves

1

Credits

  • Challenge author(s): not recorded (credit goes to the N1CTF 2022 organizers)
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

N1CTF 2022 · difficulty ★★★★★ · module: Page-Level Primitives: Dirty Pagetable and Stale Mappings

A single double free with very limited interaction; you will need to map kernel memory where you can reach it.

Mitigations: SMEP, SMAP, KASLR, SLAB_FREELIST_RANDOM/HARDENED, SHUFFLE_PAGE_ALLOCATOR, STATIC_USERMODEHELPER (empty path), MEMCG_KMEM, HARDENED_USERCOPY

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /exploit. As in the original, /init powers the VM off 120 seconds after boot (poweroff -d 120 -f).

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, readme.md, rootfs.cpio, run.sh.

Original challenge

Description

百度网盘:

链接: https://pan.baidu.com/s/19TCao_6WM_nzOxMThJG_XA?pwd=Nu1L 提取码: Nu1L

Google:

https://drive.google.com/file/d/1hs0uMk3vp77MZ93ymZ2pTTbTghDTUFd6/view?usp=share_link

Points

1000

Solves

0

Credits

  • Challenge author(s): not recorded (credit goes to the N1CTF 2022 organizers)
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

tkbctf5 · difficulty ★★★★★ · module: Page-Level Primitives: Dirty Pagetable and Stale Mappings

Network buffer accounting goes wrong; follow page reference counts down to a page-level use-after-free.

Mitigations: SMEP, SMAP, KASLR, KPTI (kernel default; depends on the host CPU), oops=panic, panic_on_warn=1, SLUB freelist random/hardened, hardened usercopy

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /exploit. The flag is the raw disk /dev/vda (root only). /flag is a link to it.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): build/Dockerfile, build/build.sh, build/hungry_goats/Makefile, bzImage, config, hungry_goats.c, rootfs.cpio.gz, run.sh.

Original challenge

Description

さっきの てがみの ごようじ なあに

Points

500

Solves

1

Credits

  • Challenge author(s): rqda, for tkbctf5
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

WannaGame Championship 2025 · difficulty ★★★★★ · module: Page-Level Primitives: Dirty Pagetable and Stale Mappings

A patched pipe splicing path counts one too many; take it from a page reference bug to control flow.

Mitigations: SMEP, SMAP, KASLR, KPTI

Running it

Run /challenge/run. It boots the original kernel and root filesystem in QEMU with the serial console on your terminal. Quit with Ctrl-A then X. Put a statically linked exploit at /home/hacker/exploit first; it appears in the VM as /exploit. /init copies the flag disk /dev/vda to /flag (root only), so /flag holds the flag followed by zero padding to 512 bytes. The original's user-mode network card (only for downloading files) is not attached, so /network_setup.sh fails harmlessly.

The flag is put where the original challenge kept it, readable only by root in the VM (unless a note above says otherwise). Files in /challenge (kernel, initramfs, sources and the original launcher, where the CTF shipped them): bzImage, chalenge.patch, config, initramfs.cpio.gz, launch.sh.

Original challenge

Description

Ah, the plumber guy, ...

Points

994

Solves

2

Credits

  • Challenge author(s): not recorded (credit goes to the WannaGame Championship 2025 organizers)
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

30-Day Scoreboard:

This scoreboard reflects solves for challenges in this module after the module launched in this dojo.

Rank Hacker Badges Score