freenode
Kernel & Low-Level

Linux ipset bug lets unprivileged users escalate to root

A double-free during set resize was missed by an earlier garbage-collection fix and has been turned into a local privilege escalation.

A longstanding hole in the Linux kernel's ipset code lets an unprivileged local user become root, according to a fix posted to the stable kernel list by onLeaf.

Ipset stores the address and port sets used by netfilter. When a set grows, the kernel copies its entries, including pointers to attached data such as comments, into a new table. If garbage collection then frees an expired entry in the old table, it frees memory the new table still uses. A later collection of the published copy frees the same object again.

An earlier change stopped the background collector from running while a resize was in progress. That did not cover every path. When a region of the set is already full, adding an entry runs garbage collection directly. A packet can take that path while userspace is still copying the old table, freeing a comment that the new table still references.

The practical consequence is a local privilege escalation. An unprivileged process can create its own user and network namespaces, where it holds the network-administration capability, and reach the packet-side add path from there. onLeaf wrote that the duplicate free was reproduced with the kernel's address sanitizer on x86-64 and exploited from an ordinary user account to root in the initial user namespace on a build without that sanitizer.

The fix makes the direct collector take the same lock as the background collector and skip collection while the table being resized is still pinned. onLeaf said the bug was found through AI-assisted source review and that the change was prepared with assistance from OpenAI Codex. On a fixed kernel, the same sequence no longer produced a duplicate free, and the exploit test failed.