CVE-2026-139793: inet: frags: bound the wmem charge of the socket completing a reassembly
In the Linux kernel, the following vulnerability has been resolved:
inet: frags: bound the wmem charge of the socket completing a reassembly
When a socket owned fragment completes a reassembly queue, inetfragreasmprepare() and inetfragreasmfinish() charge the truesize of all other fragments to its skwmemalloc. These fragments were orphaned when queued, and might have been sent by someone else, for instance padded TUN packets.
Commit 3ae20e4697eb ("inet: frags: limit the truesize of a reassembly queue") bounds this charge to INTMAX / 2 per queue, but a socket can complete several queues while the reassembled skbs are still alive, for instance held in a qdisc. skwmemalloc can then go past INTMAX, refcountadd() saturates it with a WARN, and the socket is leaked.
This is reachable from an unprivileged user/network namespace, by raising ipfraghighthresh.
Refuse the reassembly if the charge would push skwmemalloc above 2 sksndbuf, the bound ipappenddata() uses, plus 4MB of slack for fragments inflated by a refragmentation with a small MTU, and never above INTMAX / 2. The cap matters for tun sockets, which use sksndbuf = INTMAX, and whose skbs are still owned when actct or openvswitch reassemble them at ingress.
Several queues can complete at the same time on different cpus for the same socket, so the charge is reserved with a cmpxchg() loop in inetfragreasmprepare(), before it modifies the queue, and settled in inetfragreasmfinish(). Move the size checks of ipfragreasm(), ip6fragreasm() and nfctfrag6reasm() before inetfragreasmprepare(), using the first fragment which becomes the head, so that a successful inetfragreasmprepare() is always followed by inetfragreasmfinish(). All callers already kill the queue when inetfragreasmprepare() returns NULL.
Found by code inspection (AI review), not reproduced.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Compensating control
In inet_frag_reasm_prepare(), check the socket memory charge before modifying the reassembly queue, and refuse reassembly if the charge would push sk_wmem_alloc above INT_MAX / 2.