Thread View: linux.kernel.netdev
9 messages
9 total messages
Started by Henry Martin
Mon, 12 Oct 2026 15:33
[PATCH net v2] tipc: fix broadcast sender hang on last acker departure
Author: Henry Martin
Date: Mon, 12 Oct 2026 15:33
Date: Mon, 12 Oct 2026 15:33
136 lines
13407 bytes
13407 bytes
TIPC group broadcast senders are blocked while a replicast still has
outstanding member acks: poll(EPOLLOUT) only fires when
tsk->group_is_open, and writers keep re-sleeping on every unrelated
data-ready wakeup because tipc_group_bc_cong() keeps seeing
*grp->open == false (the default sk_sndtimeo is MAX_SCHEDULE_TIMEOUT,
so there is no bounded send timeout either).
When the last outstanding acker departs before acking,
tipc_group_delete_member() decrements grp->bc_ackers but never
restores *grp->open, and the blocked senders are never woken.
Commit 99cc2a62e07a ("tipc: reject invalid and unexpected
GRP_ACK_MSG to prevent bc_ackers underflow") already calls this out
in its changelog as a pre-existing issue.
Reproduced on a two-node TIPC group cluster (v7.3-rc5, two QEMU
guests over a UDP bearer): with one member's ack outstanding and
that member then departing, poll(POLLOUT) on the sender never
fired and a blocking sendmsg() never returned; with the fix
applied both are released when the leave event is delivered (log
below the fold).
Restore the open state exactly on the 1->0 transition in the delete
path, mirroring the GRP_ACK_MSG completion path, and invoke
sk->sk_write_space() from tipc_sk_filter_rcv() when the group just
became writable again.
While at it, make the accounting precise: the delete path used to
test less(m->bc_acked, grp->bc_snd_nxt - 1), which also matches
members that were never counted for the current replicast
(JOINING/LEAVING members keep a stale bc_acked). Zeroing
bc_ackers on such a member could silently void a still-outstanding
ack from a real acker. Track whether a member owes an ack for the
current replicast in a new per-member bc_pending flag, set when the
member is counted and cleared when its ack arrives, and test that
in the delete path instead. Suggested by Tung Quang Nguyen.
This issue was discovered by Tencent CodeBuddy Security.
Cc: stable@vger.kernel.org
Fixes: 2f487712b893 ("tipc: guarantee that group broadcast doesn't bypass group unicast")
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
---
v2: Subject no longer claims a leak; describe the actual wakeup
mechanics and add the reproduction; the delete path now
discriminates members that were actually counted for the
current replicast via a new per-member bc_pending flag instead
of comparing a possibly stale bc_acked (Tung Quang Nguyen).
Reproduction (two QEMU guests, TIPC over UDP bearer; the acking
peer withheld GRP_ACK_MSG via a test-only knob to emulate the
lossy peer, the sender's kernel ran unmodified TIPC):
UNPATCHED (#88/#90, fix absent):
sender: NO POLLOUT for 30s after member departed -> STALL
sender2: R2 NEVER returned in 32s (blocked writer not woken)
PATCHED (#89, this patch):
sender: POLLOUT at t=18.5s, when the leave event was delivered
sender2: R2 returned at t=18.6s, EHOSTUNREACH on now-empty group
net/tipc/group.c | 13 ++++++++++---
net/tipc/socket.c | 12 +++++++++++-
2 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/net/tipc/group.c b/net/tipc/group.c
index 74f6d3dac0784..e9c77f12c9819 100644
--- a/net/tipc/group.c
+++ b/net/tipc/group.c
@@ -75,6 +75,7 @@ struct tipc_member {
u16 bc_rcv_nxt;
u16 bc_syncpt;
u16 bc_acked;
+ bool bc_pending;
};
struct tipc_group {
@@ -340,9 +341,12 @@ static void tipc_group_delete_member(struct tipc_group *grp,
rb_erase(&m->tree_node, &grp->members);
grp->member_cnt--;
- /* Check if we were waiting for replicast ack from this member */
- if (grp->bc_ackers && less(m->bc_acked, grp->bc_snd_nxt - 1))
- grp->bc_ackers--;
+ /* If this member owed an ack for the current replicast and it
+ * was the last one, restore the open state so blocked broadcast
+ * senders can proceed.
+ */
+ if (grp->bc_ackers && m->bc_pending && !--grp->bc_ackers)
+ *grp->open = true;
list_del_init(&m->list);
list_del_init(&m->small_win);
@@ -406,6 +410,8 @@ void tipc_group_update_bc_members(struct tipc_group *grp, int len, bool ack)
m->bc_acked = prev;
ackers++;
}
+ if (ack)
+ m->bc_pending = tipc_group_is_receiver(m);
}
/* Mark number of acknowledges to expect, if any */
@@ -803,6 +809,7 @@ void tipc_group_proto_rcv(struct tipc_group *grp, bool *usr_wakeup,
if (acked != grp->bc_snd_nxt || m->bc_acked == acked)
return;
m->bc_acked = acked;
+ m->bc_pending = false;
if (--grp->bc_ackers)
return;
list_del_init(&m->small_win);
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index d5d70eb230b56..65cc0c4964b31 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -2356,8 +2356,18 @@ static void tipc_sk_filter_rcv(struct sock *sk, struct sk_buff *skb,
if (unlikely(!msg_isdata(hdr)))
tipc_sk_proto_rcv(sk, &inputq, xmitq);
- if (unlikely(grp))
+ if (unlikely(grp)) {
+ bool was_open = tsk->group_is_open;
+
tipc_group_filter_msg(grp, &inputq, xmitq);
+ /* A departing member may have held the last outstanding
+ * replicast ack, which can restore the open state inside
+ * tipc_group_filter_msg(); wake up senders blocked in
+ * poll()/write() if the group just became writable.
+ */
+ if (!was_open && tsk->group_is_open)
+ sk->sk_write_space(sk);
+ }
if (unlikely(!grp) && mtyp == TIPC_MCAST_MSG)
tipc_mcast_filter_msg(net, &tsk->mc_method.deferredq, &inputq);
--
2.43.7
Re: [PATCH net v2] tipc: fix broadcast sender hang on last acker departure
Author: netdev-bot+sashiko
Date: Tue, 13 Oct 2026 16:24
Date: Tue, 13 Oct 2026 16:24
164 lines
11830 bytes
11830 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The patch adds m->bc_pending so that only members counted for
the current replicast can reduce grp->bc_ackers, but it checks the…
- [Low] The commit message gives the wrong reason why blocked writers
stay asleep, and it overstates when the blocking sendmsg() hang…
--
tipc: fix broadcast sender hang on last acker departure
This patch restores *grp->open when the last member that owes a replicast
ack is deleted. It also calls sk->sk_write_space() from tipc_sk_filter_rcv()
when the group becomes writable again. A new per-member bc_pending flag
limits the bc_ackers decrement in the delete path to members that were
counted for the current replicast.
> TIPC group broadcast senders are blocked while a replicast still has
> outstanding member acks: poll(EPOLLOUT) only fires when
> tsk->group_is_open, and writers keep re-sleeping on every unrelated
> data-ready wakeup because tipc_group_bc_cong() keeps seeing
> *grp->open == false (the default sk_sndtimeo is MAX_SCHEDULE_TIMEOUT,
> so there is no bounded send timeout either).
[Severity: Low]
Is this description of the mechanism accurate? tipc_group_bc_cong() only
writes *grp->open and never reads it:
net/tipc/group.c:tipc_group_bc_cong() {
if (grp->bc_ackers) {
*grp->open = false;
return true;
}
if (list_empty(&grp->small_win))
return false;
...
}
Its return value depends only on grp->bc_ackers and the head of
grp->small_win.
> When the last outstanding acker departs before acking,
> tipc_group_delete_member() decrements grp->bc_ackers but never
> restores *grp->open, and the blocked senders are never woken.
The old delete path already brought bc_ackers to 0 when the last owing
member left. That member has bc_acked == S-1 and bc_snd_nxt == S+1, so the
less() test matches.
tipc_wait_for_cond() waits with woken_wake_function, which ignores the poll
key, and tipc_data_ready() wakes every sleeper on sk_wq.
So with group member events enabled, the sk_data_ready() after the leave
event is delivered already woke the writer in tipc_send_group_bcast().
tipc_group_bc_cong() then returned false and sendmsg() went on, returning
EHOSTUNREACH if the group was now empty.
The poll(EPOLLOUT) hang does look real in every case, because tipc_poll()
only sets EPOLLOUT when tsk->group_is_open is true.
The blocking sendmsg() hang seems to happen only when nothing wakes the
writer after the deletion. One example is group member events being
disabled. In that case TIPC_GRP_MEMBER_EVT is freed with deliver = false
and sk_data_ready() is never called.
The code change itself looks correct. Since this is tagged for stable,
could the changelog describe the actual wakeup path and say when the
sendmsg() hang occurs?
> diff --git a/net/tipc/group.c b/net/tipc/group.c
> index 74f6d3dac0784..e9c77f12c9819 100644
> --- a/net/tipc/group.c
> +++ b/net/tipc/group.c
[ ... ]
> @@ -340,9 +341,12 @@ static void tipc_group_delete_member(struct tipc_group *grp,
> rb_erase(&m->tree_node, &grp->members);
> grp->member_cnt--;
>
> - /* Check if we were waiting for replicast ack from this member */
> - if (grp->bc_ackers && less(m->bc_acked, grp->bc_snd_nxt - 1))
> - grp->bc_ackers--;
> + /* If this member owed an ack for the current replicast and it
> + * was the last one, restore the open state so blocked broadcast
> + * senders can proceed.
> + */
> + if (grp->bc_ackers && m->bc_pending && !--grp->bc_ackers)
> + *grp->open = true;
>
> list_del_init(&m->list);
> list_del_init(&m->small_win);
> @@ -406,6 +410,8 @@ void tipc_group_update_bc_members(struct tipc_group *grp, int len, bool ack)
> m->bc_acked = prev;
> ackers++;
> }
> + if (ack)
> + m->bc_pending = tipc_group_is_receiver(m);
> }
>
> /* Mark number of acknowledges to expect, if any */
> @@ -803,6 +809,7 @@ void tipc_group_proto_rcv(struct tipc_group *grp, bool *usr_wakeup,
> if (acked != grp->bc_snd_nxt || m->bc_acked == acked)
> return;
> m->bc_acked = acked;
> + m->bc_pending = false;
> if (--grp->bc_ackers)
> return;
> list_del_init(&m->small_win);
[Severity: Medium]
Should the GRP_ACK_MSG handler also check m->bc_pending before it
decrements grp->bc_ackers?
The new test in tipc_group_delete_member() assumes bc_ackers equals the
number of members with bc_pending set.
This handler still decrements bc_ackers for any member that passes the
acked == grp->bc_snd_nxt and m->bc_acked != acked checks.
Two kinds of member can pass those checks without having been counted:
- Members that were MBR_JOINING or MBR_LEAVING when
tipc_group_update_bc_members() ran keep a stale bc_acked and get
bc_pending = false.
- Members created after the replicast have bc_pending = false and
bc_acked = bc_snd_nxt - 1 from tipc_group_create_member().
For both, a GRP_ACK_MSG carrying acked == bc_snd_nxt passes every check
here.
For example, with bc_ackers == 2 for counted members A and B:
ack from uncounted member X bc_ackers 2 -> 1
B acks, or B is deleted bc_ackers 1 -> 0, *grp->open = true
A still has bc_pending == true and has never acked.
Isn't this the case the commit message gives as the reason for adding
bc_pending, where a non-counted member "could silently void a
still-outstanding ack from a real acker"?
A cluster peer can trigger this. It sends GRP_JOIN_MSG, which makes
tipc_group_proto_rcv() create an MBR_JOINING member for any port. It then
sends GRP_ACK_MSG with acked == bc_snd_nxt. I could not find a benign
protocol sequence that ends up here.
Would something like this close the gap?
if (acked != grp->bc_snd_nxt || !m->bc_pending)
return;
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261012153357.1863316-1-bsdhenrymartin%40gmail.com
Re: [PATCH net v2] tipc: fix broadcast sender hang on last acker departure
Author: Tung Quang Nguyen
Date: Wed, 14 Oct 2026 13:37
Date: Wed, 14 Oct 2026 13:37
20 lines
13776 bytes
13776 bytes
> @@ -406,6 +410,8 @@ void tipc_group_update_bc_members(struct tipc_group *grp, int len, bool ack)
> m->bc_acked = prev;
> ackers++;
> }
> + if (ack)
> + m->bc_pending = tipc_group_is_receiver(m);
> }
This needs to be done in a simple way:
@ -405,6 +405,7 @@ void tipc_group_update_bc_members(struct tipc_group *grp, int len, bool ack)
tipc_group_update_member(m, len);
m->bc_acked = prev;
ackers++;
+ m->bc_pending = ack;
}
}
RE: [PATCH net v2] tipc: fix broadcast sender hang on last acker departure
Author: Tung Quang Nguyen
Date: Wed, 14 Oct 2026 13:40
Date: Wed, 14 Oct 2026 13:40
198 lines
20678 bytes
20678 bytes
>Subject: Re: [PATCH net v2] tipc: fix broadcast sender hang on last acker
>departure
>
>Thank you for your contribution! Sashiko AI review found 2 potential
>issue(s) to consider.
>
>Critical: 0 · High: 0 · Medium: 1 · Low: 1
>
>If you believe none of the issues are legitimate, please reply to each issue of
>Medium severity or higher and explain why the AI is wrong.
>If any of them are legitimate and you plan to respin, please let patchwork
>know by including "pw-bot: cr" as a separate line at the end of your reply (one
>such reply per series is enough).
>
>- [Medium] The patch adds m->bc_pending so that only members counted for
> the current replicast can reduce grp->bc_ackers, but it checks the…
>- [Low] The commit message gives the wrong reason why blocked writers
> stay asleep, and it overstates when the blocking sendmsg() hang…
>
>--
>
>tipc: fix broadcast sender hang on last acker departure
>
>This patch restores *grp->open when the last member that owes a replicast ack
>is deleted. It also calls sk->sk_write_space() from tipc_sk_filter_rcv() when the
>group becomes writable again. A new per-member bc_pending flag limits the
>bc_ackers decrement in the delete path to members that were counted for the
>current replicast.
>
>> TIPC group broadcast senders are blocked while a replicast still has
>> outstanding member acks: poll(EPOLLOUT) only fires when
>> tsk->group_is_open, and writers keep re-sleeping on every unrelated
>> data-ready wakeup because tipc_group_bc_cong() keeps seeing *grp->open
>> == false (the default sk_sndtimeo is MAX_SCHEDULE_TIMEOUT, so there is
>> no bounded send timeout either).
>
>[Severity: Low]
>Is this description of the mechanism accurate? tipc_group_bc_cong() only
>writes *grp->open and never reads it:
>
>net/tipc/group.c:tipc_group_bc_cong() {
> if (grp->bc_ackers) {
> *grp->open = false;
> return true;
> }
> if (list_empty(&grp->small_win))
> return false;
> ...
>}
>
>Its return value depends only on grp->bc_ackers and the head of
>grp->small_win.
>
>> When the last outstanding acker departs before acking,
>> tipc_group_delete_member() decrements grp->bc_ackers but never
>> restores *grp->open, and the blocked senders are never woken.
>
>The old delete path already brought bc_ackers to 0 when the last owing
>member left. That member has bc_acked == S-1 and bc_snd_nxt == S+1, so the
>less() test matches.
>
>tipc_wait_for_cond() waits with woken_wake_function, which ignores the poll
>key, and tipc_data_ready() wakes every sleeper on sk_wq.
>
>So with group member events enabled, the sk_data_ready() after the leave
>event is delivered already woke the writer in tipc_send_group_bcast().
>tipc_group_bc_cong() then returned false and sendmsg() went on, returning
>EHOSTUNREACH if the group was now empty.
>
>The poll(EPOLLOUT) hang does look real in every case, because tipc_poll() only
>sets EPOLLOUT when tsk->group_is_open is true.
>
>The blocking sendmsg() hang seems to happen only when nothing wakes the
>writer after the deletion. One example is group member events being disabled.
>In that case TIPC_GRP_MEMBER_EVT is freed with deliver = false and
>sk_data_ready() is never called.
>
>The code change itself looks correct. Since this is tagged for stable, could the
>changelog describe the actual wakeup path and say when the
>sendmsg() hang occurs?
Please rewrite the changelog.
>
>> diff --git a/net/tipc/group.c b/net/tipc/group.c index
>> 74f6d3dac0784..e9c77f12c9819 100644
>> --- a/net/tipc/group.c
>> +++ b/net/tipc/group.c
>
>[ ... ]
>
>> @@ -340,9 +341,12 @@ static void tipc_group_delete_member(struct
>tipc_group *grp,
>> rb_erase(&m->tree_node, &grp->members);
>> grp->member_cnt--;
>>
>> - /* Check if we were waiting for replicast ack from this member */
>> - if (grp->bc_ackers && less(m->bc_acked, grp->bc_snd_nxt - 1))
>> - grp->bc_ackers--;
>> + /* If this member owed an ack for the current replicast and it
>> + * was the last one, restore the open state so blocked broadcast
>> + * senders can proceed.
>> + */
>> + if (grp->bc_ackers && m->bc_pending && !--grp->bc_ackers)
>> + *grp->open = true;
>>
>> list_del_init(&m->list);
>> list_del_init(&m->small_win);
>> @@ -406,6 +410,8 @@ void tipc_group_update_bc_members(struct
>tipc_group *grp, int len, bool ack)
>> m->bc_acked = prev;
>> ackers++;
>> }
>> + if (ack)
>> + m->bc_pending = tipc_group_is_receiver(m);
>> }
>>
>> /* Mark number of acknowledges to expect, if any */ @@ -803,6
>+809,7
>> @@ void tipc_group_proto_rcv(struct tipc_group *grp, bool *usr_wakeup,
>> if (acked != grp->bc_snd_nxt || m->bc_acked == acked)
>> return;
>> m->bc_acked = acked;
>> + m->bc_pending = false;
>> if (--grp->bc_ackers)
>> return;
>> list_del_init(&m->small_win);
>
>[Severity: Medium]
>Should the GRP_ACK_MSG handler also check m->bc_pending before it
>decrements grp->bc_ackers?
>
>The new test in tipc_group_delete_member() assumes bc_ackers equals the
>number of members with bc_pending set.
>
>This handler still decrements bc_ackers for any member that passes the acked
>== grp->bc_snd_nxt and m->bc_acked != acked checks.
>
>Two kinds of member can pass those checks without having been counted:
>
>- Members that were MBR_JOINING or MBR_LEAVING when
> tipc_group_update_bc_members() ran keep a stale bc_acked and get
> bc_pending = false.
>- Members created after the replicast have bc_pending = false and
> bc_acked = bc_snd_nxt - 1 from tipc_group_create_member().
>
>For both, a GRP_ACK_MSG carrying acked == bc_snd_nxt passes every check
>here.
>
>For example, with bc_ackers == 2 for counted members A and B:
>
> ack from uncounted member X bc_ackers 2 -> 1
> B acks, or B is deleted bc_ackers 1 -> 0, *grp->open = true
>
>A still has bc_pending == true and has never acked.
>
>Isn't this the case the commit message gives as the reason for adding
>bc_pending, where a non-counted member "could silently void a still-
>outstanding ack from a real acker"?
>
>A cluster peer can trigger this. It sends GRP_JOIN_MSG, which makes
>tipc_group_proto_rcv() create an MBR_JOINING member for any port. It then
>sends GRP_ACK_MSG with acked == bc_snd_nxt. I could not find a benign
>protocol sequence that ends up here.
>
>Would something like this close the gap?
>
> if (acked != grp->bc_snd_nxt || !m->bc_pending)
> return;
>
Looks right. Please use this approach (Perhaps, bc_acked field of tipc_member needs to be removed).
[PATCH net v3] tipc: fix broadcast sender hang on last acker departure
Author: Henry Martin
Date: Thu, 15 Oct 2026 02:20
Date: Thu, 15 Oct 2026 02:20
166 lines
14668 bytes
14668 bytes
TIPC group broadcast senders are blocked while a replicast still has
outstanding member acks: tipc_group_bc_cong() returns true as long as
grp->bc_ackers is non-zero, and clears *grp->open, which is what
tipc_poll() uses to report EPOLLOUT (via tsk->group_is_open).
When the last outstanding acker departs before acking,
tipc_group_delete_member() decrements grp->bc_ackers to zero but
never restores *grp->open. As a result poll(EPOLLOUT) never fires
again. A writer blocked in sendmsg() is only released if some other
wakeup happens after the deletion: with TIPC_GROUP_MEMBER_EVTS the
leave event delivery calls sk_data_ready() and wakes it, but without
member events nothing does and it sleeps indefinitely, since the
default send timeout is MAX_SCHEDULE_TIMEOUT.
Commit 99cc2a62e07a ("tipc: reject invalid and unexpected
GRP_ACK_MSG to prevent bc_ackers underflow") already calls this out
in its changelog as a pre-existing issue.
Restore the open state exactly on the 1->0 transition in the delete
path, mirroring the GRP_ACK_MSG completion path, and invoke
sk->sk_write_space() from tipc_sk_filter_rcv() when the group just
became writable again.
Also make the ack accounting precise. The delete path used to test
less(m->bc_acked, grp->bc_snd_nxt - 1), which also matches members
that were never counted for the current replicast (JOINING/LEAVING
members keep a stale bc_acked), and the GRP_ACK_MSG handler accepted
an ack from any member whose bc_acked differed from the expected
value. Either could zero bc_ackers on behalf of a member that owes
nothing and silently void an ack still owed by a real acker. Track
whether a member owes an ack for the current replicast in a new
per-member bc_pending flag, set when the member is counted and
cleared when its ack arrives, and use it both to accept an ack and
to decide on deletion. bc_acked has no remaining user and is
removed. Suggested by Tung Quang Nguyen.
This issue was discovered by Tencent CodeBuddy Security.
Cc: stable@vger.kernel.org
Fixes: 2f487712b893 ("tipc: guarantee that group broadcast doesn't bypass group unicast")
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
---
v3: Correct the changelog: tipc_group_bc_cong() only writes *grp->open,
and a blocked sendmsg() hangs only when nothing wakes it after the
deletion (e.g. member events disabled); also require bc_pending
in the GRP_ACK_MSG handler so an uncounted member cannot decrement
bc_ackers, and drop the now unused bc_acked field.
v2: Subject no longer claims a leak; add the reproduction; the delete
path now discriminates members that were actually counted for the
current replicast via a new per-member bc_pending flag instead
of comparing a possibly stale bc_acked (Tung Quang Nguyen).
Reproduction (two QEMU guests, TIPC over UDP bearer, groups joined
without member events; the acking peer withheld GRP_ACK_MSG via a
test-only knob to emulate the lossy peer, the sender's kernel ran
unmodified TIPC):
UNPATCHED (#88/#90, fix absent):
sender: NO POLLOUT for 30s after member departed -> STALL
sender2: R2 NEVER returned in 32s (blocked writer not woken)
PATCHED (#89, v1 of this patch):
sender: POLLOUT at t=18.5s, when the leave event was delivered
sender2: R2 returned at t=18.6s, EHOSTUNREACH on now-empty group
net/tipc/group.c | 20 +++++++++++---------
net/tipc/socket.c | 12 +++++++++++-
2 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/net/tipc/group.c b/net/tipc/group.c
index 74f6d3dac0784..b76edd5001ffa 100644
--- a/net/tipc/group.c
+++ b/net/tipc/group.c
@@ -74,7 +74,7 @@ struct tipc_member {
u16 window;
u16 bc_rcv_nxt;
u16 bc_syncpt;
- u16 bc_acked;
+ bool bc_pending;
};
struct tipc_group {
@@ -316,7 +316,6 @@ static struct tipc_member *tipc_group_create_member(struct tipc_group *grp,
m->node = node;
m->port = port;
m->instance = instance;
- m->bc_acked = grp->bc_snd_nxt - 1;
ret = tipc_group_add_to_tree(grp, m);
if (ret < 0) {
kfree(m);
@@ -340,9 +339,12 @@ static void tipc_group_delete_member(struct tipc_group *grp,
rb_erase(&m->tree_node, &grp->members);
grp->member_cnt--;
- /* Check if we were waiting for replicast ack from this member */
- if (grp->bc_ackers && less(m->bc_acked, grp->bc_snd_nxt - 1))
- grp->bc_ackers--;
+ /* If this member owed an ack for the current replicast and it
+ * was the last one, restore the open state so blocked broadcast
+ * senders can proceed.
+ */
+ if (grp->bc_ackers && m->bc_pending && !--grp->bc_ackers)
+ *grp->open = true;
list_del_init(&m->list);
list_del_init(&m->small_win);
@@ -394,7 +396,6 @@ void tipc_group_update_member(struct tipc_member *m, int len)
void tipc_group_update_bc_members(struct tipc_group *grp, int len, bool ack)
{
- u16 prev = grp->bc_snd_nxt - 1;
struct tipc_member *m;
struct rb_node *n;
u16 ackers = 0;
@@ -403,9 +404,10 @@ void tipc_group_update_bc_members(struct tipc_group *grp, int len, bool ack)
m = container_of(n, struct tipc_member, tree_node);
if (tipc_group_is_receiver(m)) {
tipc_group_update_member(m, len);
- m->bc_acked = prev;
ackers++;
}
+ if (ack)
+ m->bc_pending = tipc_group_is_receiver(m);
}
/* Mark number of acknowledges to expect, if any */
@@ -800,9 +802,9 @@ void tipc_group_proto_rcv(struct tipc_group *grp, bool *usr_wakeup,
if (!m || !grp->bc_ackers)
return;
acked = msg_grp_bc_acked(hdr);
- if (acked != grp->bc_snd_nxt || m->bc_acked == acked)
+ if (acked != grp->bc_snd_nxt || !m->bc_pending)
return;
- m->bc_acked = acked;
+ m->bc_pending = false;
if (--grp->bc_ackers)
return;
list_del_init(&m->small_win);
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index d5d70eb230b56..65cc0c4964b31 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -2356,8 +2356,18 @@ static void tipc_sk_filter_rcv(struct sock *sk, struct sk_buff *skb,
if (unlikely(!msg_isdata(hdr)))
tipc_sk_proto_rcv(sk, &inputq, xmitq);
- if (unlikely(grp))
+ if (unlikely(grp)) {
+ bool was_open = tsk->group_is_open;
+
tipc_group_filter_msg(grp, &inputq, xmitq);
+ /* A departing member may have held the last outstanding
+ * replicast ack, which can restore the open state inside
+ * tipc_group_filter_msg(); wake up senders blocked in
+ * poll()/write() if the group just became writable.
+ */
+ if (!was_open && tsk->group_is_open)
+ sk->sk_write_space(sk);
+ }
if (unlikely(!grp) && mtyp == TIPC_MCAST_MSG)
tipc_mcast_filter_msg(net, &tsk->mc_method.deferredq, &inputq);
--
2.43.7
RE: [PATCH net v3] tipc: fix broadcast sender hang on last acker departure
Author: Tung Quang Nguyen
Date: Mon, 19 Oct 2026 11:09
Date: Mon, 19 Oct 2026 11:09
158 lines
18868 bytes
18868 bytes
>Subject: [PATCH net v3] tipc: fix broadcast sender hang on last acker departure
>
>TIPC group broadcast senders are blocked while a replicast still has outstanding
>member acks: tipc_group_bc_cong() returns true as long as
>grp->bc_ackers is non-zero, and clears *grp->open, which is what
>tipc_poll() uses to report EPOLLOUT (via tsk->group_is_open).
>
>When the last outstanding acker departs before acking,
>tipc_group_delete_member() decrements grp->bc_ackers to zero but never
>restores *grp->open. As a result poll(EPOLLOUT) never fires again. A writer
>blocked in sendmsg() is only released if some other wakeup happens after the
>deletion: with TIPC_GROUP_MEMBER_EVTS the leave event delivery calls
>sk_data_ready() and wakes it, but without member events nothing does and it
>sleeps indefinitely, since the default send timeout is
>MAX_SCHEDULE_TIMEOUT.
>
>Commit 99cc2a62e07a ("tipc: reject invalid and unexpected GRP_ACK_MSG to
>prevent bc_ackers underflow") already calls this out in its changelog as a pre-
>existing issue.
>
>Restore the open state exactly on the 1->0 transition in the delete path,
>mirroring the GRP_ACK_MSG completion path, and invoke
>sk->sk_write_space() from tipc_sk_filter_rcv() when the group just
>became writable again.
>
>Also make the ack accounting precise. The delete path used to test less(m-
>>bc_acked, grp->bc_snd_nxt - 1), which also matches members that were
>never counted for the current replicast (JOINING/LEAVING members keep a
>stale bc_acked), and the GRP_ACK_MSG handler accepted an ack from any
>member whose bc_acked differed from the expected value. Either could zero
>bc_ackers on behalf of a member that owes nothing and silently void an ack
>still owed by a real acker. Track whether a member owes an ack for the current
>replicast in a new per-member bc_pending flag, set when the member is
>counted and cleared when its ack arrives, and use it both to accept an ack and
>to decide on deletion. bc_acked has no remaining user and is removed.
>Suggested by Tung Quang Nguyen.
>
>This issue was discovered by Tencent CodeBuddy Security.
>
>Cc: stable@vger.kernel.org
>Fixes: 2f487712b893 ("tipc: guarantee that group broadcast doesn't bypass
>group unicast")
>Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
>---
>
>v3: Correct the changelog: tipc_group_bc_cong() only writes *grp->open,
> and a blocked sendmsg() hangs only when nothing wakes it after the
> deletion (e.g. member events disabled); also require bc_pending
> in the GRP_ACK_MSG handler so an uncounted member cannot decrement
> bc_ackers, and drop the now unused bc_acked field.
>
>v2: Subject no longer claims a leak; add the reproduction; the delete
> path now discriminates members that were actually counted for the
> current replicast via a new per-member bc_pending flag instead
> of comparing a possibly stale bc_acked (Tung Quang Nguyen).
>
>Reproduction (two QEMU guests, TIPC over UDP bearer, groups joined without
>member events; the acking peer withheld GRP_ACK_MSG via a test-only knob
>to emulate the lossy peer, the sender's kernel ran unmodified TIPC):
>
> UNPATCHED (#88/#90, fix absent):
> sender: NO POLLOUT for 30s after member departed -> STALL
> sender2: R2 NEVER returned in 32s (blocked writer not woken)
> PATCHED (#89, v1 of this patch):
> sender: POLLOUT at t=18.5s, when the leave event was delivered
> sender2: R2 returned at t=18.6s, EHOSTUNREACH on now-empty group
>
> net/tipc/group.c | 20 +++++++++++--------- net/tipc/socket.c | 12
>+++++++++++-
> 2 files changed, 22 insertions(+), 10 deletions(-)
>
>diff --git a/net/tipc/group.c b/net/tipc/group.c index
>74f6d3dac0784..b76edd5001ffa 100644
>--- a/net/tipc/group.c
>+++ b/net/tipc/group.c
>@@ -74,7 +74,7 @@ struct tipc_member {
> u16 window;
> u16 bc_rcv_nxt;
> u16 bc_syncpt;
>- u16 bc_acked;
>+ bool bc_pending;
> };
>
> struct tipc_group {
>@@ -316,7 +316,6 @@ static struct tipc_member
>*tipc_group_create_member(struct tipc_group *grp,
> m->node = node;
> m->port = port;
> m->instance = instance;
>- m->bc_acked = grp->bc_snd_nxt - 1;
> ret = tipc_group_add_to_tree(grp, m);
> if (ret < 0) {
> kfree(m);
>@@ -340,9 +339,12 @@ static void tipc_group_delete_member(struct
>tipc_group *grp,
> rb_erase(&m->tree_node, &grp->members);
> grp->member_cnt--;
>
>- /* Check if we were waiting for replicast ack from this member */
>- if (grp->bc_ackers && less(m->bc_acked, grp->bc_snd_nxt - 1))
>- grp->bc_ackers--;
>+ /* If this member owed an ack for the current replicast and it
>+ * was the last one, restore the open state so blocked broadcast
>+ * senders can proceed.
>+ */
>+ if (grp->bc_ackers && m->bc_pending && !--grp->bc_ackers)
>+ *grp->open = true;
>
> list_del_init(&m->list);
> list_del_init(&m->small_win);
>@@ -394,7 +396,6 @@ void tipc_group_update_member(struct tipc_member
>*m, int len)
>
> void tipc_group_update_bc_members(struct tipc_group *grp, int len, bool ack)
>{
>- u16 prev = grp->bc_snd_nxt - 1;
> struct tipc_member *m;
> struct rb_node *n;
> u16 ackers = 0;
>@@ -403,9 +404,10 @@ void tipc_group_update_bc_members(struct
>tipc_group *grp, int len, bool ack)
> m = container_of(n, struct tipc_member, tree_node);
> if (tipc_group_is_receiver(m)) {
> tipc_group_update_member(m, len);
>- m->bc_acked = prev;
> ackers++;
> }
>+ if (ack)
>+ m->bc_pending = tipc_group_is_receiver(m);
> }
Not sure if you read my comment for your v2:
" This needs to be done in a simple way:
@ -405,6 +405,7 @@ void tipc_group_update_bc_members(struct tipc_group *grp, int len, bool ack)
tipc_group_update_member(m, len);
m->bc_acked = prev;
ackers++;
+ m->bc_pending = ack;
}
}
>
"
--
pw-bot: cr
[PATCH net v4] tipc: fix broadcast sender hang on last acker departure
Author: Henry Martin
Date: Mon, 19 Oct 2026 11:58
Date: Mon, 19 Oct 2026 11:58
170 lines
14913 bytes
14913 bytes
TIPC group broadcast senders are blocked while a replicast still has
outstanding member acks: tipc_group_bc_cong() returns true as long as
grp->bc_ackers is non-zero, and clears *grp->open, which is what
tipc_poll() uses to report EPOLLOUT (via tsk->group_is_open).
When the last outstanding acker departs before acking,
tipc_group_delete_member() decrements grp->bc_ackers to zero but
never restores *grp->open. As a result poll(EPOLLOUT) never fires
again. A writer blocked in sendmsg() is only released if some other
wakeup happens after the deletion: with TIPC_GROUP_MEMBER_EVTS the
leave event delivery calls sk_data_ready() and wakes it, but without
member events nothing does and it sleeps indefinitely, since the
default send timeout is MAX_SCHEDULE_TIMEOUT.
Commit 99cc2a62e07a ("tipc: reject invalid and unexpected
GRP_ACK_MSG to prevent bc_ackers underflow") already calls this out
in its changelog as a pre-existing issue.
Restore the open state exactly on the 1->0 transition in the delete
path, mirroring the GRP_ACK_MSG completion path, and invoke
sk->sk_write_space() from tipc_sk_filter_rcv() when the group just
became writable again.
Also make the ack accounting precise. The delete path used to test
less(m->bc_acked, grp->bc_snd_nxt - 1), which also matches members
that were never counted for the current replicast (JOINING/LEAVING
members keep a stale bc_acked), and the GRP_ACK_MSG handler accepted
an ack from any member whose bc_acked differed from the expected
value. Either could zero bc_ackers on behalf of a member that owes
nothing and silently void an ack still owed by a real acker. Track
whether a member owes an ack for the current replicast in a new
per-member bc_pending flag, set when the member is counted and
cleared when its ack arrives, and use it both to accept an ack and
to decide on deletion. bc_acked has no remaining user and is
removed. Suggested by Tung Quang Nguyen.
This issue was discovered by Tencent CodeBuddy Security.
Cc: stable@vger.kernel.org
Fixes: 2f487712b893 ("tipc: guarantee that group broadcast doesn't bypass group unicast")
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
---
v4: Assign bc_pending inside the receiver loop body in the simple
form requested by Jon Maloy (m->bc_pending = ack); bc_ackers==0
implies no member has bc_pending set (a pending flag is cleared
either by the member's ack or by its deletion), so skipping
non-receivers cannot leave stale state.
v3: Correct the changelog: tipc_group_bc_cong() only writes *grp->open,
and a blocked sendmsg() hangs only when nothing wakes it after the
deletion (e.g. member events disabled); also require bc_pending
in the GRP_ACK_MSG handler so an uncounted member cannot decrement
bc_ackers, and drop the now unused bc_acked field.
v2: Subject no longer claims a leak; add the reproduction; the delete
path now discriminates members that were actually counted for the
current replicast via a new per-member bc_pending flag instead
of comparing a possibly stale bc_acked (Tung Quang Nguyen).
Reproduction (two QEMU guests, TIPC over UDP bearer, groups joined
without member events; the acking peer withheld GRP_ACK_MSG via a
test-only knob to emulate the lossy peer, the sender's kernel ran
unmodified TIPC):
UNPATCHED (#88/#90, fix absent):
sender: NO POLLOUT for 30s after member departed -> STALL
sender2: R2 NEVER returned in 32s (blocked writer not woken)
PATCHED (#89, v1 of this patch):
sender: POLLOUT at t=18.5s, when the leave event was delivered
sender2: R2 returned at t=18.6s, EHOSTUNREACH on now-empty group
net/tipc/group.c | 19 ++++++++++---------
net/tipc/socket.c | 12 +++++++++++-
2 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/net/tipc/group.c b/net/tipc/group.c
index 74f6d3dac0784..0c6a762000b02 100644
--- a/net/tipc/group.c
+++ b/net/tipc/group.c
@@ -74,7 +74,7 @@ struct tipc_member {
u16 window;
u16 bc_rcv_nxt;
u16 bc_syncpt;
- u16 bc_acked;
+ bool bc_pending;
};
struct tipc_group {
@@ -316,7 +316,6 @@ static struct tipc_member *tipc_group_create_member(struct tipc_group *grp,
m->node = node;
m->port = port;
m->instance = instance;
- m->bc_acked = grp->bc_snd_nxt - 1;
ret = tipc_group_add_to_tree(grp, m);
if (ret < 0) {
kfree(m);
@@ -340,9 +339,12 @@ static void tipc_group_delete_member(struct tipc_group *grp,
rb_erase(&m->tree_node, &grp->members);
grp->member_cnt--;
- /* Check if we were waiting for replicast ack from this member */
- if (grp->bc_ackers && less(m->bc_acked, grp->bc_snd_nxt - 1))
- grp->bc_ackers--;
+ /* If this member owed an ack for the current replicast and it
+ * was the last one, restore the open state so blocked broadcast
+ * senders can proceed.
+ */
+ if (grp->bc_ackers && m->bc_pending && !--grp->bc_ackers)
+ *grp->open = true;
list_del_init(&m->list);
list_del_init(&m->small_win);
@@ -394,7 +396,6 @@ void tipc_group_update_member(struct tipc_member *m, int len)
void tipc_group_update_bc_members(struct tipc_group *grp, int len, bool ack)
{
- u16 prev = grp->bc_snd_nxt - 1;
struct tipc_member *m;
struct rb_node *n;
u16 ackers = 0;
@@ -403,8 +404,8 @@ void tipc_group_update_bc_members(struct tipc_group *grp, int len, bool ack)
m = container_of(n, struct tipc_member, tree_node);
if (tipc_group_is_receiver(m)) {
tipc_group_update_member(m, len);
- m->bc_acked = prev;
ackers++;
+ m->bc_pending = ack;
}
}
@@ -800,9 +801,9 @@ void tipc_group_proto_rcv(struct tipc_group *grp, bool *usr_wakeup,
if (!m || !grp->bc_ackers)
return;
acked = msg_grp_bc_acked(hdr);
- if (acked != grp->bc_snd_nxt || m->bc_acked == acked)
+ if (acked != grp->bc_snd_nxt || !m->bc_pending)
return;
- m->bc_acked = acked;
+ m->bc_pending = false;
if (--grp->bc_ackers)
return;
list_del_init(&m->small_win);
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index d5d70eb230b56..65cc0c4964b31 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -2356,8 +2356,18 @@ static void tipc_sk_filter_rcv(struct sock *sk, struct sk_buff *skb,
if (unlikely(!msg_isdata(hdr)))
tipc_sk_proto_rcv(sk, &inputq, xmitq);
- if (unlikely(grp))
+ if (unlikely(grp)) {
+ bool was_open = tsk->group_is_open;
+
tipc_group_filter_msg(grp, &inputq, xmitq);
+ /* A departing member may have held the last outstanding
+ * replicast ack, which can restore the open state inside
+ * tipc_group_filter_msg(); wake up senders blocked in
+ * poll()/write() if the group just became writable.
+ */
+ if (!was_open && tsk->group_is_open)
+ sk->sk_write_space(sk);
+ }
if (unlikely(!grp) && mtyp == TIPC_MCAST_MSG)
tipc_mcast_filter_msg(net, &tsk->mc_method.deferredq, &inputq);
--
2.43.7
RE: [PATCH net v4] tipc: fix broadcast sender hang on last acker departure
Author: Tung Quang Nguyen
Date: Thu, 22 Oct 2026 01:11
Date: Thu, 22 Oct 2026 01:11
55 lines
19622 bytes
19622 bytes
>Subject: [PATCH net v4] tipc: fix broadcast sender hang on last acker departure
>
>TIPC group broadcast senders are blocked while a replicast still has outstanding
>member acks: tipc_group_bc_cong() returns true as long as
>grp->bc_ackers is non-zero, and clears *grp->open, which is what
>tipc_poll() uses to report EPOLLOUT (via tsk->group_is_open).
>
>When the last outstanding acker departs before acking,
>tipc_group_delete_member() decrements grp->bc_ackers to zero but never
>restores *grp->open. As a result poll(EPOLLOUT) never fires again. A writer
>blocked in sendmsg() is only released if some other wakeup happens after the
>deletion: with TIPC_GROUP_MEMBER_EVTS the leave event delivery calls
>sk_data_ready() and wakes it, but without member events nothing does and it
>sleeps indefinitely, since the default send timeout is
>MAX_SCHEDULE_TIMEOUT.
>
>Commit 99cc2a62e07a ("tipc: reject invalid and unexpected GRP_ACK_MSG to
>prevent bc_ackers underflow") already calls this out in its changelog as a pre-
>existing issue.
>
>Restore the open state exactly on the 1->0 transition in the delete path,
>mirroring the GRP_ACK_MSG completion path, and invoke
>sk->sk_write_space() from tipc_sk_filter_rcv() when the group just
>became writable again.
>
>Also make the ack accounting precise. The delete path used to test less(m-
>>bc_acked, grp->bc_snd_nxt - 1), which also matches members that were
>never counted for the current replicast (JOINING/LEAVING members keep a
>stale bc_acked), and the GRP_ACK_MSG handler accepted an ack from any
>member whose bc_acked differed from the expected value. Either could zero
>bc_ackers on behalf of a member that owes nothing and silently void an ack
>still owed by a real acker. Track whether a member owes an ack for the current
>replicast in a new per-member bc_pending flag, set when the member is
>counted and cleared when its ack arrives, and use it both to accept an ack and
>to decide on deletion. bc_acked has no remaining user and is removed.
>Suggested by Tung Quang Nguyen.
>
>This issue was discovered by Tencent CodeBuddy Security.
>
>Cc: stable@vger.kernel.org
>Fixes: 2f487712b893 ("tipc: guarantee that group broadcast doesn't bypass
>group unicast")
>Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
Reviewed-by: Tung Nguyen <tung.quang.nguyen@est.tech>
Re: [PATCH net v4] tipc: fix broadcast sender hang on last acker departure
Author: patchwork-bot+netdevbpf
Date: Thu, 22 Oct 2026 09:10
Date: Thu, 22 Oct 2026 09:10
31 lines
9210 bytes
9210 bytes
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Mon, 19 Oct 2026 19:58:59 +0800 you wrote:
> TIPC group broadcast senders are blocked while a replicast still has
> outstanding member acks: tipc_group_bc_cong() returns true as long as
> grp->bc_ackers is non-zero, and clears *grp->open, which is what
> tipc_poll() uses to report EPOLLOUT (via tsk->group_is_open).
>
> When the last outstanding acker departs before acking,
> tipc_group_delete_member() decrements grp->bc_ackers to zero but
> never restores *grp->open. As a result poll(EPOLLOUT) never fires
> again. A writer blocked in sendmsg() is only released if some other
> wakeup happens after the deletion: with TIPC_GROUP_MEMBER_EVTS the
> leave event delivery calls sk_data_ready() and wakes it, but without
> member events nothing does and it sleeps indefinitely, since the
> default send timeout is MAX_SCHEDULE_TIMEOUT.
>
> [...]
Here is the summary with links:
- [net,v4] tipc: fix broadcast sender hang on last acker departure
https://git.kernel.org/netdev/net/c/f4377bf85887
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads