Skip to contentSkip to conversation

CVE-2024-36971: net: fix __dst_negative_advice() race

DISCUSSION Lee Jones 1 participant 1 message Jun 10, 2024

lore
Share & tools
lore

Lee Jones

author
#0 lore raw

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

net: fix __dst_negative_advice() race

__dst_negative_advice() does not enforce proper RCU rules when sk->dst_cache must be cleared, leading to possible UAF.

RCU rules are that we must first clear sk->sk_dst_cache, then call dst_release(old_dst).

Note that sk_dst_reset(sk) is implementing this protocol correctly, while __dst_negative_advice() uses the wrong order.

Given that ip6_negative_advice() has special logic against RTF_CACHE, this means each of the three ->negative_advice() existing methods must perform the sk_dst_reset() themselves.

Note the check against NULL dst is centralized in __dst_negative_advice(), there is no need to duplicate it in various callbacks.

Many thanks to Clement Lecigne for tracking this issue.

This old bug became visible after the blamed commit, using UDP sockets.

The Linux kernel CVE team has assigned CVE-2024-36971 to this issue.

Affected and fixed versions
===========================

Issue introduced in 4.6 with commit a87cb3e48ee8 and fixed in 6.10-rc2 with commit 92f1655aa2b2

Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at

	https://cve.org/CVERecord/?id=CVE-2024-36971

will be updated if fixes are backported, please check that for the most up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
include/net/dst_ops.h
include/net/sock.h
net/ipv4/route.c
net/ipv6/route.c
net/xfrm/xfrm_policy.c

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:

	https://git.kernel.org/stable/c/92f1655aa2b2294d0b49925f3b875a634bd3b59e