WCU / Cybersecurity
~/CSC 472/Class 10/KP 07
Class 10 · KP 07 / 20

Kernel Use-After-Free: The Classic Pattern

allocated chunksizeheaderuser datafreed chunk (tcache)sizeheaderfd → next freereused by UAFUse-after-free: the pointer still works after free — read, or overwrite fd.
glibc heap: a dangling pointer to a freed chunk becomes a read/write primitive.

A "babydev"-style vulnerable char driver (the shape of Lab 7):

  • The driver keeps a single global pointer to one heap object, but lets the device be opened twice, sharing that object across two file descriptors.
  • close (or a release handler) kfrees the object but does not clear the pointer — a dangling reference survives on the second fd.
  • The attacker frees via fd#1, then reuses via fd#2, reading or writing through the stale pointer.
  • In the gap, they spray a controllable object of the same size so it lands on top of the freed slot — overlapping attacker data with a security-critical struct.
Key Takeaway

Two references + one free + no null-out = a dangling pointer the attacker can aim at a chosen replacement object.