linux-stable/net/xfrm
Eric Dumazet b8af8e6118 net: fix __dst_negative_advice() race
[ Upstream commit 92f1655aa2 ]

__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.

Fixes: a87cb3e48e ("net: Facility to report route quality of connected sockets")
Reported-by: Clement Lecigne <clecigne@google.com>
Diagnosed-by: Clement Lecigne <clecigne@google.com>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Tom Herbert <tom@herbertland.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://lore.kernel.org/r/20240528114353.1794151-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-06-12 11:39:55 +02:00
..
espintcp.c net: move netdev_max_backlog to net_hotdata 2024-03-07 21:12:42 -08:00
Kconfig ipsec: Select CRYPTO_AEAD 2023-10-01 16:28:14 +08:00
Makefile bpf: xfrm: Add bpf_xdp_get_xfrm_state() kfunc 2023-12-14 17:12:49 -08:00
xfrm_algo.c net: fill in MODULE_DESCRIPTION()s for xfrm 2024-02-09 14:12:01 -08:00
xfrm_compat.c net: xfrm: Amend XFRMA_SEC_CTX nla_policy structure 2023-07-03 10:51:45 +02:00
xfrm_device.c xfrm: Allow UDP encapsulation only in offload modes 2024-03-18 11:56:11 +01:00
xfrm_hash.c
xfrm_hash.h xfrm: add state hashtable keyed by seq 2021-05-14 13:52:01 +02:00
xfrm_inout.h
xfrm_input.c xfrm: Preserve vlan tags for transport mode software GRO 2024-04-26 06:44:33 +02:00
xfrm_interface_bpf.c bpf: treewide: Annotate BPF kfuncs in BTF 2024-01-31 20:40:56 -08:00
xfrm_interface_core.c ipsec-next-2024-03-06 2024-03-08 10:56:05 +00:00
xfrm_ipcomp.c net: introduce and use skb_frag_fill_page_desc() 2023-05-13 19:47:56 +01:00
xfrm_output.c xfrm: set skb control buffer based on packet offload as well 2024-03-05 10:49:44 +01:00
xfrm_policy.c net: fix __dst_negative_advice() race 2024-06-12 11:39:55 +02:00
xfrm_proc.c xfrm: get global statistics from the offloaded device 2024-02-05 16:45:49 -08:00
xfrm_replay.c xfrm: replay: Fix ESN wrap around for GSO 2022-10-19 09:00:53 +02:00
xfrm_state.c xfrm: get global statistics from the offloaded device 2024-02-05 16:45:49 -08:00
xfrm_state_bpf.c bpf: treewide: Annotate BPF kfuncs in BTF 2024-01-31 20:40:56 -08:00
xfrm_sysctl.c networking: Update to register_net_sysctl_sz 2023-08-15 15:26:18 -07:00
xfrm_user.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2024-03-07 10:29:36 -08:00