Races: Double Fetch, userfaultfd and FUSE


Kernel Exploitation: A CTF Study Path.

Kernel code that reads user memory twice, or forgets to lock, has a race window. Usually that window is nanoseconds wide; the trick is to make it as long as you like by making the kernel fault on a user page you control (userfaultfd, or FUSE where unprivileged userfaultfd is disabled).

What you will learn

  • Double fetch / TOCTOU bugs and brute-force racing with threads and CPU pinning
  • userfaultfd: registering a region, stalling copy_from_user/copy_to_user, swapping objects mid-copy
  • FUSE and other ways to stall the kernel when userfaultfd is unavailable
  • Turning a race into a UAF or double free, then reusing modules 04-07
  • Races inside core kernel code (fault handling) rather than drivers

Prerequisites

Modules 04-07.

References



Challenges

KITCTFCTF 2022 · difficulty ★★☆☆☆ · module: Races: Double Fetch, userfaultfd and FUSE

A syscall that reads your data more than once; change it between the reads.

Mitigations: SMEP, 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.

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): README.md, bzImage, initramfs.cpio.gz, launch.sh.

Original challenge

Description

After a night of bad luck at the casino you got wasted again. After waking up in a cell, not remebering what happened, the cops tell you that you picked a fight with some guy and beat him up badly. It does not look like you're getting out soon. You need another way out of this situation...

Points

499

Solves

7

Credits

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

PatriotCTF 2024 · difficulty ★★★☆☆ · module: Races: Double Fetch, userfaultfd and FUSE

The driver reads your length twice; make sure it gets two different answers.

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

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, start.sh, vuln.c, vuln.ko.

Original challenge

Description

My kernel is your kernel. Well, some of it. Here's ioctl.

Note: Only one connection per user. Compile off the box.

Points

484

Solves

9

Credits

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

TSG CTF 2021 · difficulty ★★★☆☆ · module: Races: Double Fetch, userfaultfd and FUSE

A tiny in-kernel git; duplicate hashes and a well-timed page fault lead to a use-after-free.

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. At boot the flag is moved to /home/user/flag (root only).

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, src/client/client.c, src/include/lkgit.h, src/kernel/lkgit.c.

Original challenge

Description

もしも羊がウィスキーであったなら。

flagは/home/user/flagです。

Points

322

Solves

7

Credits

  • Challenge author(s): @smallkirby, for TSG CTF 2021
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

3kCTF-2021 · difficulty ★★★☆☆ · module: Races: Double Fetch, userfaultfd and FUSE

A book library driver without proper locking; stall it mid-copy and swap what lies underneath.

Mitigations: SMEP, SMAP, KPTI, 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. The handout's 120 MB vmlinux is too big for the dojo repo; extract one from bzImage (e.g. extract-vmlinux) if you want symbols.

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, src/library.c, start.sh.

Original challenge

Description

Store your books safely inside the kernel!

Points

495

Solves

2

Credits

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

DiceCTF 2021 · difficulty ★★★☆☆ · module: Races: Double Fetch, userfaultfd and FUSE

A hash map that resizes itself; race the resize to get a use-after-free and aim it at a pipe.

Mitigations: SMEP, SMAP, KPTI, KASLR

Also uses techniques from: pipe_buffer, Dirty Pipe and Page Cache Overwrites (07-pipe-buffer).

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, hashbrown_distributed.c, initramfs.cpio, run.sh.

Original challenge

Description

Who doesn't like hashbrowns? I like them so much that I wrote a driver named after them! But apparently programming is hard and I might have made a mistake...

Please note that the following measures are active (whether they are important to the exploit process is up to you):

CONFIG_SLAB_FREELIST_RANDOM=y
CONFIG_SLAB=y
CONFIG_FG_KASLR=y
SMAP, SMEP, and KPTI are enabled as well.

Note: only one connection per IP is allowed, and there is a 10 minute wall-clock time limit from the moment you connect. Test locally!

Points

396

Solves

7

Credits

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

SUSCTF 2022 · difficulty ★★★☆☆ · module: Races: Double Fetch, userfaultfd and FUSE

A kernel queue module comes back with its old bug half-fixed; stall the kernel at the right moment to exploit what's left.

Mitigations: SMEP, SMAP, KASLR, KPTI (kernel default; depends on the host CPU), 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 VM powers off 120 seconds after boot, as in the original.

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): boot.sh, bzImage, kqueue.ko, rootfs.cpio.

Original challenge

Description

Sorry about the uploaded attachment,to be fair, attachments will not be fixed
You can continue to try to find a normal solution to the challenge

