* [PATCH net] tipc: Fix a data race on mon->peer_cnt in mon_timeout()
@ 2026-09-22 8:09 Ginger Li
2026-09-23 3:46 ` Tung Quang Nguyen
0 siblings, 1 reply; 2+ messages in thread
From: Ginger Li @ 2026-09-22 8:09 UTC (permalink / raw)
To: jmaloy, tung.quang.nguyen; +Cc: netdev, tipc-discussion, linux-kernel
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.
Fixes: 35c55c9877f8 ("tipc: add neighbor monitoring framework")
Signed-off-by: Ginger Li <ginger.jzllee@gmail.com>
---
net/tipc/monitor.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/tipc/monitor.c b/net/tipc/monitor.c
--- a/net/tipc/monitor.c
+++ b/net/tipc/monitor.c
@@ -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);
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH net] tipc: Fix a data race on mon->peer_cnt in mon_timeout()
2026-09-22 8:09 [PATCH net] tipc: Fix a data race on mon->peer_cnt in mon_timeout() Ginger Li
@ 2026-09-23 3:46 ` Tung Quang Nguyen
0 siblings, 0 replies; 2+ messages in thread
From: Tung Quang Nguyen @ 2026-09-23 3:46 UTC (permalink / raw)
To: Ginger Li; +Cc: netdev, tipc-discussion, linux-kernel, jmaloy
> Subject: [PATCH net] 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.
> Fixes: 35c55c9877f8 ("tipc: add neighbor monitoring framework")
> Signed-off-by: Ginger Li <ginger.jzllee@gmail.com>
Reviewed-by: Tung Nguyen <tung.quang.nguyen@est.tech>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-09-23 3:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-22 8:09 [PATCH net] tipc: Fix a data race on mon->peer_cnt in mon_timeout() Ginger Li
2026-09-23 3:46 ` Tung Quang Nguyen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®