tipc: Fix a data race on mon->peer_cnt in mon_timeout()
Subsystems (3)
PATCH 1/1 tipc: Fix a data race on mon->peer_cnt in mon_timeout()
mon_timeout() evaluates dom_size(mon->peer_cnt) before it takes mon->lock, while mon->peer_cnt is updated under that lock by tipc_mon_add_peer() and tipc_mon_remove_peer(). The value can therefore be stale, and the decision whether the local domain has to be recomputed can be based on an outdated member count.
Read mon->peer_cnt inside the write_lock_bh(&mon->lock) protected region.
--- net/tipc/monitor.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
net/tipc/monitor.c +2 -1
@@ -632,9 +632,10 @@ static void mon_timeout(struct timer_list *t) {struct tipc_monitor *mon =timer_container_of (mon, t, timer);struct tipc_peer *self; -int best_member_cnt =dom_size (mon->peer_cnt) -1 ; +int best_member_cnt;write_lock_bh (&mon->lock); + best_member_cnt =dom_size (mon->peer_cnt) -1 ; self = mon->self;if (self && (best_member_cnt != self->applied)) {mon_update_local_domain (mon);
Signature · 1 line
2.43.0
Quoted 8 lines
Subject: [PATCH net] tipc: Fix a data race on
mon->peer_cntinmon_timeout()
mon_timeout()evaluatesdom_size(mon->peer_cnt)before it takesmon->lock, whilemon->peer_cntis updated under that lock bytipc_mon_add_peer()andtipc_mon_remove_peer(). The value can therefore be stale, and the decision whether the local domain has to be recomputed can be based on an outdated member count.
Quoted 4 lines
Read
mon->peer_cntinside thewrite_lock_bh(&mon->lock)protected region.Fixes 35c55c9877f8 ("tipc: add neighbor monitoring framework")Signed-off-by Ginger Li <[email protected]>
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Tue, 22 Sep 2026 16:09:09 +0800 you wrote:
mon_timeout()evaluatesdom_size(mon->peer_cnt)before it takesmon->lock, whilemon->peer_cntis updated under that lock bytipc_mon_add_peer()andtipc_mon_remove_peer(). The value can therefore be stale, and the decision whether the local domain has to be recomputed can be based on an outdated member count.Read
mon->peer_cntinside thewrite_lock_bh(&mon->lock)protected region.[...]
Here is the summary with links:
- [net] tipc: Fix a data race on mon->peer_cnt in mon_timeout()
https://git.kernel.org/netdev/net/c/8e1937fed673
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html