From: Kuniyuki Iwashima Date: Wed, 6 Jul 2022 23:39:58 +0000 (-0700) Subject: tcp: Fix a data-race around sysctl_tcp_max_orphans. X-Git-Tag: v5.15.73~2310 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2dfff4b607c4b75339d3ec4adaa06dbf0a7261d9;p=platform%2Fkernel%2Flinux-rpi.git tcp: Fix a data-race around sysctl_tcp_max_orphans. [ Upstream commit 47e6ab24e8c6e3ca10ceb5835413f401f90de4bf ] While reading sysctl_tcp_max_orphans, it can be changed concurrently. So, we need to add READ_ONCE() to avoid a data-race. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kuniyuki Iwashima Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index f79b5a9..4ac53c8 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -2714,7 +2714,8 @@ static void tcp_orphan_update(struct timer_list *unused) static bool tcp_too_many_orphans(int shift) { - return READ_ONCE(tcp_orphan_cache) << shift > sysctl_tcp_max_orphans; + return READ_ONCE(tcp_orphan_cache) << shift > + READ_ONCE(sysctl_tcp_max_orphans); } bool tcp_check_oom(struct sock *sk, int shift)