HIGH
xfrm DevRef Race
CVE-2026-31663
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
KernelScan AI7.1HIGH
01Description
In the Linux kernel, the following vulnerability has been resolved: xfrm: hold dev ref until after transport_finish NF_HOOK After async crypto completes, xfrm_input_resume() calls dev_put() immediately on re-entry before the skb reaches transport_finish. The skb->dev pointer is then used inside NF_HOOK and its okfn, which can race with device teardown. Remove the dev_put from the async resumption entry and instead drop the reference after the NF_HOOK call in transport_finish, using a saved device pointer since NF_HOOK may consume the skb. This covers NF_DROP, NF_QUEUE and NF_STOLEN paths that skip the okfn. For non-transport exits (decaps, gro, drop) and secondary async return points, release the reference inline when async is set.
02KernelScan AI Analysis
Risk summary
Local attackers with low privileges (CAP_NET_ADMIN via user namespaces or authenticated IPsec peer credentials) can trigger a race condition between premature device reference release and netfilter hook processing in the XFRM transport-mode input path. This leads to a use-after-free on struct net_device, which can result in kernel memory corruption, information disclosure, or system crashes.
Vulnerability analysis
The vulnerability exists in the XFRM input resume path used for async crypto completion of transport-mode IPsec packets. After crypto completes, xfrm_input_resume() incorrectly calls dev_put() before the SKB reaches xfrm4/6_transport_finish(). The saved skb->dev pointer is subsequently dereferenced inside NF_INET_PRE_ROUTING netfilter hooks and their okfn callbacks. If the network device is concurrently torn down (e.g., via namespace or interface removal), the stale pointer references freed slab memory. The fix relocates dev_put() to after NF_HOOK in the transport_finish functions, using a local device pointer copy because NF_HOOK may consume the SKB, and adds missing releases on non-transport exit paths (decaps, GRO, drop) and secondary async return points.
03Fix Versions
| Branch | Fixed in | Patch commit |
|---|---|---|
| 3.17 | 3.17 | 5002beda5cac |
| 3.3 | 3.3 | 0f451b43c88b |
| 4.15 | 4.15 | 1c428b038400 |
| 6.18 | 6.18.23 | — |
| 6.19 | 6.19.13 | — |
| mainline | 7.0 | — |