CVE-2024-56644: net/ipv6: release expired exception dst cached in socket
In the Linux kernel, the following vulnerability has been resolved:
net/ipv6: release expired exception dst cached in socket
Dst objects get leaked in ip6negativeadvice() when this function is executed for an expired IPv6 route located in the exception table. There are several conditions that must be fulfilled for the leak to occur: an ICMPv6 packet indicating a change of the MTU for the path is received, resulting in an exception dst being created a TCP connection that uses the exception dst for routing packets must start timing out so that TCP begins retransmissions after the exception dst expires, the FIB6 garbage collector must not run before TCP executes ip6negativeadvice() for the expired exception dst
When TCP executes ip6negativeadvice() for an exception dst that has expired and if no other socket holds a reference to the exception dst, the refcount of the exception dst is 2, which corresponds to the increment made by dstinit() and the increment made by the TCP socket for which the connection is timing out. The refcount made by the socket is never released. The refcount of the dst is decremented in skdstreset() but that decrement is counteracted by a dsthold() intentionally placed just before the skdstreset() in ip6negativeadvice(). After ip6negativeadvice() has finished, there is no other object tied to the dst. The socket lost its reference stored in skdstcache and the dst is no longer in the exception table. The exception dst becomes a leaked object.
As a result of this dst leak, an unbalanced refcount is reported for the loopback device of a net namespace being destroyed under kernels that do not contain e5f80fcf869a ("ipv6: give an IPv6 dev to blackholenetdev"): unregisternetdevice: waiting for lo to become free. Usage count = 2
Fix the dst leak by removing the dsthold() in ip6negativeadvice(). The patch that introduced the dsthold() in ip6negativeadvice() was 92f1655aa2b22 ("net: fix dstnegativeadvice() race"). But 92f1655aa2b22 merely refactored the code with regards to the dst refcount so the issue was present even before 92f1655aa2b22. The bug was introduced in 54c1a859efd9f ("ipv6: Don't drop cache route entry unless timer actually expired.") where the expired cached route is deleted and the skdstcache member of the socket is set to NULL by calling dstnegativeadvice() but the refcount belonging to the socket is left unbalanced.
The IPv4 version - ipv4negativeadvice() - is not affected by this bug. When the TCP connection times out ipv4negativeadvice() merely resets the skdstcache of the socket while decrementing the refcount of the exception dst.
Other sources
This CVE was automatically created from a reference found in an email or other text. If you are reading this, then this CVE entry is probably erroneous, since this text should be replaced by the official CVE description automatically.
— Launchpad
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
debian/linuxto a version that resolves this vulnerability.Fixed in 5.10.234-1Fixed in 6.1.129-1Fixed in 6.1.135-1Fixed in 6.12.27-1 - Upgrade
Upgrade
debian/linux-6.1to a version that resolves this vulnerability.Fixed in 6.1.129-1~deb11u1 - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Patch 54c1a859efd9f - Upgrade
Upgrade to a fixed release to a version that resolves this vulnerability.
Patch 92f1655aa2b22 - Configuration
Fix the IPv6 exception dst leak by removing the dst_hold() in ip6_negative_advice(), which resolves the unbalanced dst refcount when an expired exception dst cached in a socket is released.
Linux kernel net/ipv6 (ip6_negative_advice) dst_hold() call in ip6_negative_advice() = remove dst_hold()
Event History
Frequently Asked Questions
What is the severity of CVE-2024-56644?
CVE-2024-56644 is rated as a moderate severity vulnerability due to potential memory leaks in the Linux kernel.
How do I fix CVE-2024-56644?
To fix CVE-2024-56644, you should update the Linux kernel to a version that includes the patch for this vulnerability.
What vulnerabilities are associated with CVE-2024-56644?
CVE-2024-56644 is associated with a vulnerability that can cause memory leaks when handling expired IPv6 routes in socket operations.
Which software versions are affected by CVE-2024-56644?
CVE-2024-56644 affects specific versions of the Linux kernel prior to the patch release.
What causes the issue in CVE-2024-56644?
The issue in CVE-2024-56644 is caused by leaked dst objects in the ip6_negative_advice() function when dealing with expired IPv6 routes.