Skip to content
Memory corruption Write-up Advanced

UNCONTAINED: Uncovering Container Confusion in the Linux Kernel

The Linux kernel uses the container_of() macro to downcast embedded structures, but without runtime type checking, incorrect downcasts cause out-of-bounds pointers. An attacker could exploit these container confusion bugs to corrupt memory or escalate privileges.

Jakob Koschel Follow

Published on vusec.net

We present uncontained, a framework to detect type confusion bugs originating from incorrect downcasting operations in non-object-oriented languages, which we call container confusion. In languages like C, object-oriented programming features are often mimicked by embedding structures as fields of other structures and…

Jakob Koschel, Pietro Borrello, Daniele Cono D'Elia, Herbert Bos, Cristiano Giuffrida, on vusec.net

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the absence of runtime type checking when using container_of() to downcast, allowing pointers to be misinterpreted as pointing to a different struct type.

What the attacker needed

Access to kernel code execution

The fix

The bugs were fixed by submitting 149 patches, with 102 merged so far.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

In C, programmers often embed one struct inside another to mimic inheritance. The container_of() macro calculates the address of the outer struct from a pointer to an inner field, but if the pointer does not actually point to that inner field, the result is an invalid pointer. This can lead to memory corruption, which an attacker might use to take control of the system.

What is Memory corruption?

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.

More from Linux Kernel Organization

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.