]> git.itanic.dy.fi Git - linux-stable/commit
tcp: Fix Use-After-Free in tcp_ao_connect_init
authorHyunwoo Kim <v4bel@theori.io>
Mon, 22 Apr 2024 09:33:40 +0000 (05:33 -0400)
committerJakub Kicinski <kuba@kernel.org>
Wed, 24 Apr 2024 02:06:39 +0000 (19:06 -0700)
commit80e679b352c3ce5158f3f778cfb77eb767e586fb
treee10981d3bb9d55de83b94600b5640446cdf55a5b
parent4ce62d5b2f7aecd4900e7d6115588ad7f9acccca
tcp: Fix Use-After-Free in tcp_ao_connect_init

Since call_rcu, which is called in the hlist_for_each_entry_rcu traversal
of tcp_ao_connect_init, is not part of the RCU read critical section, it
is possible that the RCU grace period will pass during the traversal and
the key will be free.

To prevent this, it should be changed to hlist_for_each_entry_safe.

Fixes: 7c2ffaf21bd6 ("net/tcp: Calculate TCP-AO traffic keys")
Signed-off-by: Hyunwoo Kim <v4bel@theori.io>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Acked-by: Dmitry Safonov <0x7f454c46@gmail.com>
Link: https://lore.kernel.org/r/ZiYu9NJ/ClR8uSkH@v4bel-B760M-AORUS-ELITE-AX
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/ipv4/tcp_ao.c