]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
tcp_metrics: fix data-race in tcpm_suck_dst() vs fastopen
authorEric Dumazet <edumazet@google.com>
Wed, 2 Aug 2023 13:15:00 +0000 (13:15 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 11 Aug 2023 13:13:55 +0000 (15:13 +0200)
commitdac3827253940013a0840f09603adfe7bddc4ae7
tree734abcb0bfac8c7c5993fabf0ba1d8a20ba0e38d
parent4517782e1bc35d8d974653f6c382bbad56160ed2
tcp_metrics: fix data-race in tcpm_suck_dst() vs fastopen

[ Upstream commit ddf251fa2bc1d3699eec0bae6ed0bc373b8fda79 ]

Whenever tcpm_new() reclaims an old entry, tcpm_suck_dst()
would overwrite data that could be read from tcp_fastopen_cache_get()
or tcp_metrics_fill_info().

We need to acquire fastopen_seqlock to maintain consistency.

For newly allocated objects, tcpm_new() can switch to kzalloc()
to avoid an extra fastopen_seqlock acquisition.

Fixes: 1fe4c481ba63 ("net-tcp: Fast Open client - cookie cache")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Yuchung Cheng <ycheng@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Link: https://lore.kernel.org/r/20230802131500.1478140-7-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/ipv4/tcp_metrics.c