HIGH Introduced in 6.0
esp ZerocopyFrag UAF
CVE-2026-98368
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
KernelScan AI6.9MEDIUM
01Description
In the Linux kernel, the following vulnerability has been resolved: esp: downgrade zerocopy managed frags before mutating skb frags On the out-of-place output path (esp->inplace == false) ESP rewrites the skb frag array: esp_output_head() appends a trailer frag and esp_output_tail() replaces the frags with a destination page, both referenced with get_page(). When the skb carries zerocopy managed frags (SKBFL_MANAGED_FRAG_REFS) the payload frags are owned by the ubuf and must not be referenced or unreferenced individually, but ESP mutates the frag array without ever downgrading the skb. This breaks the managed-frag invariant two ways: - esp_ssg_unref() walks the source scatterlist and drops a page reference for every frag, including the ubuf-owned payload frags, pushing their refcount below the GUP pin bias while the pages are still pinned, i.e. a use-after-free of the zerocopy pages; - esp_output_tail() installs its destination page as frag 0 with get_page() but leaves SKBFL_MANAGED_FRAG_REFS set, so skb_release_data() takes the skip_unref branch and never drops that reference, leaking the x->xfrag page at packet rate. Fix this the way every other frag-mutating site does (__ip_append_data(), __ip6_append_data(), tcp_sendmsg_locked()) and call skb_zcopy_downgrade_managed() before ESP touches the frag array: it takes a real reference on each existing frag and clears SKBFL_MANAGED_FRAG_REFS, so the per-frag unref in esp_ssg_unref() and the frag release in skb_release_data() are both balanced and no mixed-ownership frag array is left behind.
02KernelScan AI Analysis
Risk summary
A local process using zerocopy send (e.g., io_uring) through an IPsec ESP tunnel can trigger a use-after-free on pinned pages and a per-packet memory leak. The use-after-free could lead to kernel code execution, while the leak can exhaust memory. Systems without IPsec ESP configured are not affected.
Vulnerability analysis
When ESP processes a packet on its out-of-place output path and the socket buffer carries zerocopy managed fragments, ESP rewrites the fragment array without first converting the managed fragments to normal references. This causes the cleanup path to drop page references on fragments still owned by the zerocopy user buffer, creating a use-after-free on pinned pages, and also leaves a stale flag that causes the destination page reference to leak on every packet. The fix downgrades the socket buffer from managed-fragment mode before ESP touches the fragment array, taking real references on each existing fragment and clearing the managed flag so that all subsequent reference counting is balanced. The vulnerable path is reachable from a local process that sends zerocopy data through an IPsec ESP security association; it requires no special privileges beyond the ability to use zerocopy send, though IPsec must already be configured on the system.
Lifecycle
03Fix Versions
| Branch | Introduced | Fixed in | Patch commit |
|---|---|---|---|
| 6.1 | 6.0 | 6.1.189 | 2359264f377c |
| 6.12 | 6.0 | 6.12.112 | 6508304ac2c8 |
| 6.18 | 6.0 | 6.18.54 | 6cab554f2c0f |
| 6.6 | 6.0 | 6.6.158 | 69a768c12398 |
| 7.2 | 6.0 | 7.2.8 | 0d0845ee61c5 |
| mainline | 6.0 | 7.3 | f89416eb3db1 |
| cip/6.1 | 6.0 | 6.1.189-cip61 | 2359264f377c |
| cip/6.1-rt | 6.0 | 6.1.189-cip61-rt32 | 2359264f377c |
| cip/6.12 | 6.0 | 6.12.112-cip33 | 6508304ac2c8 |
04CIP Kernels
State of the newest release of each Civil Infrastructure Platform SLTS tree, from CIP's own fix records.
| CIP tree | State |
|---|---|
| cip/6.12 | Fixed in 6.12.112-cip33 |
| cip/6.1 | Fixed in 6.1.189-cip61 |
| cip/6.1-rt | Fixed in 6.1.189-cip61-rt32 |