From: netdev-bot+sashiko@kernel.org
To: tung.quang.nguyen@est.tech
Cc: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
edumazet@kernel.org, pabeni@redhat.com, jmaloy@redhat.com,
horms@kernel.org, tipc-discussion@lists.sourceforge.net,
syzbot+64197f7577a09686ffdb@syzkaller.appspotmail.com,
lkp@intel.com
Subject: Re: [PATCH net v3 4/7] tipc: fix missing link-up event on memory allocation failure
Date: Tue, 17 Nov 2026 18:37:54 +0000 [thread overview]
Message-ID: <179494067499.3136.17991206184972687844@kernel.org> (raw)
In-Reply-To: <20261116063529.6185-5-tung.quang.nguyen@est.tech>
Thank you for your contribution! Sashiko AI review found 5 potential
issue(s) to consider.
Critical: 2 · High: 0 · Medium: 2 · 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).
- [Critical] The new duplicate (-EEXIST) error path in
tipc_service_insert_publ() (net/tipc/name_table.c) erases and kfree()s…
- [Critical] The fault introduced by the -EEXIST free in
tipc_service_insert_publ() leads to a remotely triggerable infinite…
- [Medium] In tipc_rcv() (net/tipc/node.c), the new code after
tipc_node_write_unlock() takes the node read lock again and purges…
- [Medium] The commit message describes only plumbing an error code out
of tipc_nametbl_publish() and resetting the link on -ENOBUFS.
- [Low] tipc_node_write_unlock() (net/tipc/node.c) reads bearer_id =
n->link_id & 0xffff while holding n->lock, then calls…
--
tipc: fix missing link-up event on memory allocation failure
This patch adds an int *err output parameter so tipc_nametbl_insert_publ()
and tipc_nametbl_publish() can report errors. If the TIPC_LINK_STATE
publication fails with -ENOBUFS in tipc_node_write_unlock(), the link is
reset so the publication can be retried. It also adds cleanup of the
service range and service on failure, and an xmitq purge in tipc_rcv().
> Fix this issue by checking the error code returned through the
> output parameter of tipc_nametbl_publish(). If the error indicates
> a memory allocation failure, reset the link so that the
> TIPC_LINK_STATE publication can be retried.
[ ... ]
> v3:
> - Free sr in tipc_service_insert_publ() on memory allocation failure.
> - Free sc in tipc_service_find() on memory allocation failure.
> - Purge xmitq in tipc_rcv() in case tipc_node_write_unlock() resets a bearer.
[Severity: Medium]
The commit message only describes passing the error code out of
tipc_nametbl_publish() and resetting the link on -ENOBUFS. The patch
also:
- adds an xmitq purge in the tipc_rcv() slow path
- tears down a newly created tipc_service (hlist_del_init_rcu() plus
kfree_rcu()) in tipc_nametbl_insert_publ()
- adds -EEXIST handling in tipc_service_insert_publ() that frees sr
- changes the pr_err() in tipc_nametbl_remove_publ() to
pr_warn_ratelimited() with different text, and ratelimits the bind
failure warning
- makes tipc_nametbl_publish() report -ENOBUFS but still return the
inserted publication when the cluster-scope distribution skb can't be
allocated
These changes are only mentioned in the v3 notes below the --- line,
and those notes are not kept in git history.
The notes also don't seem to match the code. The sc teardown is in
tipc_nametbl_insert_publ(), not tipc_service_find(). The sr free happens
on -EEXIST, when sr is live, rather than on allocation failure, when sr
is NULL.
Could the commit message describe these changes?
> diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
> index 73b032ba2f8d0..e8b768699ab93 100644
> --- a/net/tipc/name_table.c
> +++ b/net/tipc/name_table.c
[ ... ]
> @@ -353,6 +356,9 @@ static bool tipc_service_insert_publ(struct net *net,
> pr_debug("Failed to bind duplicate %u,%u,%u/%u:%u/%u\n",
> p->sr.type, p->sr.lower, p->sr.upper,
> node, p->sk.ref, key);
> + if (err)
> + *err = -EEXIST;
> +
> goto exit;
> }
> }
> @@ -368,9 +374,15 @@ static bool tipc_service_insert_publ(struct net *net,
> }
> res = true;
> exit:
> - if (!res)
> - pr_warn("Failed to bind to %u,%u,%u\n",
> - p->sr.type, p->sr.lower, p->sr.upper);
> + if (!res) {
> + if (err && *err == -EEXIST) {
> + rb_erase_augmented(&sr->tree_node, &sc->ranges,
> + &sr_callbacks);
> + kfree(sr);
> + }
[Severity: Critical]
Can this free a live service_range that still holds publications?
-EEXIST is only set after a matching _p is found in sr->all_publ, so sr
is not empty at this point. Also, tipc_service_create_range() returns the
existing range when lower and upper match exactly:
if (lower == sr->lower && upper == sr->upper)
return sr;
So a freshly allocated sr, whose all_publ is empty, never reaches this
branch.
When it triggers, every binding in the range silently disappears from
the name table, and subscribers get no TIPC_WITHDRAWN event.
The orphaned publications still have all_publ and local_publ pointing
into the freed sr. Later withdrawals fail in tipc_service_find_range(),
so the publications leak, and nt->local_publ_count is never decremented
for local ones.
A remote peer can reach this, because tipc_update_nametbl() now passes a
non-NULL &err:
tipc_named_rcv()
tipc_update_nametbl()
tipc_nametbl_insert_publ(net, &ua, &sk, key, &err)
tipc_service_insert_publ()
One bulk or legacy NAME_DISTRIBUTOR message carrying two identical
PUBLICATION items looks sufficient, since those messages bypass the
seqno filter in tipc_named_dequeue(). The peer could then re-publish the
range and become its only destination.
The v3 note says sr is freed "on memory allocation failure", but on
-ENOBUFS sr is NULL and there is nothing to free. Is this block needed
at all?
The problem seems to remain at the end of the series. The later commit
"tipc: fix NULL pointer dereference in named_distribute()" treats
-EEXIST from tipc_nametbl_insert_publ() as an expected result for the
self-node publication, and that result goes through this same path.
[Severity: Critical]
Following on from the above, can this also cause an infinite loop in
tipc_publ_notify()?
Suppose a peer sends the same item X three times. All three can be in a
single bulk message:
1. X is inserted as p_old, and tipc_node_subscribe() adds p_old to
n->publ_list.
2. The second X hits -EEXIST and sr is freed. p_old is orphaned but
stays on n->publ_list.
3. The third X gets a fresh, empty sr2 from tipc_service_create_range()
and passes the duplicate check. It is inserted as p2, which lands
right after p_old on n->publ_list.
Before this patch the third insert was rejected, so p_old and p2 could
not exist at the same time.
When the peer then brings the node down:
tipc_node_write_unlock()
tipc_publ_notify()
/* publ = p_old, tmp = p2 */
list_for_each_entry_safe(publ, tmp, nsub_list, binding_node)
tipc_publ_purge(net, p_old, addr)
tipc_nametbl_remove_publ() /* returns p2, not p_old */
tipc_node_unsubscribe() /* list_del_init(&p2->binding_node) */
kfree_rcu(p2, rcu)
On the next iteration publ is p2. Because p2->binding_node was
list_del_init()'d, list_next_entry(p2) is p2 itself, so the loop never
gets back to the list head.
If this runs from tipc_rcv() or tipc_node_timeout() in softirq, the CPU
livelocks.
On preemptible RCU kernels, it can also run from process context, for
example bearer disable via netlink -> tipc_node_link_down() ->
tipc_node_write_unlock(). There the grace period could end while the
loop is still dereferencing p2, which would be a use-after-free.
The address validation added later in the series doesn't seem to block
this, because the peer uses its own valid node address.
[ ... ]
> diff --git a/net/tipc/node.c b/net/tipc/node.c
> index d84b0274fefc4..870f84e2fb1c4 100644
> --- a/net/tipc/node.c
> +++ b/net/tipc/node.c
[ ... ]
> @@ -429,12 +430,15 @@ static void tipc_node_write_unlock(struct tipc_node *n)
>
> if (flags & TIPC_NOTIFY_LINK_UP) {
> tipc_mon_peer_up(net, node, bearer_id);
> - tipc_nametbl_publish(net, &ua, &sk, sk.ref);
> + tipc_nametbl_publish(net, &ua, &sk, sk.ref, &err);
> }
> if (flags & TIPC_NOTIFY_LINK_DOWN) {
> tipc_mon_peer_down(net, node, bearer_id);
> tipc_nametbl_withdraw(net, &ua, &sk, sk.ref);
> }
> +
> + if (err == -ENOBUFS)
> + tipc_node_link_down(n, bearer_id, false);
[Severity: Low]
Does bearer_id still refer to the same link instance at this point?
bearer_id was read from n->link_id while n->lock was held, but the lock
is dropped before tipc_nametbl_publish() runs.
In that window, tipc_node_timeout(), a parallel tipc_rcv() or a bearer
reset could take the link down and bring it back up with a new session.
That new link-up's own LINK_STATE publication may succeed.
tipc_node_link_down() only checks that a link exists on the bearer:
le = &n->links[bearer_id];
l = le->link;
if (!l) {
tipc_node_write_unlock_fast(n);
return;
}
So this could reset the healthy, re-established link, or defuse its
pending link-up, and send TIPC_LINK_STATE subscribers a spurious
down/up. Should the reset be tied to the link instance whose publication
failed?
[ ... ]
> @@ -2193,6 +2197,16 @@ void tipc_rcv(struct net *net, struct sk_buff *skb, struct tipc_bearer *b)
> }
> }
> tipc_node_write_unlock(n);
> +
> + /* tipc_node_link_down() was called in
> + * tipc_node_write_unlock().
> + */
> + tipc_node_read_lock(n);
> + le = &n->links[bearer_id];
> + if (le->link && !tipc_link_is_up(le->link) &&
> + !skb_queue_empty(&xmitq))
> + __skb_queue_purge(&xmitq);
> + tipc_node_read_unlock(n);
[Severity: Medium]
Is this purge limited to the case where tipc_node_write_unlock()
actually reset the link?
tipc_node_write_unlock() returns void, so the condition here only checks
the current link state.
This slow path runs whenever n->state != SELF_UP_PEER_UP or
usr == TUNNEL_PROTOCOL. That covers establishment, failover and synch,
when the link is often legitimately not up.
For example, tipc_link_proto_rcv() returns TIPC_LINK_UP_EVT while the
link is still establishing:
/* ACTIVATE_MSG takes up link if it was already locally reset */
if (mtyp == ACTIVATE_MSG && l->state == LINK_ESTABLISHING)
rc = TIPC_LINK_UP_EVT;
The link only becomes up later, in tipc_node_link_up(), which runs after
this purge.
Could this drop messages that tipc_node_check_state() or
tipc_node_bc_sync_rcv() queued earlier on this path? One example is the
RESET_MSG that __tipc_node_link_down() builds for a parallel link when a
FAILOVER_MSG arrives on a link that is still establishing.
Another CPU could also change the link state between the write unlock
and the read lock, for example on a link timeout or bearer reset.
tipc_link_is_up() also reads l->state under only the node read lock,
while fast-path receivers on other CPUs modify it under the read lock
plus le->lock.
> }
>
> if (unlikely(rc & TIPC_LINK_UP_EVT))
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116063529.6185-1-tung.quang.nguyen%40est.tech
next prev parent reply other threads:[~2026-11-17 18:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 6:34 [PATCH net v3 0/7] tipc: fix deadlock and NUll pointer dereference in tipc_named_node_up() Tung Nguyen
2026-11-16 6:34 ` [PATCH net v3 1/7] tipc: fix memory leak in tipc_node_xmit() Tung Nguyen
2026-11-16 6:34 ` [PATCH net v3 2/7] tipc: fix dangling link in cluster_scope list in tipc_service_delete() Tung Nguyen
2026-11-17 18:37 ` netdev-bot+sashiko
2026-11-16 6:34 ` [PATCH net v3 3/7] tipc: fix incorrect initialization of replicast node counter Tung Nguyen
2026-11-16 6:34 ` [PATCH net v3 4/7] tipc: fix missing link-up event on memory allocation failure Tung Nguyen
2026-11-17 18:37 ` netdev-bot+sashiko [this message]
2026-11-16 6:34 ` [PATCH net v3 5/7] tipc: validate original address of received skb in tipc_named_rcv() Tung Nguyen
2026-11-17 18:37 ` netdev-bot+sashiko
2026-11-16 6:34 ` [PATCH net v3 6/7] tipc: fix self-deadlock in tipc_named_node_up Tung Nguyen
2026-11-17 18:37 ` netdev-bot+sashiko
2026-11-16 6:34 ` [PATCH net v3 7/7] tipc: fix NULL pointer dereference in named_distribute() Tung Nguyen
2026-11-17 18:37 ` netdev-bot+sashiko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179494067499.3136.17991206184972687844@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=horms@kernel.org \
--cc=jmaloy@redhat.com \
--cc=kuba@kernel.org \
--cc=lkp@intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=syzbot+64197f7577a09686ffdb@syzkaller.appspotmail.com \
--cc=tipc-discussion@lists.sourceforge.net \
--cc=tung.quang.nguyen@est.tech \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox