CVE-2026-139342: net: use the full socket in sk_mc_loop()
In the Linux kernel, the following vulnerability has been resolved:
net: use the full socket in skmcloop()
skmcloop() is called from ipmcoutput() and ip6finishoutput2() with skb->sk, which is not always a full socket:
- Since commit ca6fb0651883 ("tcp: attach SYNACK messages to request sockets instead of listener"), a SYNACK is attached to its request socket.
- Since commit 79636038d37e ("ipv4: tcp: give socket pointer to control skbs"), an ACK or RST sent by ipsendunicastreply() on behalf of a TIMEWAIT socket is attached to the timewait socket.
When such a packet uses a multicast route, inettestbit(MCLOOP, sk) reads inetflags past the end of the request or timewait socket.
This happens for instance when a SYN with a multicast source address reaches a listener, after being looped back with its dst attached, so that iprcvfinishcore() skips the martian source check. A raw IPHDRINCL socket sending to a local address does this, as does re-injection by nft dup or the iptables TEE target. The destination can also come from a source route option, or from a route of type multicast covering a unicast prefix.
BUG: KASAN: slab-out-of-bounds in skmcloop+0x111/0x170 Read of size 8 at addr ffff88800f2b7f10 by task repro-raw/470 Call Trace: <IRQ> skmcloop+0x111/0x170 ipmcoutput+0x355/0x930 ipbuildandsendpkt+0xb87/0xc50 tcpv4sendsynack+0x500/0x6f0 tcpconnrequest+0x2135/0x2d90 tcpv4connrequest+0xa5/0x210 tcprcvstateprocess+0x136e/0x6920 tcpv4dorcv+0x339/0xb10 tcpv4rcv+0x34ab/0x3ab0 ipprotocoldeliverrcu+0x6e/0x3e0 iplocaldeliverfinish+0x34d/0x510 iplocaldeliver+0x1bc/0x310 iprcv+0x390/0x410 netifreceiveskbonecore+0x199/0x1e0 processbacklog+0x239/0x680 napipoll+0xb5/0x650 netrxaction+0x980/0xd60 handlesoftirqs+0x17f/0x590 dosoftirq+0x3f/0x60 </IRQ>
The buggy address belongs to the object at ffff88800f2b7d60 which belongs to the cache requestsockTCP of size 312 The buggy address is located 120 bytes to the right of allocated 312-byte region [ffff88800f2b7d60, ffff88800f2b7e98)
Use skconsttofullsk(), which restores the behavior from before the two commits above: a request socket uses the setting of its listener, and a timewait socket gets the default (loop back), as the per-cpu control socket used before had.
[edumazet: rewrote the changelog, added the TIMEWAIT case]
Affected Software
Event History
Frequently Asked Questions
Which traffic paths can trigger the out-of-bounds read?
The issue can be triggered when a packet associated with a request socket or TIME_WAIT socket uses a multicast route. One described case is a SYN with a multicast source address reaching a listener after loopback; raw IP_HDRINCL traffic sent to a local address, nft dup reinjection, and the iptables TEE target can create this condition.
Are only explicitly multicast destinations relevant?
No. The destination may be supplied through a source-route option, and a multicast route that covers a unicast prefix can also cause the affected path to be used.
What socket types are involved?
SYNACK packets can be attached to request sockets, while ACK or RST packets sent on behalf of a TIME_WAIT socket can be attached to timewait sockets. These are not full sockets, so reading multicast-loop flags from them can access memory past the object boundary.