Sorry about all of mistakes

Points

526

Solves

19

Credits

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

SCTF 2024 · difficulty ★★★☆☆ · module: Races: Double Fetch, userfaultfd and FUSE

A revenge with no puts; freeze the kernel mid-copy and recycle what it freed.

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

Also uses techniques from: Elastic Objects: msg_msg (06-msg-msg).

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): boot.sh, bzImage, rootfs.cpio.

Original challenge

Description

描述:revenge
1.95.58.26:3333

Points

512

Solves

20

Credits

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

BackdoorCTF 2023 · difficulty ★★★☆☆ · module: Races: Double Fetch, userfaultfd and FUSE

An employee database driver with no locking; learn to stretch a race window until it is wide enough to win.

Mitigations: SMEP, KASLR, KPTI, no SMAP

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): EmpDB.ko, bzImage, initramfs.cpio, run.sh.

Original challenge

Description

Points

492

Solves

15

Credits

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

Securinets CTF Quals 2022 · difficulty ★★★★☆ · module: Races: Double Fetch, userfaultfd and FUSE

A blob-storage device has a race on open; widen it with userfaultfd, reclaim the freed object with msg_msg and turn the result into a privileged write.

Mitigations: SMEP, SMAP, KPTI, KASLR, oops=panic, ext rootfs on /dev/vda

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 an ext2 disk, so there is no initramfs to add files to: transfer your exploit over the console (for example base64). The flag is /root/flag.txt; 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.ext2, start-qemu.sh, xblob.c.

Original challenge

Description

eXclusive BLOB

* If you make many connections in a short period of time, you will lose connection for several minutes.

Points

1000

Solves

4

Credits

  • Challenge author(s): ptr-yudai, for Securinets CTF Quals 2022
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

SECCON 2020 Online CTF · difficulty ★★★★☆ · module: Races: Double Fetch, userfaultfd and FUSE

A per-process stack driver with a race window; widen it on purpose and turn it into a double free.

Mitigations: SMEP, 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. Booting takes about 15 seconds (the init waits for a network that is not there).

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, src/kstack.c, src/kstack.h, start.sh.

Original challenge

Description

Stack is one of the most fundamental data structure.

Points

393

Solves

4

Credits

  • Challenge author(s): ptr-yudai, for SECCON 2020 Online CTF
  • Compiled by: mito753 in Kernel-Exploit-Dojo, which also has the original handout and writeups

InCTF 2021 · difficulty ★★★★☆ · module: Races: Double Fetch, userfaultfd and FUSE

A storage driver that checks a size and later trusts it; race the check into a heap overflow and groom the heap.

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

Also uses techniques from: Elastic Objects: msg_msg (06-msg-msg).

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, src/MultiStorage.c, src/MultiStorage.h, start.sh.

Original challenge

Description

You can now store two types of data in kernel.

Hint

Functions that may look irrelevant might have bigger affect than you think!

Points

1000

Solves

1

Credits

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

KalmarCTF 2025 · difficulty ★★★★☆ · module: Races: Double Fetch, userfaultfd and FUSE

No memory corruption: the system's crash-dump handler trusts a path it should not. Think about timing.

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, initramfs.cpio.gz, run.sh.

Original challenge

Description

Always getting segfaults in my production code. Good thing we have coredumps, so I can log it :)

Points

427

Solves

10

Credits

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

TRX CTF 2026 · difficulty ★★★★☆ · module: Races: Double Fetch, userfaultfd and FUSE

A driver defers a user pointer to a kernel worker; ask whose address space that worker is really in.

Mitigations: SMEP, SMAP, KPTI, KASLR, FSGSBASE

Also uses techniques from: Bit Flips, Page Tables and x86 Privilege Machinery (11-x86-machinery).

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/sda (root only).

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, pwn.c, run.sh.

Original challenge

Description

The solution to all your problems is right here -> https://kqx.io

Points

282

Solves

15

Credits

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

KalmarCTF 2026 · difficulty ★★★★★ · module: Races: Double Fetch, userfaultfd and FUSE

Some lines were removed from the kernel's fault handling to make it faster; find out what they were protecting.

Mitigations: SMEP, SMAP, no KPTI (nopti), SMP 2, KVM

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, chall.diff, initramfs.cpio.gz, run.sh.

Original challenge

Description

I removed some redundant lines from the linux kernel so my faults run faster!

Points

817

Solves

2

Credits

  • Challenge author(s): not recorded (credit goes to the KalmarCTF 2026 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