]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
tcp: use dst_dev_rcu() in tcp_fastopen_active_disable_ofo_check()
authorEric Dumazet <edumazet@google.com>
Thu, 28 Aug 2025 19:58:22 +0000 (19:58 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:34:17 +0000 (15:34 -0500)
[ Upstream commit b62a59c18b692f892dcb8109c1c2e653b2abc95c ]

Use RCU to avoid a pair of atomic operations and a potential
UAF on dst_dev()->flags.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
Link: https://patch.msgid.link/20250828195823.3958522-8-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/ipv4/tcp_fastopen.c

index 86c995dc1c5e5b50205ef02a58671f0a1a0b381b..f9460e7531ba74fd092fdb4b7d69679537c97a51 100644 (file)
@@ -575,11 +575,12 @@ void tcp_fastopen_active_disable_ofo_check(struct sock *sk)
                }
        } else if (tp->syn_fastopen_ch &&
                   atomic_read(&sock_net(sk)->ipv4.tfo_active_disable_times)) {
-               dst = sk_dst_get(sk);
-               dev = dst ? dst_dev(dst) : NULL;
+               rcu_read_lock();
+               dst = __sk_dst_get(sk);
+               dev = dst ? dst_dev_rcu(dst) : NULL;
                if (!(dev && (dev->flags & IFF_LOOPBACK)))
                        atomic_set(&sock_net(sk)->ipv4.tfo_active_disable_times, 0);
-               dst_release(dst);
+               rcu_read_unlock();
        }
 }