summaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2023-09-12 09:17:25 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-11-20 11:58:56 +0100
commit268e92e323039f49490d3ad2413d535c8ea2847f (patch)
treed1cf442dd7d6bf3a30ac886dd3663cda7c1a6a1f /net/ipv4
parent67188b2e28dacddf0d85777eca8ce4c2eadde03a (diff)
downloadlinux-stable-268e92e323039f49490d3ad2413d535c8ea2847f.tar.gz
linux-stable-268e92e323039f49490d3ad2413d535c8ea2847f.tar.bz2
linux-stable-268e92e323039f49490d3ad2413d535c8ea2847f.zip
udp: add missing WRITE_ONCE() around up->encap_rcv
[ Upstream commit 6d5a12eb91224d707f8691dccb40a5719fe5466d ] UDP_ENCAP_ESPINUDP_NON_IKE setsockopt() writes over up->encap_rcv while other cpus read it. Fixes: 067b207b281d ("[UDP]: Cleanup UDP encapsulation code") Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Willem de Bruijn <willemb@google.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/udp.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 1debc10a0f02..db43907b9a3e 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -2675,10 +2675,12 @@ int udp_lib_setsockopt(struct sock *sk, int level, int optname,
case UDP_ENCAP_ESPINUDP_NON_IKE:
#if IS_ENABLED(CONFIG_IPV6)
if (sk->sk_family == AF_INET6)
- up->encap_rcv = ipv6_stub->xfrm6_udp_encap_rcv;
+ WRITE_ONCE(up->encap_rcv,
+ ipv6_stub->xfrm6_udp_encap_rcv);
else
#endif
- up->encap_rcv = xfrm4_udp_encap_rcv;
+ WRITE_ONCE(up->encap_rcv,
+ xfrm4_udp_encap_rcv);
#endif
fallthrough;
case UDP_ENCAP_L2TPINUDP: