* [PATCH net v3 1/7] tipc: fix memory leak in tipc_node_xmit()
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 ` 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
` (5 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Tung Nguyen @ 2026-11-16 6:34 UTC (permalink / raw)
To: netdev
Cc: davem, kuba, edumazet, pabeni, jmaloy, horms, tipc-discussion,
Tung Nguyen
The following memory leak can occur, as identified during code inspection:
tipc_node_xmit()
tipc_link_xmit(le->link, list, &xmitq)
...
__skb_queue_purge(list);
return -ENOBUFS;
tipc_link_xmit() purges list but does not purge xmitq. tipc_node_xmit() does not
purge xmitq either, resulting in a memory leak.
Fix this issue by purging xmitq in tipc_node_xmit() when tipc_link_xmit()
returns -ENOBUFS.
Fixes: 4952cd3e7b47 ("tipc: refactor node xmit and fix memory leaks")
Signed-off-by: Tung Nguyen <tung.quang.nguyen@est.tech>
---
v3: no change
net/tipc/node.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 53b0993c2c23..d84b0274fefc 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -1747,10 +1747,13 @@ int tipc_node_xmit(struct net *net, struct sk_buff_head *list,
spin_unlock_bh(&le->lock);
tipc_node_read_unlock(n);
- if (unlikely(rc == -ENOBUFS))
+ if (unlikely(rc == -ENOBUFS)) {
+ if (!skb_queue_empty(&xmitq))
+ __skb_queue_purge(&xmitq);
tipc_node_link_down(n, bearer_id, false);
- else
+ } else {
tipc_bearer_xmit(net, bearer_id, &xmitq, &le->maddr, n);
+ }
tipc_node_put(n);
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH net v3 2/7] tipc: fix dangling link in cluster_scope list in tipc_service_delete()
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 ` 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
` (4 subsequent siblings)
6 siblings, 1 reply; 13+ messages in thread
From: Tung Nguyen @ 2026-11-16 6:34 UTC (permalink / raw)
To: netdev
Cc: davem, kuba, edumazet, pabeni, jmaloy, horms, tipc-discussion,
Tung Nguyen
The TIPC name table uses the cluster_scope list to store the
following publications:
- User publications with cluster scope from the local node:
__tipc_bind()
tipc_sk_publish()
tipc_nametbl_publish()
tipc_named_publish()
list_add_tail(&p->binding_node, &nt->cluster_scope)
list_add(&p->binding_sock, &tsk->publications)
- Protocol publications of type TIPC_NODE_STATE (0) with cluster
scope from the local node:
tipc_net_finalize()
tipc_nametbl_publish()
tipc_named_publish()
list_add_tail(&p->binding_node, &nt->cluster_scope)
When a network namespace is destroyed:
- User publications with cluster scope from the local node are removed
through the following call path:
tipc_release()
tipc_sk_withdraw()
list_for_each_entry_safe(p, safe, &tsk->publications, binding_sock)
tipc_nametbl_withdraw()
tipc_named_withdraw()
list_del(&p->binding_node)
- However, code inspection revealed that tipc_service_delete() does not
remove self-node TIPC_NODE_STATE publication from the cluster_scope list,
leaving dangling list entries:
tipc_service_delete()
list_for_each_entry_safe()
tipc_service_remove_publ()
kfree_rcu(p, rcu);
Fix this by calling list_del() before freeing TIPC_NODE_STATE
publications in tipc_service_delete().
Fixes: 1bb8dce57f4d ("tipc: fix memory leak during module removal")
Signed-off-by: Tung Nguyen <tung.quang.nguyen@est.tech>
---
v3: no change
net/tipc/name_table.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index 6fda36ab1766..73b032ba2f8d 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -934,6 +934,7 @@ int tipc_nametbl_init(struct net *net)
*/
static void tipc_service_delete(struct net *net, struct tipc_service *sc)
{
+ struct tipc_net *tn = tipc_net(net);
struct service_range *sr, *tmpr;
struct publication *p, *tmp;
@@ -941,6 +942,13 @@ static void tipc_service_delete(struct net *net, struct tipc_service *sc)
rbtree_postorder_for_each_entry_safe(sr, tmpr, &sc->ranges, tree_node) {
list_for_each_entry_safe(p, tmp, &sr->all_publ, all_publ) {
tipc_service_remove_publ(sr, &p->sk, p->key);
+ if (p->sr.type == TIPC_NODE_STATE &&
+ p->sr.lower == tn->node_addr &&
+ p->sr.upper == tn->node_addr &&
+ p->key == tn->node_addr &&
+ p->sk.ref == 0 && p->sk.node == tn->node_addr)
+ list_del(&p->binding_node);
+
kfree_rcu(p, rcu);
}
rb_erase_augmented(&sr->tree_node, &sc->ranges, &sr_callbacks);
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH net v3 2/7] tipc: fix dangling link in cluster_scope list in tipc_service_delete()
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
0 siblings, 0 replies; 13+ messages in thread
From: netdev-bot+sashiko @ 2026-11-17 18:37 UTC (permalink / raw)
To: tung.quang.nguyen
Cc: netdev, davem, kuba, edumazet, pabeni, jmaloy, horms,
tipc-discussion, syzbot+64197f7577a09686ffdb, lkp
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message presents this change as a bug fix and carries
a Fixes: tag (1bb8dce57f4d), but it names no consequence anyone could…
--
tipc: fix dangling link in cluster_scope list in tipc_service_delete()
This patch makes tipc_service_delete() remove the local node's own
TIPC_NODE_STATE publication from nt->cluster_scope before it is freed
with kfree_rcu(). The commit message calls the leftover entry a
dangling list entry and adds a Fixes: tag for 1bb8dce57f4d.
> diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
> index 6fda36ab17669..73b032ba2f8d0 100644
> --- a/net/tipc/name_table.c
> +++ b/net/tipc/name_table.c
[ ... ]
> @@ -941,6 +942,13 @@ static void tipc_service_delete(struct net *net, struct tipc_service *sc)
> rbtree_postorder_for_each_entry_safe(sr, tmpr, &sc->ranges, tree_node) {
> list_for_each_entry_safe(p, tmp, &sr->all_publ, all_publ) {
> tipc_service_remove_publ(sr, &p->sk, p->key);
> + if (p->sr.type == TIPC_NODE_STATE &&
> + p->sr.lower == tn->node_addr &&
> + p->sr.upper == tn->node_addr &&
> + p->key == tn->node_addr &&
> + p->sk.ref == 0 && p->sk.node == tn->node_addr)
> + list_del(&p->binding_node);
> +
> kfree_rcu(p, rcu);
> }
> rb_erase_augmented(&sr->tree_node, &sc->ranges, &sr_callbacks);
[Severity: Low]
Can anything actually reach the leftover cluster_scope entry?
tipc_service_delete() is only called from tipc_nametbl_stop(). That
function frees the name table, including the cluster_scope list head,
right after the purge loop:
net/tipc/name_table.c:tipc_nametbl_stop() {
...
spin_unlock_bh(&tn->nametbl_lock);
/* TODO: clear tn->nametbl, implement proper RCU rules ? */
kfree_rcu(nt, rcu);
}
tipc_nametbl_stop() is called from the tipc_init_net() error path and
from tipc_exit_net():
net/tipc/core.c:tipc_exit_net() {
...
tipc_net_stop(net);
/* Make sure the tipc_net_finalize_work() finished */
cancel_work_sync(&tn->work);
tipc_bcast_stop(net);
tipc_nametbl_stop(net);
...
}
By that point tipc_net_stop() has already removed the bearers and
nodes, so tipc_named_node_up() can't run. cancel_work_sync() has
stopped tn->work, so tipc_named_reinit() can't run either.
tipc_named_publish() and tipc_named_withdraw() only run from socket
operations.
Is there a path that walks nt->cluster_scope between the purge and
kfree_rcu(nt, rcu), or after it?
If there isn't, this looks like cleanup at teardown rather than a fix
for a bug that can be hit. Should the commit message describe a failure
that can be observed? If not, could it present this as cleanup and drop
the Fixes: tag, so stable trees don't pick it up?
Separately, the commit message says:
Fix this by calling list_del() before freeing TIPC_NODE_STATE
publications in tipc_service_delete().
The code only removes the local node's own publication: type
TIPC_NODE_STATE, lower == upper == key == sk.node == tn->node_addr, and
sk.ref == 0. Remote TIPC_NODE_STATE publications are left alone. That
looks correct, because their binding_node sits on the peer node's
publ_list.
Could that sentence name the self-node publication specifically?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116063529.6185-1-tung.quang.nguyen%40est.tech
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net v3 3/7] tipc: fix incorrect initialization of replicast node counter
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-16 6:34 ` Tung Nguyen
2026-11-16 6:34 ` [PATCH net v3 4/7] tipc: fix missing link-up event on memory allocation failure Tung Nguyen
` (3 subsequent siblings)
6 siblings, 0 replies; 13+ messages in thread
From: Tung Nguyen @ 2026-11-16 6:34 UTC (permalink / raw)
To: netdev
Cc: davem, kuba, edumazet, pabeni, jmaloy, horms, tipc-discussion,
Tung Nguyen, lkp
The TIPC name table uses rc_dests to track the number of nodes
available for replicast transmission. This counter is used to decide
whether to use broadcast or replicast links when sending bulk messages.
However, code inspection revealed a race between tipc_net_finalize(),
which initializes rc_dests, and tipc_named_node_up(), which
increments it, as illustrated below:
Thread 1 (tipc_net_finalize) | Thread 2 (tipc_named_node_up)
| ...
| nt->rc_dests++;
... |
tipc_named_reinit() |
nt->rc_dests = 0; |
If tipc_named_reinit() (Thread 1) executes after nt->rc_dests++
(Thread 2), the counter will be reset to zero. As a result, two
unexpected behaviors can occur:
1. User publications are sent via the broadcast link instead of the
replicast link:
tipc_sk_publish()
tipc_nametbl_publish()
tipc_node_broadcast()
if (!rc_dests && tipc_bcast_get_mode(net) != BCLINK_MODE_RCAST)
tipc_bcast_xmit()
2. nt->rc_dests can underflow to -1 when the node goes down. As a
result, publications are sent via the replicast link even though no
replicast nodes are available:
tipc_publ_notify()
nt->rc_dests--;
Fix this issue by removing initialization of nt->rc_dests in
tipc_named_reinit().
Fixes: cad2929dc432 ("tipc: update a binding service via broadcast")
Cc: lkp@intel.com
Signed-off-by: Tung Nguyen <tung.quang.nguyen@est.tech>
---
v3:
- Add Cc: lkp@intel.com to the changelog to address a warning.
- Remove the unnecessary nt->rc_dests = 0 assignment from
tipc_nametbl_init().
v2: https://lore.kernel.org/netdev/20261102034207.10639-4-tung.quang.nguyen@est.tech/
net/tipc/name_distr.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
index ba4f4906e13b..1dfe8475a75d 100644
--- a/net/tipc/name_distr.c
+++ b/net/tipc/name_distr.c
@@ -415,6 +415,5 @@ void tipc_named_reinit(struct net *net)
p->sk.node = self;
list_for_each_entry_rcu(p, &nt->cluster_scope, binding_node)
p->sk.node = self;
- nt->rc_dests = 0;
spin_unlock_bh(&tn->nametbl_lock);
}
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* [PATCH net v3 4/7] tipc: fix missing link-up event on memory allocation failure
2026-11-16 6:34 [PATCH net v3 0/7] tipc: fix deadlock and NUll pointer dereference in tipc_named_node_up() Tung Nguyen
` (2 preceding siblings ...)
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 ` Tung Nguyen
2026-11-17 18:37 ` netdev-bot+sashiko
2026-11-16 6:34 ` [PATCH net v3 5/7] tipc: validate original address of received skb in tipc_named_rcv() Tung Nguyen
` (2 subsequent siblings)
6 siblings, 1 reply; 13+ messages in thread
From: Tung Nguyen @ 2026-11-16 6:34 UTC (permalink / raw)
To: netdev
Cc: davem, kuba, edumazet, pabeni, jmaloy, horms, tipc-discussion,
Tung Nguyen
When a new TIPC link comes up, a protocol publication of type
TIPC_LINK_STATE (2) is created and inserted into the name table
through the following call path:
tipc_node_write_unlock()
tipc_nametbl_publish()
tipc_nametbl_insert_publ()
User applications subscribing to this TIPC_LINK_STATE event will
be notified when the link comes up. However, code inspection
revealed that if tipc_nametbl_insert_publ() fails due to a memory
allocation error, the TIPC_LINK_STATE publication is not inserted
into the name table. As a result, user applications are never
notified of the link-up event.
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.
Fixes: b97bf3fd8f6a ("[TIPC] Initial merge")
Signed-off-by: Tung Nguyen <tung.quang.nguyen@est.tech>
---
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.
v2: https://lore.kernel.org/netdev/20261102034207.10639-5-tung.quang.nguyen@est.tech/
net/tipc/name_distr.c | 3 +-
net/tipc/name_table.c | 74 +++++++++++++++++++++++++++++++++----------
net/tipc/name_table.h | 5 +--
net/tipc/net.c | 3 +-
net/tipc/node.c | 16 +++++++++-
net/tipc/socket.c | 3 +-
6 files changed, 82 insertions(+), 22 deletions(-)
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
index 1dfe8475a75d..3ea5e900cb45 100644
--- a/net/tipc/name_distr.c
+++ b/net/tipc/name_distr.c
@@ -285,6 +285,7 @@ static bool tipc_update_nametbl(struct net *net, struct distr_item *i,
struct tipc_socket_addr sk;
u32 key = ntohl(i->key);
struct tipc_uaddr ua;
+ int err = 0;
/* A peer-advertised binding with lower > upper can never be matched
* or withdrawn and would leak the publication; the local bind path
@@ -299,7 +300,7 @@ static bool tipc_update_nametbl(struct net *net, struct distr_item *i,
sk.node = node;
if (dtype == PUBLICATION) {
- p = tipc_nametbl_insert_publ(net, &ua, &sk, key);
+ p = tipc_nametbl_insert_publ(net, &ua, &sk, key, &err);
if (p) {
tipc_node_subscribe(net, &p->binding_node, node);
return true;
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index 73b032ba2f8d..e8b768699ab9 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -329,7 +329,7 @@ static struct service_range *tipc_service_create_range(struct tipc_service *sc,
static bool tipc_service_insert_publ(struct net *net,
struct tipc_service *sc,
- struct publication *p)
+ struct publication *p, int *err)
{
struct tipc_subscription *sub, *tmp;
struct service_range *sr;
@@ -341,8 +341,11 @@ static bool tipc_service_insert_publ(struct net *net,
spin_lock_bh(&sc->lock);
sr = tipc_service_create_range(sc, p);
- if (!sr)
- goto exit;
+ if (!sr) {
+ if (err)
+ *err = -ENOBUFS;
+ goto exit;
+ }
first = list_empty(&sr->all_publ);
@@ -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);
+ }
+ pr_warn_ratelimited("Failed to bind to %u,%u,%u\n",
+ p->sr.type, p->sr.lower, p->sr.upper);
+ }
spin_unlock_bh(&sc->lock);
return res;
}
@@ -478,20 +490,40 @@ static struct tipc_service *tipc_service_find(struct net *net,
struct publication *tipc_nametbl_insert_publ(struct net *net,
struct tipc_uaddr *ua,
struct tipc_socket_addr *sk,
- u32 key)
+ u32 key, int *err)
{
+ bool service_created = false;
struct tipc_service *sc;
struct publication *p;
p = tipc_publ_create(ua, sk, key);
- if (!p)
+ if (!p) {
+ if (err)
+ *err = -ENOBUFS;
return NULL;
+ }
sc = tipc_service_find(net, ua);
- if (!sc)
+
+ if (!sc) {
sc = tipc_service_create(net, ua);
- if (sc && tipc_service_insert_publ(net, sc, p))
- return p;
+ service_created = true;
+ }
+
+ if (sc) {
+ if (tipc_service_insert_publ(net, sc, p, err))
+ return p;
+
+ spin_lock_bh(&sc->lock);
+ if (service_created && err && *err == -ENOBUFS) {
+ hlist_del_init_rcu(&sc->service_list);
+ kfree_rcu(sc, rcu);
+ }
+ spin_unlock_bh(&sc->lock);
+ } else if (err) {
+ *err = -ENOBUFS;
+ }
+
kfree(p);
return NULL;
}
@@ -540,9 +572,9 @@ struct publication *tipc_nametbl_remove_publ(struct net *net,
spin_unlock_bh(&sc->lock);
exit:
if (!p) {
- pr_err("Failed to remove unknown binding: %u,%u,%u/%u:%u/%u\n",
- ua->sr.type, ua->sr.lower, ua->sr.upper,
- sk->node, sk->ref, key);
+ pr_warn_ratelimited("Remove unknown pub: %u,%u,%u/%u:%u/%u\n",
+ ua->sr.type, ua->sr.lower, ua->sr.upper,
+ sk->node, sk->ref, key);
}
return p;
}
@@ -760,7 +792,8 @@ void tipc_nametbl_build_group(struct net *net, struct tipc_group *grp,
/* tipc_nametbl_publish - add service binding to name table
*/
struct publication *tipc_nametbl_publish(struct net *net, struct tipc_uaddr *ua,
- struct tipc_socket_addr *sk, u32 key)
+ struct tipc_socket_addr *sk,
+ u32 key, int *err)
{
struct name_table *nt = tipc_name_table(net);
u32 max_user_pub = TIPC_MAX_PUBL - 1;
@@ -768,6 +801,7 @@ struct publication *tipc_nametbl_publish(struct net *net, struct tipc_uaddr *ua,
struct publication *p = NULL;
struct sk_buff *skb = NULL;
bool protocol_type = false;
+ int error = 0;
u32 rc_dests;
if (ua->sr.type == TIPC_NODE_STATE || ua->sr.type == TIPC_LINK_STATE ||
@@ -788,7 +822,7 @@ struct publication *tipc_nametbl_publish(struct net *net, struct tipc_uaddr *ua,
}
insert:
- p = tipc_nametbl_insert_publ(net, ua, sk, key);
+ p = tipc_nametbl_insert_publ(net, ua, sk, key, &error);
if (p) {
/* Not count node state, link state and topology server types
* so that maximum nt->local_publ_count does not prevent
@@ -798,6 +832,14 @@ struct publication *tipc_nametbl_publish(struct net *net, struct tipc_uaddr *ua,
if (!protocol_type)
nt->local_publ_count++;
skb = tipc_named_publish(net, p);
+ /* Local-scope publication is not published (skb is NULL).
+ * For cluster-cope one, skb is NULL when named_prepare_buf()
+ * returns NULL in tipc_named_publish().
+ */
+ if (!skb && p->scope == TIPC_CLUSTER_SCOPE && err)
+ *err = -ENOBUFS;
+ } else if ((error == -ENOBUFS) && err) {
+ *err = -ENOBUFS;
}
rc_dests = nt->rc_dests;
exit:
diff --git a/net/tipc/name_table.h b/net/tipc/name_table.h
index 7ff6eeebaae6..3a15dcfcc2cd 100644
--- a/net/tipc/name_table.h
+++ b/net/tipc/name_table.h
@@ -126,13 +126,14 @@ bool tipc_nametbl_lookup_group(struct net *net, struct tipc_uaddr *ua,
void tipc_nametbl_build_group(struct net *net, struct tipc_group *grp,
struct tipc_uaddr *ua);
struct publication *tipc_nametbl_publish(struct net *net, struct tipc_uaddr *ua,
- struct tipc_socket_addr *sk, u32 key);
+ struct tipc_socket_addr *sk,
+ u32 key, int *err);
void tipc_nametbl_withdraw(struct net *net, struct tipc_uaddr *ua,
struct tipc_socket_addr *sk, u32 key);
struct publication *tipc_nametbl_insert_publ(struct net *net,
struct tipc_uaddr *ua,
struct tipc_socket_addr *sk,
- u32 key);
+ u32 key, int *err);
struct publication *tipc_nametbl_remove_publ(struct net *net,
struct tipc_uaddr *ua,
struct tipc_socket_addr *sk,
diff --git a/net/tipc/net.c b/net/tipc/net.c
index 7e65d0b0c4a8..82f6d2f6ab89 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -128,6 +128,7 @@ static void tipc_net_finalize(struct net *net, u32 addr)
struct tipc_net *tn = tipc_net(net);
struct tipc_socket_addr sk = {0, addr};
struct tipc_uaddr ua;
+ int err = 0;
tipc_uaddr(&ua, TIPC_SERVICE_RANGE, TIPC_CLUSTER_SCOPE,
TIPC_NODE_STATE, addr, addr);
@@ -138,7 +139,7 @@ static void tipc_net_finalize(struct net *net, u32 addr)
tipc_named_reinit(net);
tipc_sk_reinit(net);
tipc_mon_reinit_self(net);
- tipc_nametbl_publish(net, &ua, &sk, addr);
+ tipc_nametbl_publish(net, &ua, &sk, addr, &err);
}
void tipc_net_finalize_work(struct work_struct *work)
diff --git a/net/tipc/node.c b/net/tipc/node.c
index d84b0274fefc..870f84e2fb1c 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -402,6 +402,7 @@ static void tipc_node_write_unlock(struct tipc_node *n)
struct list_head *publ_list;
struct tipc_uaddr ua;
u32 bearer_id, node;
+ int err = 0;
if (likely(!flags)) {
write_unlock_bh(&n->lock);
@@ -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);
}
static void tipc_node_assign_peer_net(struct tipc_node *n, u32 hash_mixes)
@@ -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);
}
if (unlikely(rc & TIPC_LINK_UP_EVT))
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 65cc0c4964b3..a7b046f1d1d6 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -2920,6 +2920,7 @@ static int tipc_sk_publish(struct tipc_sock *tsk, struct tipc_uaddr *ua)
struct net *net = sock_net(sk);
struct tipc_socket_addr skaddr;
struct publication *p;
+ int err = 0;
u32 key;
if (tipc_sk_connected(sk))
@@ -2929,7 +2930,7 @@ static int tipc_sk_publish(struct tipc_sock *tsk, struct tipc_uaddr *ua)
return -EADDRINUSE;
skaddr.ref = tsk->portid;
skaddr.node = tipc_own_addr(net);
- p = tipc_nametbl_publish(net, ua, &skaddr, key);
+ p = tipc_nametbl_publish(net, ua, &skaddr, key, &err);
if (unlikely(!p))
return -EINVAL;
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH net v3 4/7] tipc: fix missing link-up event on memory allocation failure
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
0 siblings, 0 replies; 13+ messages in thread
From: netdev-bot+sashiko @ 2026-11-17 18:37 UTC (permalink / raw)
To: tung.quang.nguyen
Cc: netdev, davem, kuba, edumazet, pabeni, jmaloy, horms,
tipc-discussion, syzbot+64197f7577a09686ffdb, lkp
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
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net v3 5/7] tipc: validate original address of received skb in tipc_named_rcv()
2026-11-16 6:34 [PATCH net v3 0/7] tipc: fix deadlock and NUll pointer dereference in tipc_named_node_up() Tung Nguyen
` (3 preceding siblings ...)
2026-11-16 6:34 ` [PATCH net v3 4/7] tipc: fix missing link-up event on memory allocation failure Tung Nguyen
@ 2026-11-16 6:34 ` 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-16 6:34 ` [PATCH net v3 7/7] tipc: fix NULL pointer dereference in named_distribute() Tung Nguyen
6 siblings, 1 reply; 13+ messages in thread
From: Tung Nguyen @ 2026-11-16 6:34 UTC (permalink / raw)
To: netdev
Cc: davem, kuba, edumazet, pabeni, jmaloy, horms, tipc-discussion,
Tung Nguyen
Code inspection reveals that tipc_named_rcv() does not validate the
original address of received packets. This can lead to two issues:
1. A remote peer can send a publication message whose original address
is equal to the local node's address or is unknown. Upon receiving
this message, the local node can follow this execution path:
tipc_named_rcv()
tipc_update_nametbl()
tipc_nametbl_insert_publ()
tipc_node_subscribe()
return NULL;
As a result, the inserted publication is not added to the local
node's publ_list. Consequently, the publication will not be removed
later when this list is traversed for publication removal.
2. A remote peer can send a withdrawal message whose original address
is equal to the local node's address or is unknown. Upon receiving
this message, the local node can follow this execution path:
tipc_named_rcv()
tipc_update_nametbl()
tipc_nametbl_remove_publ()
tipc_node_unsubscribe()
return NULL;
kfree_rcu(p, rcu);
As a result, the publication is freed, but p->binding_node remains
linked to the local node's publ_list. Subsequent traversal of this
list will access freed memory.
Fix these issues by validating the original address of received
messages and rejecting those with invalid addresses.
Fixes: b97bf3fd8f6a ("[TIPC] Initial merge")
Signed-off-by: Tung Nguyen <tung.quang.nguyen@est.tech>
---
net/tipc/name_distr.c | 8 ++++++++
net/tipc/node.c | 34 ++++++++++++++++++++++++++--------
net/tipc/node.h | 1 +
3 files changed, 35 insertions(+), 8 deletions(-)
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
index 3ea5e900cb45..1fe650a95eb4 100644
--- a/net/tipc/name_distr.c
+++ b/net/tipc/name_distr.c
@@ -378,18 +378,26 @@ void tipc_named_rcv(struct net *net, struct sk_buff_head *namedq,
struct distr_item *item;
struct tipc_msg *hdr;
struct sk_buff *skb;
+ struct tipc_node *n;
u32 count, node;
spin_lock_bh(&tn->nametbl_lock);
while ((skb = tipc_named_dequeue(namedq, rcv_nxt, open))) {
hdr = buf_msg(skb);
node = msg_orignode(hdr);
+ n = tipc_node_find_remote(net, node);
+ if (!n)
+ goto free_skb;
+ else
+ tipc_node_put(n);
+
item = (struct distr_item *)msg_data(hdr);
count = msg_data_sz(hdr) / ITEM_SIZE;
while (count--) {
tipc_update_nametbl(net, item, node, msg_type(hdr));
item++;
}
+free_skb:
kfree_skb(skb);
}
spin_unlock_bh(&tn->nametbl_lock);
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 870f84e2fb1c..dfbeed21dbc1 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -657,16 +657,37 @@ void tipc_node_stop(struct net *net)
spin_unlock_bh(&tn->node_list_lock);
}
-void tipc_node_subscribe(struct net *net, struct list_head *subscr, u32 addr)
+/**
+ * tipc_node_find_remote - Find a node associated with an address
+ * @net: the associated network namespace
+ * @addr: node's address
+ *
+ * Return:
+ * * Found node - Success
+ * * NULL - Invalid node's address
+ *
+ */
+struct tipc_node *tipc_node_find_remote(struct net *net, u32 addr)
{
struct tipc_node *n;
if (in_own_node(net, addr))
- return;
+ return NULL;
n = tipc_node_find(net, addr);
+ if (!n)
+ return NULL;
+
+ return n;
+}
+
+void tipc_node_subscribe(struct net *net, struct list_head *subscr, u32 addr)
+{
+ struct tipc_node *n;
+
+ n = tipc_node_find_remote(net, addr);
if (!n) {
- pr_warn("Node subscribe rejected, unknown node 0x%x\n", addr);
+ pr_warn("Node subscribe rejected, invalid node 0x%x\n", addr);
return;
}
tipc_node_write_lock(n);
@@ -679,12 +700,9 @@ void tipc_node_unsubscribe(struct net *net, struct list_head *subscr, u32 addr)
{
struct tipc_node *n;
- if (in_own_node(net, addr))
- return;
-
- n = tipc_node_find(net, addr);
+ n = tipc_node_find_remote(net, addr);
if (!n) {
- pr_warn("Node unsubscribe rejected, unknown node 0x%x\n", addr);
+ pr_warn("Node unsubscribe rejected, invalid node 0x%x\n", addr);
return;
}
tipc_node_write_lock(n);
diff --git a/net/tipc/node.h b/net/tipc/node.h
index 154a5bbb0d29..411fac8c00ce 100644
--- a/net/tipc/node.h
+++ b/net/tipc/node.h
@@ -103,6 +103,7 @@ int tipc_node_xmit(struct net *net, struct sk_buff_head *list, u32 dnode,
int tipc_node_distr_xmit(struct net *net, struct sk_buff_head *list);
int tipc_node_xmit_skb(struct net *net, struct sk_buff *skb, u32 dest,
u32 selector);
+struct tipc_node *tipc_node_find_remote(struct net *net, u32 addr);
void tipc_node_subscribe(struct net *net, struct list_head *subscr, u32 addr);
void tipc_node_unsubscribe(struct net *net, struct list_head *subscr, u32 addr);
void tipc_node_broadcast(struct net *net, struct sk_buff *skb, int rc_dests);
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH net v3 5/7] tipc: validate original address of received skb in tipc_named_rcv()
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
0 siblings, 0 replies; 13+ messages in thread
From: netdev-bot+sashiko @ 2026-11-17 18:37 UTC (permalink / raw)
To: tung.quang.nguyen
Cc: netdev, davem, kuba, edumazet, pabeni, jmaloy, horms,
tipc-discussion, syzbot+64197f7577a09686ffdb, lkp
Thank you for your contribution! Sashiko AI review found 5 potential
issue(s) to consider.
Critical: 1 · High: 1 (1) · 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] Both bug classes the commit says it fixes are still
reachable from a remote peer: publications that are never removed, and…
- [High] Check-then-act race in the new validation.
- [Medium] The fix for this case is right, but the commit message
describes the wrong mechanism and understates the impact.
- [Medium] The new check in tipc_named_rcv() only verifies that
msg_orignode(hdr) is some non-preliminary remote node in node_htable.
- [Low] The kernel-doc for the newly exported tipc_node_find_remote()
(node.c:660-669, prototype at node.h:106) does not describe the real…
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but
tipc_publ_notify() walks n->publ_list with list_for_each_entry_safe()…
--
tipc: validate original address of received skb in tipc_named_rcv()
This patch makes tipc_named_rcv() reject name distributor messages whose
original node address is the local node, zero, or not in the node table.
The lookup is moved into a new helper, tipc_node_find_remote().
tipc_node_subscribe() and tipc_node_unsubscribe() now use that helper too.
> 2. A remote peer can send a withdrawal message whose original address
> is equal to the local node's address or is unknown. Upon receiving
> this message, the local node can follow this execution path:
>
> tipc_named_rcv()
> tipc_update_nametbl()
> tipc_nametbl_remove_publ()
> tipc_node_unsubscribe()
> return NULL;
> kfree_rcu(p, rcu);
>
> As a result, the publication is freed, but p->binding_node remains
> linked to the local node's publ_list. Subsequent traversal of this
> list will access freed memory.
[Severity: Medium]
Is this the right mechanism? The local node has no publ_list. The comment
in name_table.h says remote publications live on node->publ_list. Local
ones live on name_table->node_scope or cluster_scope.
In the own-address case, the withdrawal can match one of our own
cluster-scope bindings. publ_to_item() sends the type, lower, upper, port
and key of those bindings to every peer:
tipc_named_rcv()
tipc_update_nametbl()
tipc_nametbl_remove_publ() <- matches local p (sk.node == own)
tipc_node_unsubscribe() <- returns early due to in_own_node()
kfree_rcu(p, rcu)
When p is freed, p->binding_sock is still on tsk->publications (added in
tipc_sk_publish()). p->binding_node is still on nt->cluster_scope. Later
walks would then read freed memory:
tipc_sk_withdraw()
named_distribute(), via tipc_named_node_up()
tipc_named_reinit()
So any cluster peer seems able to cause a use-after-free of local socket
bindings. Could the commit message say so, and name the lists that are
actually left pointing at freed memory?
In the unknown-address case, such a publication can only exist through
scenario 1, where tipc_node_subscribe() failed. Its binding_node was only
initialized by tipc_publ_create(), so freeing it leaves nothing dangling.
Is the unknown-address part of scenario 2 accurate?
> diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
> index 3ea5e900cb454..1fe650a95eb42 100644
> --- a/net/tipc/name_distr.c
> +++ b/net/tipc/name_distr.c
> @@ -378,18 +378,26 @@ void tipc_named_rcv(struct net *net, struct sk_buff_head *namedq,
[ ... ]
> spin_lock_bh(&tn->nametbl_lock);
> while ((skb = tipc_named_dequeue(namedq, rcv_nxt, open))) {
> hdr = buf_msg(skb);
> node = msg_orignode(hdr);
> + n = tipc_node_find_remote(net, node);
[Severity: Medium]
This check accepts any remote, non-preliminary node in the node hash table.
Should it also check that orignode is the peer that actually sent the
message?
tipc_rcv() and tipc_node_bc_rcv() only call tipc_named_rcv() on
n->bc_entry.namedq of the sending node. There, n was found through
msg_prevnode(). Only the queue is passed down, though:
net/tipc/node.c:tipc_rcv() {
...
tipc_named_rcv(net, &n->bc_entry.namedq,
&n->bc_entry.named_rcv_nxt,
&n->bc_entry.named_open);
...
}
Valid name distributor messages always carry orignode equal to the
sender, because named_prepare_buf() calls tipc_msg_init() with our own
address.
With this patch, peer B can still send PUBLICATION items with orignode set
to another live peer A. They are linked onto A's publ_list and stay there
until A goes down. B can also send WITHDRAWAL items that remove A's real
bindings from the name table.
Would rejecting msg_orignode(hdr) != n->addr fit better here? That would
also cover the own-address and unknown-address cases this patch targets.
[Severity: Critical]
Can a node that is down but still hashed pass this check?
When peer Y loses contact, node_lost_contact() sets TIPC_NOTIFY_NODE_DOWN.
tipc_node_write_unlock() then drains Y->publ_list:
net/tipc/node.c:tipc_node_write_unlock() {
...
if (flags & TIPC_NOTIFY_NODE_DOWN)
tipc_publ_notify(net, publ_list, node, n->capabilities);
...
}
Y stays in node_htable until tipc_node_cleanup() deletes it, which happens
after NODE_CLEANUP_AFTER (300000 ms). tipc_node_find() ignores node state,
so tipc_node_find_remote(Y) keeps succeeding during that window.
Suppose a malicious peer X sends a PUBLICATION with orignode = Y in that
window:
tipc_named_rcv()
tipc_node_find_remote(Y) <- succeeds
tipc_update_nametbl()
tipc_nametbl_insert_publ()
tipc_node_subscribe()
list_add_tail(&p->binding_node, &Y->publ_list)
Y->publ_list has already been drained and is never walked again. Then:
tipc_node_timeout()
tipc_node_cleanup()
tipc_node_clear_links()
tipc_node_delete_from_list() <- Y is eventually freed
publ_list is never drained before Y is freed. p stays in the name table
permanently, and p->binding_node points into the freed node.
Later a node with address Y is created again, for example after Y reboots.
X then sends a matching WITHDRAWAL with orignode = Y:
tipc_named_rcv()
tipc_node_find_remote(Y) <- succeeds on the new node
tipc_update_nametbl()
tipc_nametbl_remove_publ() <- returns the stale p
tipc_node_unsubscribe()
list_del_init(subscr) <- writes into the freed old tipc_node
Doesn't this mean both problems from the commit message are still
reachable by a remote peer: a publication that is never removed, and a
list operation on freed memory?
A presence check alone doesn't seem to close this. Would either of these
work?
- require orignode == n->addr, with n up
- drain publ_list in tipc_node_cleanup() or tipc_node_free()
Later patches in the series don't seem to change tipc_named_rcv(),
tipc_node_find_remote() or tipc_node_cleanup() in this respect.
> + if (!n)
> + goto free_skb;
> + else
> + tipc_node_put(n);
[Severity: High]
The reference is dropped right after the check.
tipc_node_subscribe() and tipc_node_unsubscribe() later do a separate
lookup. Can the node be removed between the two lookups?
Only tn->nametbl_lock is held across both. tipc_node_cleanup() runs from
the node timer on another CPU and takes only node_list_lock and n->lock
before tipc_node_delete_from_list() calls hlist_del_rcu():
CPU A CPU B
tipc_named_rcv()
tipc_node_find_remote(Y) ok
tipc_node_put(n)
tipc_node_timeout()
tipc_node_cleanup()
tipc_node_delete_from_list(Y)
tipc_update_nametbl()
tipc_node_subscribe() or
tipc_node_unsubscribe()
tipc_node_find_remote(Y) fails
For a PUBLICATION, the insert has already succeeded. p is left in the name
table on no publ_list, which is scenario 1 again.
For a WITHDRAWAL, tipc_node_unsubscribe() fails silently and
tipc_update_nametbl() frees p anyway:
p = tipc_nametbl_remove_publ(net, &ua, &sk, key);
if (p) {
tipc_node_unsubscribe(net, &p->binding_node, node);
kfree_rcu(p, rcu);
p->binding_node is still on the old node's publ_list at that point, which
is scenario 2.
tipc_node_cleanup() only removes a node that has been down for
NODE_CLEANUP_AFTER, so this needs the spoofed orignode described above.
Would holding the validated node, and its liveness, from the check through
subscribe/unsubscribe close this?
[ ... ]
> diff --git a/net/tipc/node.c b/net/tipc/node.c
> index 870f84e2fb1c4..dfbeed21dbc1b 100644
> --- a/net/tipc/node.c
> +++ b/net/tipc/node.c
> @@ -657,16 +657,37 @@ void tipc_node_stop(struct net *net)
> spin_unlock_bh(&tn->node_list_lock);
> }
>
> -void tipc_node_subscribe(struct net *net, struct list_head *subscr, u32 addr)
> +/**
> + * tipc_node_find_remote - Find a node associated with an address
> + * @net: the associated network namespace
> + * @addr: node's address
> + *
> + * Return:
> + * * Found node - Success
> + * * NULL - Invalid node's address
> + *
> + */
> +struct tipc_node *tipc_node_find_remote(struct net *net, u32 addr)
> {
> struct tipc_node *n;
>
> if (in_own_node(net, addr))
> - return;
> + return NULL;
>
> n = tipc_node_find(net, addr);
> + if (!n)
> + return NULL;
> +
> + return n;
> +}
[Severity: Low]
This isn't a bug, but the kernel-doc for this newly exported helper doesn't
say that the returned node holds a reference. tipc_node_find() takes it
with kref_get_unless_zero(), and the caller has to drop it with
tipc_node_put().
NULL also covers more than an invalid address:
- own or zero address (in_own_node())
- unknown address
- preliminary node
- node whose kref already reached zero
Could the Return section list these cases?
Also, this sequence is redundant:
if (!n)
return NULL;
return n;
The function could just return tipc_node_find(net, addr).
[ ... ]
> @@ -679,12 +700,9 @@ void tipc_node_unsubscribe(struct net *net, struct list_head *subscr, u32 addr)
> {
> struct tipc_node *n;
>
> - if (in_own_node(net, addr))
> - return;
> -
> - n = tipc_node_find(net, addr);
> + n = tipc_node_find_remote(net, addr);
> if (!n) {
> - pr_warn("Node unsubscribe rejected, unknown node 0x%x\n", addr);
> + pr_warn("Node unsubscribe rejected, invalid node 0x%x\n", addr);
> return;
> }
> tipc_node_write_lock(n);
[Severity: High]
This is a pre-existing issue, not introduced by this patch. Does
tipc_publ_notify() walk n->publ_list without any lock that serializes it
against this list_del_init()?
tipc_node_write_unlock() drops n->lock before calling
tipc_publ_notify(net, publ_list, ...). tipc_publ_notify() then iterates
without n->lock:
net/tipc/name_distr.c:tipc_publ_notify() {
...
list_for_each_entry_safe(publ, tmp, nsub_list, binding_node)
tipc_publ_purge(net, publ, addr);
...
}
tipc_publ_purge() only takes nametbl_lock for each entry. Meanwhile,
tipc_named_rcv() on another CPU holds nametbl_lock and takes n->lock in
tipc_node_unsubscribe() to run list_del_init(subscr).
The new check still accepts orignode equal to a node that is going down.
Such messages can be Y's own messages that were already queued, or a peer
spoofing orignode = Y.
Suppose a concurrent WITHDRAWAL removes the entry saved in tmp:
- list_del_init() makes tmp->binding_node point to itself
- tmp is passed to kfree_rcu()
- list_next_entry(tmp) == tmp on the next step
- tipc_publ_purge() finds nothing to remove
The loop then never ends, which hangs the CPU in softirq context.
The walk can also run in process context, for example on bearer disable:
tipc_node_delete_links()
tipc_node_link_down()
tipc_node_write_unlock()
tipc_publ_notify()
There, an RCU grace period can complete between iterations, so tmp could
be read after it has been freed.
A concurrent list_add_tail() could also be missed by the walk, which would
leave that publication unpurged.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116063529.6185-1-tung.quang.nguyen%40est.tech
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net v3 6/7] tipc: fix self-deadlock in tipc_named_node_up
2026-11-16 6:34 [PATCH net v3 0/7] tipc: fix deadlock and NUll pointer dereference in tipc_named_node_up() Tung Nguyen
` (4 preceding siblings ...)
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-16 6:34 ` 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
6 siblings, 1 reply; 13+ messages in thread
From: Tung Nguyen @ 2026-11-16 6:34 UTC (permalink / raw)
To: netdev
Cc: davem, kuba, edumazet, pabeni, jmaloy, horms, tipc-discussion,
Tung Nguyen
The following deadlock can occur, as observed during code inspection:
tipc_named_node_up()
read_lock_bh(&nt->cluster_scope_lock) <-- acquire read lock
named_distribute()
tipc_node_xmit()
tipc_node_link_down()
tipc_node_write_unlock()
tipc_nametbl_withdraw()
spin_lock_bh(&tn->nametbl_lock)
tipc_named_withdraw()
write_lock_bh(&nt->cluster_scope_lock) <-- acquire write lock
Fix this issue by:
- Removing cluster_scope_lock, which protects the name table's
cluster_scope list. Use nametbl_lock instead to protect the list
against races when multiple threads concurrently call
tipc_named_publish(), tipc_named_withdraw(), and
tipc_named_node_up().
- Introducing a new function, tipc_node_distribute(), which is similar
to tipc_node_xmit() but does not call tipc_node_link_down().
Both functions call the newly introduced tipc_node_build_list(),
which clones a list of messages in sequence and tipc_node_lxc_xmit()
which delivers the list to the peer namespace. When tipc_named_node_up()
returns -ENOBUFS, tipc_node_link_down() is called from
tipc_node_write_unlock() instead.
Fixes: 988f3f1603d4 ("tipc: eliminate message disordering during binding table update")
Signed-off-by: Tung Nguyen <tung.quang.nguyen@est.tech>
---
v3: Introduce tipc_node_lxc_xmit() for container communication.
v2: https://lore.kernel.org/netdev/20261102034207.10639-6-tung.quang.nguyen@est.tech/
v1: https://lore.kernel.org/netdev/20261028033722.125477-3-tung.quang.nguyen@est.tech/
net/tipc/name_distr.c | 32 ++++++---
net/tipc/name_distr.h | 3 +-
net/tipc/name_table.c | 1 -
net/tipc/name_table.h | 2 -
net/tipc/node.c | 151 ++++++++++++++++++++++++++++++++----------
net/tipc/node.h | 2 +
6 files changed, 142 insertions(+), 49 deletions(-)
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
index 1fe650a95eb4..2e07d50a2943 100644
--- a/net/tipc/name_distr.c
+++ b/net/tipc/name_distr.c
@@ -95,9 +95,7 @@ struct sk_buff *tipc_named_publish(struct net *net, struct publication *p)
list_add_tail_rcu(&p->binding_node, &nt->node_scope);
return NULL;
}
- write_lock_bh(&nt->cluster_scope_lock);
list_add_tail(&p->binding_node, &nt->cluster_scope);
- write_unlock_bh(&nt->cluster_scope_lock);
skb = named_prepare_buf(net, PUBLICATION, ITEM_SIZE, 0);
if (!skb) {
pr_warn("Publication distribution failure\n");
@@ -121,9 +119,7 @@ struct sk_buff *tipc_named_withdraw(struct net *net, struct publication *p)
struct distr_item *item;
struct sk_buff *skb;
- write_lock_bh(&nt->cluster_scope_lock);
list_del(&p->binding_node);
- write_unlock_bh(&nt->cluster_scope_lock);
if (p->scope == TIPC_NODE_SCOPE)
return NULL;
@@ -202,25 +198,39 @@ static void named_distribute(struct net *net, struct sk_buff_head *list,
* @net: the associated network namespace
* @dnode: destination node
* @capabilities: peer node's capabilities
+ * @bearer_id: id of the bearer
+ *
+ * Return:
+ * * 0 - Success
+ * * -ENOBUFS - No buffer space is available
+ * * -EHOSTUNREACH - Destination node does not exist or cannot be reached
+ * * -EMSGSIZE - Message's size is too big
+ *
*/
-void tipc_named_node_up(struct net *net, u32 dnode, u16 capabilities)
+int tipc_named_node_up(struct net *net, u32 dnode,
+ u16 capabilities, int *bearer_id)
{
struct name_table *nt = tipc_name_table(net);
struct tipc_net *tn = tipc_net(net);
struct sk_buff_head head;
- u16 seqno;
+ int rc = 0;
__skb_queue_head_init(&head);
spin_lock_bh(&tn->nametbl_lock);
if (!(capabilities & TIPC_NAMED_BCAST))
nt->rc_dests++;
- seqno = nt->snd_nxt;
+ named_distribute(net, &head, dnode, &nt->cluster_scope, nt->snd_nxt);
+ if (!skb_queue_empty(&head))
+ rc = tipc_node_distribute(net, &head, dnode, bearer_id, 0);
spin_unlock_bh(&tn->nametbl_lock);
- read_lock_bh(&nt->cluster_scope_lock);
- named_distribute(net, &head, dnode, &nt->cluster_scope, seqno);
- tipc_node_xmit(net, &head, dnode, 0);
- read_unlock_bh(&nt->cluster_scope_lock);
+ /* The link is congested after the list is inserted into
+ * the link's send queue. Return 0, as this is normal.
+ */
+ if (rc == -ELINKCONG)
+ rc = 0;
+
+ return rc;
}
/**
diff --git a/net/tipc/name_distr.h b/net/tipc/name_distr.h
index c677f6f082df..767f9f69624d 100644
--- a/net/tipc/name_distr.h
+++ b/net/tipc/name_distr.h
@@ -69,7 +69,8 @@ struct distr_item {
struct sk_buff *tipc_named_publish(struct net *net, struct publication *publ);
struct sk_buff *tipc_named_withdraw(struct net *net, struct publication *publ);
-void tipc_named_node_up(struct net *net, u32 dnode, u16 capabilities);
+int tipc_named_node_up(struct net *net, u32 dnode,
+ u16 capabilities, int *bearer_id);
void tipc_named_rcv(struct net *net, struct sk_buff_head *namedq,
u16 *rcv_nxt, bool *open);
void tipc_named_reinit(struct net *net);
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index e8b768699ab9..6bb0333f39bf 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -963,7 +963,6 @@ int tipc_nametbl_init(struct net *net)
INIT_LIST_HEAD(&nt->node_scope);
INIT_LIST_HEAD(&nt->cluster_scope);
- rwlock_init(&nt->cluster_scope_lock);
tn->nametbl = nt;
spin_lock_init(&tn->nametbl_lock);
return 0;
diff --git a/net/tipc/name_table.h b/net/tipc/name_table.h
index 3a15dcfcc2cd..a66975ef8546 100644
--- a/net/tipc/name_table.h
+++ b/net/tipc/name_table.h
@@ -97,7 +97,6 @@ struct publication {
* @cluster_scope: all local publications with cluster scope
* - used by name_distr to send bulk updates to new nodes
* - used by name_distr during re-init of name table
- * @cluster_scope_lock: lock for accessing @cluster_scope
* @local_publ_count: number of publications issued by this node
* @rc_dests: destination node counter
* @snd_nxt: next sequence number to be used
@@ -107,7 +106,6 @@ struct name_table {
struct hlist_head services[TIPC_NAMETBL_SIZE];
struct list_head node_scope;
struct list_head cluster_scope;
- rwlock_t cluster_scope_lock;
u32 local_publ_count;
u32 rc_dests;
u32 snd_nxt;
diff --git a/net/tipc/node.c b/net/tipc/node.c
index dfbeed21dbc1..77979a850df2 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -400,6 +400,7 @@ static void tipc_node_write_unlock(struct tipc_node *n)
struct net *net = n->net;
u32 flags = n->action_flags;
struct list_head *publ_list;
+ int rc = 0, bearer = 0;
struct tipc_uaddr ua;
u32 bearer_id, node;
int err = 0;
@@ -426,7 +427,7 @@ static void tipc_node_write_unlock(struct tipc_node *n)
tipc_publ_notify(net, publ_list, node, n->capabilities);
if (flags & TIPC_NOTIFY_NODE_UP)
- tipc_named_node_up(net, node, n->capabilities);
+ rc = tipc_named_node_up(net, node, n->capabilities, &bearer);
if (flags & TIPC_NOTIFY_LINK_UP) {
tipc_mon_peer_up(net, node, bearer_id);
@@ -437,8 +438,15 @@ static void tipc_node_write_unlock(struct tipc_node *n)
tipc_nametbl_withdraw(net, &ua, &sk, sk.ref);
}
- if (err == -ENOBUFS)
+ if (rc == -ENOBUFS)
+ tipc_node_link_down(n, bearer, false);
+
+ if (err == -ENOBUFS) {
+ if (rc == -ENOBUFS && bearer == bearer_id)
+ return;
+
tipc_node_link_down(n, bearer_id, false);
+ }
}
static void tipc_node_assign_peer_net(struct tipc_node *n, u32 hash_mixes)
@@ -1704,6 +1712,55 @@ static void tipc_lxc_xmit(struct net *peer_net, struct sk_buff_head *list)
}
}
+static int tipc_node_lxc_xmit(struct tipc_node *n, struct sk_buff_head *list)
+{
+ bool node_up = false;
+ struct net *peer_net;
+
+ rcu_read_lock();
+ tipc_node_read_lock(n);
+ node_up = node_is_up(n);
+ peer_net = n->peer_net;
+ tipc_node_read_unlock(n);
+
+ if (node_up && peer_net && check_net(peer_net)) {
+ /* xmit inner linux container */
+ tipc_lxc_xmit(peer_net, list);
+ if (likely(skb_queue_empty(list))) {
+ rcu_read_unlock();
+ return 1;
+ }
+ }
+ rcu_read_unlock();
+
+ return 0;
+}
+
+static int tipc_node_build_list(struct tipc_node *n, struct sk_buff_head *list,
+ struct sk_buff_head *xmitq, int selector,
+ struct tipc_media_addr *maddr, int *bearer_id)
+{
+ struct tipc_link_entry *le = NULL;
+ int rc = 0;
+
+ tipc_node_read_lock(n);
+ *bearer_id = n->active_links[selector & 1];
+ if (unlikely(*bearer_id == INVALID_BEARER_ID)) {
+ tipc_node_read_unlock(n);
+ __skb_queue_purge(list);
+ return -EHOSTUNREACH;
+ }
+
+ le = &n->links[*bearer_id];
+ *maddr = le->maddr;
+ spin_lock_bh(&le->lock);
+ rc = tipc_link_xmit(le->link, list, xmitq);
+ spin_unlock_bh(&le->lock);
+ tipc_node_read_unlock(n);
+
+ return rc;
+}
+
/**
* tipc_node_xmit() - general link level function for message sending
* @net: the applicable net namespace
@@ -1711,17 +1768,15 @@ static void tipc_lxc_xmit(struct net *peer_net, struct sk_buff_head *list)
* @dnode: address of destination node
* @selector: a number used for deterministic link selection
* Consumes the buffer chain.
- * Return: 0 if success, otherwise: -ELINKCONG,-EHOSTUNREACH,-EMSGSIZE,-ENOBUF
+ * Return: 0 if success, otherwise: -ELINKCONG,-EHOSTUNREACH,-EMSGSIZE,-ENOBUFS
*/
int tipc_node_xmit(struct net *net, struct sk_buff_head *list,
u32 dnode, int selector)
{
- struct tipc_link_entry *le = NULL;
- struct tipc_node *n;
+ struct tipc_media_addr maddr;
struct sk_buff_head xmitq;
- bool node_up = false;
- struct net *peer_net;
- int bearer_id;
+ struct tipc_node *n;
+ int bearer_id = 0;
int rc;
if (in_own_node(net, dnode)) {
@@ -1737,44 +1792,72 @@ int tipc_node_xmit(struct net *net, struct sk_buff_head *list,
return -EHOSTUNREACH;
}
- rcu_read_lock();
- tipc_node_read_lock(n);
- node_up = node_is_up(n);
- peer_net = n->peer_net;
- tipc_node_read_unlock(n);
- if (node_up && peer_net && check_net(peer_net)) {
- /* xmit inner linux container */
- tipc_lxc_xmit(peer_net, list);
- if (likely(skb_queue_empty(list))) {
- rcu_read_unlock();
- tipc_node_put(n);
- return 0;
- }
+ if (tipc_node_lxc_xmit(n, list)) {
+ tipc_node_put(n);
+ return 0;
}
- rcu_read_unlock();
- tipc_node_read_lock(n);
- bearer_id = n->active_links[selector & 1];
- if (unlikely(bearer_id == INVALID_BEARER_ID)) {
- tipc_node_read_unlock(n);
- tipc_node_put(n);
+ __skb_queue_head_init(&xmitq);
+ rc = tipc_node_build_list(n, list, &xmitq, selector,
+ &maddr, &bearer_id);
+
+ if (unlikely(rc == -ENOBUFS)) {
+ if (!skb_queue_empty(&xmitq))
+ __skb_queue_purge(&xmitq);
+ tipc_node_link_down(n, bearer_id, false);
+ } else {
+ tipc_bearer_xmit(net, bearer_id, &xmitq, &maddr, n);
+ }
+
+ tipc_node_put(n);
+
+ return rc;
+}
+
+/**
+ * tipc_node_distribute() - distribute list of messages to specific destination
+ * @net: the applicable net namespace
+ * @list: chain of buffers containing message
+ * @dnode: address of destination node
+ * @bearer_id: id of the bearer
+ * @selector: a number used for deterministic link selection
+ *
+ * Return:
+ * * 0 - Success
+ * * -ELINKCONG - Link is congested
+ * * -EHOSTUNREACH - Host is not reachable
+ * * -EMSGSIZE - Message's size is too big
+ * * -ENOBUFS - No buffer space is available
+ *
+ */
+int tipc_node_distribute(struct net *net, struct sk_buff_head *list,
+ u32 dnode, int *bearer_id, int selector)
+{
+ struct tipc_media_addr maddr;
+ struct sk_buff_head xmitq;
+ struct tipc_node *n;
+ int rc;
+
+ n = tipc_node_find(net, dnode);
+ if (unlikely(!n)) {
__skb_queue_purge(list);
return -EHOSTUNREACH;
}
+ if (tipc_node_lxc_xmit(n, list)) {
+ tipc_node_put(n);
+ return 0;
+ }
+
__skb_queue_head_init(&xmitq);
- le = &n->links[bearer_id];
- spin_lock_bh(&le->lock);
- rc = tipc_link_xmit(le->link, list, &xmitq);
- spin_unlock_bh(&le->lock);
- tipc_node_read_unlock(n);
+ rc = tipc_node_build_list(n, list, &xmitq, selector,
+ &maddr, bearer_id);
if (unlikely(rc == -ENOBUFS)) {
if (!skb_queue_empty(&xmitq))
__skb_queue_purge(&xmitq);
- tipc_node_link_down(n, bearer_id, false);
} else {
- tipc_bearer_xmit(net, bearer_id, &xmitq, &le->maddr, n);
+ tipc_bearer_xmit(net, *bearer_id, &xmitq, &maddr, n);
}
tipc_node_put(n);
diff --git a/net/tipc/node.h b/net/tipc/node.h
index 411fac8c00ce..499e8ea8c753 100644
--- a/net/tipc/node.h
+++ b/net/tipc/node.h
@@ -100,6 +100,8 @@ int tipc_node_get_linkname(struct net *net, u32 bearer_id, u32 node,
char *linkname, size_t len);
int tipc_node_xmit(struct net *net, struct sk_buff_head *list, u32 dnode,
int selector);
+int tipc_node_distribute(struct net *net, struct sk_buff_head *list,
+ u32 dnode, int *bearer_id, int selector);
int tipc_node_distr_xmit(struct net *net, struct sk_buff_head *list);
int tipc_node_xmit_skb(struct net *net, struct sk_buff *skb, u32 dest,
u32 selector);
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH net v3 6/7] tipc: fix self-deadlock in tipc_named_node_up
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
0 siblings, 0 replies; 13+ messages in thread
From: netdev-bot+sashiko @ 2026-11-17 18:37 UTC (permalink / raw)
To: tung.quang.nguyen
Cc: netdev, davem, kuba, edumazet, pabeni, jmaloy, horms,
tipc-discussion, syzbot+64197f7577a09686ffdb, lkp
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] In net/tipc/node.c, the call to tipc_node_lxc_xmit() inside the
new tipc_node_distribute() (line 1847) can never do anything, so it is…
- [Low] tipc_named_node_up() (net/tipc/name_distr.c, around lines
227-231) maps -ELINKCONG to 0, with the comment "The link is congested…
--
tipc: fix self-deadlock in tipc_named_node_up
This patch removes cluster_scope_lock and uses nametbl_lock to protect
the cluster_scope list. That avoids a self-deadlock when
tipc_node_xmit() reaches tipc_node_link_down() while the read lock is
held. It also adds tipc_node_distribute(), which sends the bulk list
without calling tipc_node_link_down(), and moves the link reset on
-ENOBUFS into tipc_node_write_unlock().
> diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
> index 1fe650a95eb42..2e07d50a29437 100644
> --- a/net/tipc/name_distr.c
> +++ b/net/tipc/name_distr.c
[ ... ]
> @@ -202,25 +198,39 @@ static void named_distribute(struct net *net, struct sk_buff_head *list,
[ ... ]
> -void tipc_named_node_up(struct net *net, u32 dnode, u16 capabilities)
> +int tipc_named_node_up(struct net *net, u32 dnode,
> + u16 capabilities, int *bearer_id)
> {
[ ... ]
> __skb_queue_head_init(&head);
> spin_lock_bh(&tn->nametbl_lock);
> if (!(capabilities & TIPC_NAMED_BCAST))
> nt->rc_dests++;
> - seqno = nt->snd_nxt;
> + named_distribute(net, &head, dnode, &nt->cluster_scope, nt->snd_nxt);
> + if (!skb_queue_empty(&head))
> + rc = tipc_node_distribute(net, &head, dnode, bearer_id, 0);
> spin_unlock_bh(&tn->nametbl_lock);
>
> - read_lock_bh(&nt->cluster_scope_lock);
> - named_distribute(net, &head, dnode, &nt->cluster_scope, seqno);
> - tipc_node_xmit(net, &head, dnode, 0);
> - read_unlock_bh(&nt->cluster_scope_lock);
> + /* The link is congested after the list is inserted into
> + * the link's send queue. Return 0, as this is normal.
> + */
> + if (rc == -ELINKCONG)
> + rc = 0;
[Severity: Low]
Can tipc_link_xmit() return -ELINKCONG for this list?
Every buffer that named_distribute() builds has user NAME_DISTRIBUTOR.
msg_importance() maps that user to TIPC_SYSTEM_IMPORTANCE:
net/tipc/msg.h:msg_importance() {
if (likely((usr <= TIPC_CRITICAL_IMPORTANCE) && !msg_errcode(m)))
return usr;
if ((usr == MSG_FRAGMENTER) || (usr == MSG_BUNDLER))
return msg_bits(m, 9, 0, 0x7);
return TIPC_SYSTEM_IMPORTANCE;
}
In tipc_link_xmit(), a SYSTEM importance list that hits the backlog limit
is purged and gets -ENOBUFS. That means link_schedule_user(), the only
source of -ELINKCONG, is never called for it:
net/tipc/link.c:tipc_link_xmit() {
...
if (unlikely(l->backlog[imp].len >= l->backlog[imp].limit)) {
if (imp == TIPC_SYSTEM_IMPORTANCE) {
pr_warn("%s<%s>, link overflow", link_rst_msg, l->name);
__skb_queue_purge(list);
return -ENOBUFS;
}
rc = link_schedule_user(l, hdr);
}
...
}
When transmq is full, the buffers just move to the backlog and rc stays
0.
If that's right, this branch is dead code. The comment also says
congestion is a normal result here, but for this traffic congestion ends
in -ENOBUFS and a link reset. The -ELINKCONG entry in the
tipc_node_distribute() kernel-doc has the same problem.
Later in the series, the same branch and comment are copied into
tipc_named_distribute().
> diff --git a/net/tipc/node.c b/net/tipc/node.c
> index dfbeed21dbc1b..77979a850df24 100644
> --- a/net/tipc/node.c
> +++ b/net/tipc/node.c
[ ... ]
> @@ -1737,44 +1792,72 @@ int tipc_node_xmit(struct net *net, struct sk_buff_head *list,
[ ... ]
> +int tipc_node_distribute(struct net *net, struct sk_buff_head *list,
> + u32 dnode, int *bearer_id, int selector)
> +{
> + struct tipc_media_addr maddr;
> + struct sk_buff_head xmitq;
> + struct tipc_node *n;
> + int rc;
> +
> + n = tipc_node_find(net, dnode);
> + if (unlikely(!n)) {
> __skb_queue_purge(list);
> return -EHOSTUNREACH;
> }
>
> + if (tipc_node_lxc_xmit(n, list)) {
> + tipc_node_put(n);
> + return 0;
> + }
[Severity: Low]
Can this tipc_node_lxc_xmit() call ever consume the list?
tipc_named_node_up() is the only caller of tipc_node_distribute(), and
it passes the bulk list from named_distribute(). named_prepare_buf()
builds each of those buffers with user NAME_DISTRIBUTOR:
net/tipc/name_distr.c:named_prepare_buf() {
...
tipc_msg_init(self, msg, NAME_DISTRIBUTOR,
type, INT_H_SIZE, dest);
...
}
For that user, tipc_lxc_xmit() returns without touching the list:
net/tipc/node.c:tipc_lxc_xmit() {
...
case LINK_PROTOCOL:
case NAME_DISTRIBUTOR:
case TUNNEL_PROTOCOL:
case BCAST_PROTOCOL:
return;
...
}
So skb_queue_empty(list) is always false and tipc_node_lxc_xmit() always
returns 0 here. All it adds is an extra rcu_read_lock() and a node read
lock round trip before tipc_node_build_list().
Runtime behavior doesn't change, because the old tipc_node_xmit() never
delivered named bulk messages over lxc either. This is still true at the
end of the series. The tipc_named_distribute() caller added later also
only passes named_distribute() output.
Could this call be dropped from tipc_node_distribute()? The commit
message says:
Both functions call the newly introduced tipc_node_build_list(),
which clones a list of messages in sequence and tipc_node_lxc_xmit()
which delivers the list to the peer namespace.
The v3 changelog also says "Introduce tipc_node_lxc_xmit() for container
communication", but tipc_node_distribute() never does that delivery.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116063529.6185-1-tung.quang.nguyen%40est.tech
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH net v3 7/7] tipc: fix NULL pointer dereference in named_distribute()
2026-11-16 6:34 [PATCH net v3 0/7] tipc: fix deadlock and NUll pointer dereference in tipc_named_node_up() Tung Nguyen
` (5 preceding siblings ...)
2026-11-16 6:34 ` [PATCH net v3 6/7] tipc: fix self-deadlock in tipc_named_node_up Tung Nguyen
@ 2026-11-16 6:34 ` Tung Nguyen
2026-11-17 18:37 ` netdev-bot+sashiko
6 siblings, 1 reply; 13+ messages in thread
From: Tung Nguyen @ 2026-11-16 6:34 UTC (permalink / raw)
To: netdev
Cc: davem, kuba, edumazet, pabeni, jmaloy, horms, tipc-discussion,
Tung Nguyen, syzbot+64197f7577a09686ffdb, kernel test robot
Syzbot reports NULL pointer dereference in named_distribute():
...
RIP: 0010:buf_msg net/tipc/msg.h:202 [inline]
RIP: 0010:named_distribute net/tipc/name_distr.c:195 [inline]
RIP: 0010:tipc_named_node_up+0x8e0/0xb00 net/tipc/name_distr.c:221
...
tipc_node_write_unlock+0x2ce/0x4f0 net/tipc/node.c:428
tipc_rcv+0xb55/0x1020 net/tipc/node.c:2196
tipc_l2_rcv_msg+0x2d9/0x470 net/tipc/bearer.c:671
The root cause is racing between tipc_net_finalize() and
named_distribute() as follows:
Thread 1 (tipc_net_finalize) | Thread 2 (named_distribute)
-----------------------------|-----------------------------
| ...
| list_for_each_entry(publ, pls, binding_node) {
| ...
| __skb_queue_tail(list, skb);
| ...
| }
| ...
| hdr = buf_msg(skb_peek_tail(list));
... |
tipc_nametbl_publish(); |
If 'tipc_nametbl_publish()' (Thread 1) executes after 'named_distribute()'
(Thread 2), list will be empty. As a result, NULL is passed to 'buf_msg()',
leading to a NULL pointer dereference.
Fix the this issue by checking for the node's self-address publication on
either node-up or node-timeout event. If the publication does not exist, insert
it into the name table and publish it to the other nodes.
Reported-by: syzbot+64197f7577a09686ffdb@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=64197f7577a09686ffdb
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202611022356.UddfVq4D-lkp@intel.com/
Fixes: adba75be0d23 ("tipc: fix lockdep warning when reinitilaizing sockets")
Signed-off-by: Tung Nguyen <tung.quang.nguyen@est.tech>
---
v3:
- Initialize p to NULL in tipc_net_finalize() to address a warning.
- Reset the correct bearer in tipc_node_write_unlock().
- Correct the return value of tipc_nametbl_insert() in function comment.
v2: https://lore.kernel.org/netdev/20261102034207.10639-7-tung.quang.nguyen@est.tech/
v1: https://lore.kernel.org/netdev/20261028033722.125477-3-tung.quang.nguyen@est.tech/
net/tipc/core.c | 1 +
net/tipc/core.h | 2 +
net/tipc/name_distr.c | 93 ++++++++++++++++++++++++++++++++++++++---
net/tipc/name_distr.h | 1 +
net/tipc/name_table.c | 97 ++++++++++++++++++++++++++++++++++++++-----
net/tipc/name_table.h | 4 ++
net/tipc/net.c | 18 +++++++-
net/tipc/node.c | 74 +++++++++++++++++++++++++++++----
net/tipc/node.h | 1 +
9 files changed, 265 insertions(+), 26 deletions(-)
diff --git a/net/tipc/core.c b/net/tipc/core.c
index 315975c3be81..351ced173866 100644
--- a/net/tipc/core.c
+++ b/net/tipc/core.c
@@ -61,6 +61,7 @@ static int __net_init tipc_init_net(struct net *net)
tn->trial_addr = 0;
tn->addr_trial_end = 0;
tn->capabilities = TIPC_NODE_CAPABILITIES;
+ tn->nt_self_node_exist = false;
INIT_WORK(&tn->work, tipc_net_finalize_work);
memset(tn->node_id, 0, sizeof(tn->node_id));
memset(tn->node_id_string, 0, sizeof(tn->node_id_string));
diff --git a/net/tipc/core.h b/net/tipc/core.h
index 9ce5f9ff6cc0..8f5a94dbc1fc 100644
--- a/net/tipc/core.h
+++ b/net/tipc/core.h
@@ -145,6 +145,8 @@ struct tipc_net {
struct work_struct work;
/* The numbers of work queues in schedule */
atomic_t wq_count;
+ /* Node's self address publication is available in the name table */
+ bool nt_self_node_exist;
};
static inline struct tipc_net *tipc_net(struct net *net)
diff --git a/net/tipc/name_distr.c b/net/tipc/name_distr.c
index 2e07d50a2943..f77d49883ce8 100644
--- a/net/tipc/name_distr.c
+++ b/net/tipc/name_distr.c
@@ -142,9 +142,14 @@ struct sk_buff *tipc_named_withdraw(struct net *net, struct publication *p)
* @dnode: node to be updated
* @pls: linked list of publication items to be packed into buffer chain
* @seqno: sequence number for this message
+ *
+ * Return:
+ * * 0 - Success
+ * * -ENOBUFS - No buffer space is available
+ *
*/
-static void named_distribute(struct net *net, struct sk_buff_head *list,
- u32 dnode, struct list_head *pls, u16 seqno)
+static int named_distribute(struct net *net, struct sk_buff_head *list,
+ u32 dnode, struct list_head *pls, u16 seqno)
{
struct publication *publ;
struct sk_buff *skb = NULL;
@@ -160,8 +165,9 @@ static void named_distribute(struct net *net, struct sk_buff_head *list,
skb = named_prepare_buf(net, PUBLICATION, msg_rem,
dnode);
if (!skb) {
+ __skb_queue_purge(list);
pr_warn("Bulk publication failure\n");
- return;
+ return -ENOBUFS;
}
hdr = buf_msg(skb);
msg_set_bc_ack_invalid(hdr, true);
@@ -191,6 +197,82 @@ static void named_distribute(struct net *net, struct sk_buff_head *list,
hdr = buf_msg(skb_peek_tail(list));
msg_set_last_bulk(hdr);
msg_set_named_seqno(hdr, seqno);
+
+ return 0;
+}
+
+/**
+ * __tipc_named_distribute - build a list of publications need to be distributed
+ * @net: the associated network namespace
+ * @dnode: destination node
+ * @head: list of publications
+ *
+ * Return:
+ * * 0 - Success
+ * * -ENOBUFS - No buffer space is available
+ *
+ */
+static int __tipc_named_distribute(struct net *net, u32 dnode,
+ struct sk_buff_head *head)
+{
+ struct name_table *nt = tipc_name_table(net);
+ struct tipc_net *tn = tipc_net(net);
+
+ /* Node's self-address is not set yet */
+ if (!tipc_own_addr(net)) {
+ /* Defer the distribution to node's timer */
+ tipc_node_set_dist_bulk(net, dnode);
+ return 0;
+ }
+
+ /* Node's self-address publication does not exist */
+ if (!tn->nt_self_node_exist) {
+ if (tipc_nametb_insert_self_node_pub(net))
+ return -ENOBUFS;
+
+ tn->nt_self_node_exist = true;
+ }
+
+ if (named_distribute(net, head, dnode,
+ &nt->cluster_scope, nt->snd_nxt) == -ENOBUFS)
+ return -ENOBUFS;
+
+ return 0;
+}
+
+/**
+ * tipc_named_distribute - distribute all publications to specified node
+ * @net: the associated network namespace
+ * @dnode: destination node
+ * @bearer_id: id of the bearer
+ *
+ * Return:
+ * * 0 - Success
+ * * -ENOBUFS - No buffer space is available
+ * * -EHOSTUNREACH - Destination node does not exist or cannot be reached
+ * * -EMSGSIZE - Message's size is too big
+ *
+ */
+int tipc_named_distribute(struct net *net, u32 dnode, int *bearer_id)
+{
+ struct tipc_net *tn = tipc_net(net);
+ struct sk_buff_head head;
+ int rc = 0;
+
+ __skb_queue_head_init(&head);
+ spin_lock_bh(&tn->nametbl_lock);
+ rc = __tipc_named_distribute(net, dnode, &head);
+ if (!rc && !skb_queue_empty(&head))
+ rc = tipc_node_distribute(net, &head, dnode, bearer_id, 0);
+ spin_unlock_bh(&tn->nametbl_lock);
+
+ /* The link is congested after the list is inserted into
+ * the link's send queue. Return 0, as this is normal.
+ */
+ if (rc == -ELINKCONG)
+ rc = 0;
+
+ return rc;
}
/**
@@ -219,8 +301,9 @@ int tipc_named_node_up(struct net *net, u32 dnode,
spin_lock_bh(&tn->nametbl_lock);
if (!(capabilities & TIPC_NAMED_BCAST))
nt->rc_dests++;
- named_distribute(net, &head, dnode, &nt->cluster_scope, nt->snd_nxt);
- if (!skb_queue_empty(&head))
+
+ rc = __tipc_named_distribute(net, dnode, &head);
+ if (!rc && !skb_queue_empty(&head))
rc = tipc_node_distribute(net, &head, dnode, bearer_id, 0);
spin_unlock_bh(&tn->nametbl_lock);
diff --git a/net/tipc/name_distr.h b/net/tipc/name_distr.h
index 767f9f69624d..a5f11265c3bb 100644
--- a/net/tipc/name_distr.h
+++ b/net/tipc/name_distr.h
@@ -76,5 +76,6 @@ void tipc_named_rcv(struct net *net, struct sk_buff_head *namedq,
void tipc_named_reinit(struct net *net);
void tipc_publ_notify(struct net *net, struct list_head *nsub_list,
u32 addr, u16 capabilities);
+int tipc_named_distribute(struct net *net, u32 dnode, int *bearer_id);
#endif
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index 6bb0333f39bf..5db218394444 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -789,26 +789,34 @@ void tipc_nametbl_build_group(struct net *net, struct tipc_group *grp,
rcu_read_unlock();
}
-/* tipc_nametbl_publish - add service binding to name table
+/**
+ * tipc_nametbl_insert - insert service binding into name table
+ * @net: network namespace
+ * @ua: the service range is binding to
+ * @sk: address publishing socket
+ * @key: target publication key
+ * @skb: buffer containing the publication
+ * @err: error code
+ *
+ * Return:
+ * * Inserted publication - Success
+ * * -ENOBUFS - No buffer space is available
+ *
*/
-struct publication *tipc_nametbl_publish(struct net *net, struct tipc_uaddr *ua,
- struct tipc_socket_addr *sk,
- u32 key, int *err)
+struct publication *tipc_nametbl_insert(struct net *net, struct tipc_uaddr *ua,
+ struct tipc_socket_addr *sk, u32 key,
+ struct sk_buff **skb, int *err)
{
struct name_table *nt = tipc_name_table(net);
u32 max_user_pub = TIPC_MAX_PUBL - 1;
- struct tipc_net *tn = tipc_net(net);
struct publication *p = NULL;
- struct sk_buff *skb = NULL;
bool protocol_type = false;
int error = 0;
- u32 rc_dests;
if (ua->sr.type == TIPC_NODE_STATE || ua->sr.type == TIPC_LINK_STATE ||
ua->sr.type == TIPC_TOP_SRV)
protocol_type = true;
- spin_lock_bh(&tn->nametbl_lock);
if (protocol_type)
goto insert;
@@ -831,24 +839,91 @@ struct publication *tipc_nametbl_publish(struct net *net, struct tipc_uaddr *ua,
*/
if (!protocol_type)
nt->local_publ_count++;
- skb = tipc_named_publish(net, p);
+ *skb = tipc_named_publish(net, p);
/* Local-scope publication is not published (skb is NULL).
* For cluster-cope one, skb is NULL when named_prepare_buf()
* returns NULL in tipc_named_publish().
*/
- if (!skb && p->scope == TIPC_CLUSTER_SCOPE && err)
+ if (!*skb && p->scope == TIPC_CLUSTER_SCOPE && err)
*err = -ENOBUFS;
} else if ((error == -ENOBUFS) && err) {
*err = -ENOBUFS;
}
- rc_dests = nt->rc_dests;
exit:
+ return p;
+}
+
+/* tipc_nametbl_publish - add service binding to name table
+ */
+struct publication *tipc_nametbl_publish(struct net *net, struct tipc_uaddr *ua,
+ struct tipc_socket_addr *sk,
+ u32 key, int *err)
+{
+ struct name_table *nt = tipc_name_table(net);
+ struct tipc_net *tn = tipc_net(net);
+ struct publication *p = NULL;
+ struct sk_buff *skb = NULL;
+ u32 rc_dests;
+
+ spin_lock_bh(&tn->nametbl_lock);
+ p = tipc_nametbl_insert(net, ua, sk, key, &skb, err);
+ rc_dests = nt->rc_dests;
spin_unlock_bh(&tn->nametbl_lock);
if (skb)
tipc_node_broadcast(net, skb, rc_dests);
return p;
+}
+
+/**
+ * tipc_nametb_insert_self_node_pub - insert publication of node's self address
+ * @net: network namespace
+ *
+ * Return:
+ * * 0 - Success
+ * * -ENOBUFS - No buffer space is available
+ *
+ */
+int tipc_nametb_insert_self_node_pub(struct net *net)
+{
+ struct name_table *nt = tipc_name_table(net);
+ struct tipc_net *tn = tipc_net(net);
+ struct publication *p = NULL;
+ struct tipc_socket_addr sk;
+ struct tipc_uaddr ua;
+ int err = 0;
+
+ sk.ref = 0;
+ sk.node = tn->node_addr;
+ tipc_uaddr(&ua, TIPC_SERVICE_RANGE, TIPC_CLUSTER_SCOPE,
+ TIPC_NODE_STATE, tn->node_addr, tn->node_addr);
+
+ p = tipc_nametbl_insert_publ(net, &ua, &sk, tn->node_addr, &err);
+
+ if (p) {
+ list_add_tail(&p->binding_node, &nt->cluster_scope);
+ return 0;
+
+ } else if (err == -EEXIST) {
+ bool found = false;
+
+ list_for_each_entry(p, &nt->cluster_scope, binding_node) {
+ if (p->sr.type == TIPC_NODE_STATE &&
+ p->sr.lower == tn->node_addr &&
+ p->sr.upper == tn->node_addr &&
+ p->key == tn->node_addr &&
+ p->sk.ref == 0 && p->sk.node == tn->node_addr) {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found)
+ list_add_tail(&p->binding_node, &nt->cluster_scope);
+ return 0;
+ }
+ return -ENOBUFS;
}
/**
diff --git a/net/tipc/name_table.h b/net/tipc/name_table.h
index a66975ef8546..4d421548705c 100644
--- a/net/tipc/name_table.h
+++ b/net/tipc/name_table.h
@@ -123,6 +123,9 @@ bool tipc_nametbl_lookup_group(struct net *net, struct tipc_uaddr *ua,
u32 exclude, bool mcast);
void tipc_nametbl_build_group(struct net *net, struct tipc_group *grp,
struct tipc_uaddr *ua);
+struct publication *tipc_nametbl_insert(struct net *net, struct tipc_uaddr *ua,
+ struct tipc_socket_addr *sk, u32 key,
+ struct sk_buff **skb, int *err);
struct publication *tipc_nametbl_publish(struct net *net, struct tipc_uaddr *ua,
struct tipc_socket_addr *sk,
u32 key, int *err);
@@ -132,6 +135,7 @@ struct publication *tipc_nametbl_insert_publ(struct net *net,
struct tipc_uaddr *ua,
struct tipc_socket_addr *sk,
u32 key, int *err);
+int tipc_nametb_insert_self_node_pub(struct net *net);
struct publication *tipc_nametbl_remove_publ(struct net *net,
struct tipc_uaddr *ua,
struct tipc_socket_addr *sk,
diff --git a/net/tipc/net.c b/net/tipc/net.c
index 82f6d2f6ab89..2114c5ef09a9 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -125,9 +125,13 @@ int tipc_net_init(struct net *net, u8 *node_id, u32 addr)
static void tipc_net_finalize(struct net *net, u32 addr)
{
- struct tipc_net *tn = tipc_net(net);
+ struct name_table *nt = tipc_name_table(net);
struct tipc_socket_addr sk = {0, addr};
+ struct tipc_net *tn = tipc_net(net);
+ struct publication *p = NULL;
+ struct sk_buff *skb = NULL;
struct tipc_uaddr ua;
+ u32 rc_dests;
int err = 0;
tipc_uaddr(&ua, TIPC_SERVICE_RANGE, TIPC_CLUSTER_SCOPE,
@@ -139,7 +143,17 @@ static void tipc_net_finalize(struct net *net, u32 addr)
tipc_named_reinit(net);
tipc_sk_reinit(net);
tipc_mon_reinit_self(net);
- tipc_nametbl_publish(net, &ua, &sk, addr, &err);
+ spin_lock_bh(&tn->nametbl_lock);
+ if (!tn->nt_self_node_exist)
+ p = tipc_nametbl_insert(net, &ua, &sk, addr, &skb, &err);
+
+ if (p || err == -EEXIST)
+ tn->nt_self_node_exist = true;
+ rc_dests = nt->rc_dests;
+ spin_unlock_bh(&tn->nametbl_lock);
+
+ if (skb)
+ tipc_node_broadcast(net, skb, rc_dests);
}
void tipc_net_finalize_work(struct work_struct *work)
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 77979a850df2..496ef262f315 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -111,6 +111,7 @@ struct tipc_bclink_entry {
* @peer_net: peer's net namespace
* @peer_hash_mix: hash for this peer (FIXME)
* @crypto_rx: RX crypto handler
+ * @dist_bulk: flag to redistribute cluster-scope publications
*/
struct tipc_node {
u32 addr;
@@ -145,6 +146,7 @@ struct tipc_node {
#ifdef CONFIG_TIPC_CRYPTO
struct tipc_crypto *crypto_rx;
#endif
+ bool dist_bulk;
};
/* Node FSM states and events:
@@ -400,7 +402,7 @@ static void tipc_node_write_unlock(struct tipc_node *n)
struct net *net = n->net;
u32 flags = n->action_flags;
struct list_head *publ_list;
- int rc = 0, bearer = 0;
+ int rc = 0, bearer = -1;
struct tipc_uaddr ua;
u32 bearer_id, node;
int err = 0;
@@ -421,6 +423,8 @@ static void tipc_node_write_unlock(struct tipc_node *n)
n->action_flags &= ~(TIPC_NOTIFY_NODE_DOWN | TIPC_NOTIFY_NODE_UP |
TIPC_NOTIFY_LINK_DOWN | TIPC_NOTIFY_LINK_UP);
+ if (flags & TIPC_NOTIFY_NODE_DOWN)
+ n->dist_bulk = false;
write_unlock_bh(&n->lock);
if (flags & TIPC_NOTIFY_NODE_DOWN)
@@ -438,17 +442,46 @@ static void tipc_node_write_unlock(struct tipc_node *n)
tipc_nametbl_withdraw(net, &ua, &sk, sk.ref);
}
- if (rc == -ENOBUFS)
- tipc_node_link_down(n, bearer, false);
+ if (rc == -ENOBUFS) {
+ /* tipc_named_node_up() calls tipc_node_distribute() and
+ * tipc_node_distribute() returns -ENOBUFS.
+ */
+ if (bearer != -1) {
+ tipc_node_link_down(n, bearer, false);
+ } else {
+ /* tipc_named_node_up() calls __tipc_named_distribute()
+ * and __tipc_named_distribute() returns -ENOBUFS.
+ * Force the node down to retry distribution.
+ */
+ for (bearer = 0; bearer < MAX_BEARERS; bearer++)
+ tipc_node_link_down(n, bearer, false);
+ return;
+ }
+ }
if (err == -ENOBUFS) {
- if (rc == -ENOBUFS && bearer == bearer_id)
+ /* link has been down already */
+ if (bearer == bearer_id)
return;
tipc_node_link_down(n, bearer_id, false);
}
}
+void tipc_node_set_dist_bulk(struct net *net, u32 addr)
+{
+ struct tipc_node *node;
+
+ node = tipc_node_find(net, addr);
+ if (node) {
+ tipc_node_write_lock(node);
+ if (node_is_up(node))
+ node->dist_bulk = true;
+ tipc_node_write_unlock_fast(node);
+ tipc_node_put(node);
+ }
+}
+
static void tipc_node_assign_peer_net(struct tipc_node *n, u32 hash_mixes)
{
int net_id = tipc_netid(n->net);
@@ -576,6 +609,7 @@ struct tipc_node *tipc_node_create(struct net *net, u32 addr, u8 *peer_id,
INIT_LIST_HEAD(&n->list);
INIT_LIST_HEAD(&n->publ_list);
INIT_LIST_HEAD(&n->conn_sks);
+ n->dist_bulk = false;
skb_queue_head_init(&n->bc_entry.namedq);
skb_queue_head_init(&n->bc_entry.inputq1);
__skb_queue_head_init(&n->bc_entry.arrvq);
@@ -833,9 +867,12 @@ static void tipc_node_timeout(struct timer_list *t)
struct tipc_node *n = timer_container_of(n, t, timer);
struct tipc_link_entry *le;
struct sk_buff_head xmitq;
- int remains = n->link_cnt;
+ bool dist_bulk = false;
+ int remains = 0;
+ int dist_rc = 0;
+ int bearer = -1;
int bearer_id;
- int rc = 0;
+ int rc;
trace_tipc_node_timeout(n, false, " ");
if (!node_is_up(n) && tipc_node_cleanup(n)) {
@@ -850,13 +887,33 @@ static void tipc_node_timeout(struct timer_list *t)
#endif
__skb_queue_head_init(&xmitq);
+ tipc_node_write_lock(n);
/* Initial node interval to value larger (10 seconds), then it will be
* recalculated with link lowest tolerance
*/
- tipc_node_read_lock(n);
n->keepalive_intv = 10000;
- tipc_node_read_unlock(n);
+ remains = n->link_cnt;
+ if (n->dist_bulk) {
+ dist_bulk = true;
+ n->dist_bulk = false;
+ }
+ tipc_node_write_unlock_fast(n);
+ if (dist_bulk)
+ dist_rc = tipc_named_distribute(n->net, n->addr, &bearer);
+
for (bearer_id = 0; remains && (bearer_id < MAX_BEARERS); bearer_id++) {
+ /* 1. tipc_named_distribute() calls tipc_node_distribute() and
+ * tipc_node_distribute() returns -ENOBUFS.
+ * 2. tipc_named_distribute() calls __tipc_named_distribute()
+ * and __tipc_named_distribute() returns -ENOBUFS.
+ */
+ if (dist_rc == -ENOBUFS &&
+ (bearer == -1 || bearer == bearer_id)) {
+ rc = TIPC_LINK_DOWN_EVT;
+ goto link_down;
+ }
+
+ rc = 0;
tipc_node_read_lock(n);
le = &n->links[bearer_id];
if (le->link) {
@@ -869,6 +926,7 @@ static void tipc_node_timeout(struct timer_list *t)
}
tipc_node_read_unlock(n);
tipc_bearer_xmit(n->net, bearer_id, &xmitq, &le->maddr, n);
+link_down:
if (rc & TIPC_LINK_DOWN_EVT)
tipc_node_link_down(n, bearer_id, false);
}
diff --git a/net/tipc/node.h b/net/tipc/node.h
index 499e8ea8c753..cff34e1a8bc3 100644
--- a/net/tipc/node.h
+++ b/net/tipc/node.h
@@ -131,4 +131,5 @@ int tipc_nl_node_set_key(struct sk_buff *skb, struct genl_info *info);
int tipc_nl_node_flush_key(struct sk_buff *skb, struct genl_info *info);
#endif
void tipc_node_pre_cleanup_net(struct net *exit_net);
+void tipc_node_set_dist_bulk(struct net *net, u32 addr);
#endif
--
2.53.0
^ permalink raw reply related [flat|nested] 13+ messages in thread* Re: [PATCH net v3 7/7] tipc: fix NULL pointer dereference in named_distribute()
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
0 siblings, 0 replies; 13+ messages in thread
From: netdev-bot+sashiko @ 2026-11-17 18:37 UTC (permalink / raw)
To: tung.quang.nguyen
Cc: netdev, davem, kuba, edumazet, pabeni, jmaloy, horms,
tipc-discussion, syzbot+64197f7577a09686ffdb, lkp
Thank you for your contribution! Sashiko AI review found 9 potential
issue(s) to consider.
Critical: 0 · High: 3 · Medium: 2 · Low: 4
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).
- [High] tipc_nametb_insert_self_node_pub() (net/tipc/name_table.c)
corrupts nt->cluster_scope in its -EEXIST branch.
- [High] tipc_service_insert_publ() (net/tipc/name_table.c) erases and
kfree()s a service_range that still holds live publications whenever…
- [High] tipc: use-after-free of service_range on -EEXIST in
tipc_service_insert_publ()
- [Medium] tipc_node_write_unlock() (net/tipc/node.c) no longer resets
the link when the TIPC_LINK_STATE publication fails with -ENOBUFS.
- [Medium] On the deferred node-timer path, a failed bulk is never
retried when the peer has more than one link.
- [Low] The -EEXIST check in tipc_net_finalize() (net/tipc/net.c) is dead
code, because the caller and callee disagree on the contract.
- [Low] The commit message leaves out several behaviour changes and
slightly misdescribes how the publication reaches other nodes.
- [Low] The commit carries `Reported-by: kernel test robot
<lkp@intel.com>` and `Closes: https://lore.kernel.org/oe-kbuild-…
- [Low] The kernel-doc for tipc_nametbl_insert() (net/tipc/name_table.c)
says it returns "Inserted publication - Success" and "-ENOBUFS - No…
--
tipc: fix NULL pointer dereference in named_distribute()
This patch fixes a race in which tipc_named_node_up() can run
named_distribute() before tipc_net_finalize() has published the node's own
TIPC_NODE_STATE binding. In that case the bulk list is empty and NULL gets
dereferenced. The fix adds an nt_self_node_exist flag and inserts the self
publication on demand from the node-up and node-timeout paths; while the
own address is unset, the bulk is deferred to the node timer.
named_distribute() now returns -ENOBUFS on allocation failure, and the
callers reset links to retry.
> Fix the this issue by checking for the node's self-address publication on
> either node-up or node-timeout event. If the publication does not exist, insert
> it into the name table and publish it to the other nodes.
[Severity: Low]
This isn't a bug, but there's a typo: "Fix the this issue".
Is "publish it to the other nodes" accurate?
tipc_nametb_insert_self_node_pub() doesn't broadcast anything. It only
links the publication into nt->cluster_scope, so the publication goes out
inside the per-destination bulk.
The log also leaves out several behaviour changes:
- When the own address is still 0, bulk distribution is now deferred to
the node keepalive timer through the new per-node dist_bulk flag. This
can delay binding propagation by up to one keepalive interval (10 s at
first).
- named_distribute() now purges a partial bulk on allocation failure and
returns -ENOBUFS. A __tipc_named_distribute() failure now takes every
bearer to the peer down, in both tipc_node_write_unlock() and
tipc_node_timeout(). Before, a partial bulk was sent and nothing was
reset.
- tipc_node_timeout() now takes the node write lock, calls into the name
distributor and may reset links.
- The -ENOBUFS bearer handling in tipc_node_write_unlock() has changed.
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202611022356.UddfVq4D-lkp@intel.com/
[Severity: Low]
Should these two tags be here? The v3 changelog says "Initialize p to NULL
in tipc_net_finalize() to address a warning", and the report ID date
matches the v2 posting. So this looks like a robot report against v2 of
this same patch.
The robot's instructions ask for these tags only when the fix goes in as a
separate commit, not as a new version of the same patch.
> diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
> index 6bb0333f39bf4..5db2183944445 100644
> --- a/net/tipc/name_table.c
> +++ b/net/tipc/name_table.c
> @@ -789,26 +789,34 @@ void tipc_nametbl_build_group(struct net *net, struct tipc_group *grp,
> rcu_read_unlock();
> }
>
> -/* tipc_nametbl_publish - add service binding to name table
> +/**
> + * tipc_nametbl_insert - insert service binding into name table
> + * @net: network namespace
> + * @ua: the service range is binding to
> + * @sk: address publishing socket
> + * @key: target publication key
> + * @skb: buffer containing the publication
> + * @err: error code
> + *
> + * Return:
> + * * Inserted publication - Success
> + * * -ENOBUFS - No buffer space is available
> + *
> */
[Severity: Low]
This isn't a bug, but the Return: section doesn't match the function.
tipc_nametbl_insert() returns struct publication *, and every exit is
"return p;". No path returns -ENOBUFS or ERR_PTR(-ENOBUFS).
The outcomes that can actually happen are:
non-NULL p, *err = -ENOBUFS (skb allocation in tipc_named_publish() failed)
NULL, *err = -ENOBUFS (publication allocation failed)
NULL, *err untouched (local publication limit reached)
NULL, *err untouched (duplicate, -EEXIST)
The v3 changelog says this comment was corrected. Could it describe these
cases instead?
> -struct publication *tipc_nametbl_publish(struct net *net, struct tipc_uaddr *ua,
> - struct tipc_socket_addr *sk,
> - u32 key, int *err)
> +struct publication *tipc_nametbl_insert(struct net *net, struct tipc_uaddr *ua,
> + struct tipc_socket_addr *sk, u32 key,
> + struct sk_buff **skb, int *err)
[ ... ]
> @@ -831,24 +839,91 @@ struct publication *tipc_nametbl_publish(struct net *net, struct tipc_uaddr *ua,
[ ... ]
> +int tipc_nametb_insert_self_node_pub(struct net *net)
> +{
> + struct name_table *nt = tipc_name_table(net);
> + struct tipc_net *tn = tipc_net(net);
> + struct publication *p = NULL;
> + struct tipc_socket_addr sk;
> + struct tipc_uaddr ua;
> + int err = 0;
> +
> + sk.ref = 0;
> + sk.node = tn->node_addr;
> + tipc_uaddr(&ua, TIPC_SERVICE_RANGE, TIPC_CLUSTER_SCOPE,
> + TIPC_NODE_STATE, tn->node_addr, tn->node_addr);
> +
> + p = tipc_nametbl_insert_publ(net, &ua, &sk, tn->node_addr, &err);
[Severity: High]
This new caller relies on the -EEXIST handling in
tipc_service_insert_publ(). That handling was added by the earlier patch in
this series, "tipc: fix missing link-up event on memory allocation
failure". Is it safe?
-EEXIST is only set from inside the walk over sr->all_publ, so the range is
never empty when it is set. The exit path still does this:
net/tipc/name_table.c:tipc_service_insert_publ() {
...
exit:
if (!res) {
if (err && *err == -EEXIST) {
rb_erase_augmented(&sr->tree_node, &sc->ranges,
&sr_callbacks);
kfree(sr);
}
...
}
Doesn't this free a service_range that still holds the publication that
caused the -EEXIST, along with any siblings? Their all_publ and local_publ
links would then point into freed memory.
Those publications are also no longer reachable through the rb-tree.
tipc_nametbl_remove_publ(), tipc_publ_purge() and tipc_service_delete()
can't find them, and lookups no longer see the binding.
A cluster peer can reach this too. tipc_named_rcv()->tipc_update_nametbl()
inserts peer-supplied items with &err, so a peer sending the same distr_item
twice would leak publications and drop bindings each time.
> +
> + if (p) {
> + list_add_tail(&p->binding_node, &nt->cluster_scope);
> + return 0;
> +
> + } else if (err == -EEXIST) {
> + bool found = false;
> +
> + list_for_each_entry(p, &nt->cluster_scope, binding_node) {
> + if (p->sr.type == TIPC_NODE_STATE &&
> + p->sr.lower == tn->node_addr &&
> + p->sr.upper == tn->node_addr &&
> + p->key == tn->node_addr &&
> + p->sk.ref == 0 && p->sk.node == tn->node_addr) {
> + found = true;
> + break;
> + }
> + }
> +
> + if (!found)
> + list_add_tail(&p->binding_node, &nt->cluster_scope);
> + return 0;
[Severity: High]
When tipc_nametbl_insert_publ() returns with err == -EEXIST, this
branch assumes the duplicate publication is still intact in the name
table and goes looking for it on nt->cluster_scope. Is that still true
with the -EEXIST handling added earlier in this series by "tipc: fix
missing link-up event on memory allocation failure"?
tipc_service_insert_publ() only sets -EEXIST after it finds a matching
_p while walking sr->all_publ. So sr is always a pre-existing range
that still holds that publication. The exit path frees it anyway:
if (!res) {
if (err && *err == -EEXIST) {
rb_erase_augmented(&sr->tree_node, &sc->ranges,
&sr_callbacks);
kfree(sr);
}
...
}
That frees sr while _p, and any other publication with the same
lower/upper, is still linked to it through all_publ and local_publ.
Those publications are also no longer reachable from sc->ranges, so
lookups lose the binding. A later tipc_nametbl_remove_publ(),
tipc_publ_purge() or tipc_service_delete() on them would then touch
freed list heads.
This new caller is not the only way in. tipc_nametbl_insert() always
passes its local error to tipc_nametbl_insert_publ(), so a duplicate
local bind through tipc_sk_publish() -> tipc_nametbl_publish() gets
here too. So does a peer that sends the same distr_item twice, via
tipc_named_rcv() -> tipc_update_nametbl().
The range can never be empty on the -EEXIST path. Could the erase be
dropped for -EEXIST, or limited to a range that
tipc_service_create_range() just allocated and that still has an empty
all_publ?
[Severity: High]
Can this corrupt nt->cluster_scope? When nothing matches, the
list_for_each_entry() loop has run to the end. p is then
container_of(&nt->cluster_scope, struct publication, binding_node), not a
real publication, so the call becomes:
list_add_tail(&nt->cluster_scope, &nt->cluster_scope);
That leaves head->next pointing at the head. Forward walks then see an
empty list, and every existing cluster-scope publication is orphaned. With
CONFIG_DEBUG_LIST or CONFIG_LIST_HARDENED, __list_add_valid() should
complain instead.
There is also no new publication to add on this path:
tipc_nametbl_insert_publ() has already freed the one it allocated.
The function still returns 0, so __tipc_named_distribute() sets the flag:
if (!tn->nt_self_node_exist) {
if (tipc_nametb_insert_self_node_pub(net))
return -ENOBUFS;
tn->nt_self_node_exist = true;
}
named_distribute() then walks what looks like an empty cluster_scope, skb
stays NULL, and this line, which still has no guard, dereferences NULL:
hdr = buf_msg(skb_peek_tail(list));
Wouldn't that bring back the same syzbot crash this patch is meant to fix,
with the flag set so the state never gets repaired?
The !found case seems reachable because the -EEXIST test in
tipc_service_insert_publ() is broader than the match above:
if (_p->key == key && _p->sk.ref == p->sk.ref &&
(!_p->sk.node || _p->sk.node == node)) {
Here is one way to get there:
1. Our own address is still 0.
2. A peer whose address equals our future trial address sends its own
TIPC_NODE_STATE [Y,Y] publication.
3. tipc_net_finalize() doesn't set the flag. Either tipc_publ_create()
fails under GFP_ATOMIC, or the -EEXIST check in tipc_net_finalize()
never fires (see below).
The next node-up or node-timeout distribution then takes this branch.
> + }
>
> + return -ENOBUFS;
> }
[ ... ]
> diff --git a/net/tipc/net.c b/net/tipc/net.c
> index 82f6d2f6ab892..2114c5ef09a90 100644
> --- a/net/tipc/net.c
> +++ b/net/tipc/net.c
[ ... ]
> @@ -139,7 +143,17 @@ static void tipc_net_finalize(struct net *net, u32 addr)
> tipc_named_reinit(net);
> tipc_sk_reinit(net);
> tipc_mon_reinit_self(net);
> - tipc_nametbl_publish(net, &ua, &sk, addr, &err);
> + spin_lock_bh(&tn->nametbl_lock);
> + if (!tn->nt_self_node_exist)
> + p = tipc_nametbl_insert(net, &ua, &sk, addr, &skb, &err);
> +
> + if (p || err == -EEXIST)
> + tn->nt_self_node_exist = true;
[Severity: Low]
Can err ever be -EEXIST here? tipc_nametbl_insert() passes its own local
error to tipc_nametbl_insert_publ(), and the only value it copies back is
-ENOBUFS:
} else if ((error == -ENOBUFS) && err) {
*err = -ENOBUFS;
}
So if this insert hits a duplicate, nt_self_node_exist stays false. The next
node-up or node-timeout then reaches the -EEXIST branch of
tipc_nametb_insert_self_node_pub() discussed above.
For now the range erase on -EEXIST in tipc_service_insert_publ() hides
this, because the second insert lands in a fresh range. Once that erase is
fixed, this path leads into the cluster_scope corruption.
> + rc_dests = nt->rc_dests;
> + spin_unlock_bh(&tn->nametbl_lock);
[ ... ]
> diff --git a/net/tipc/node.c b/net/tipc/node.c
> index 77979a850df24..496ef262f315b 100644
> --- a/net/tipc/node.c
> +++ b/net/tipc/node.c
[ ... ]
> @@ -438,17 +442,46 @@ static void tipc_node_write_unlock(struct tipc_node *n)
[ ... ]
> if (err == -ENOBUFS) {
> - if (rc == -ENOBUFS && bearer == bearer_id)
> + /* link has been down already */
> + if (bearer == bearer_id)
> return;
>
> tipc_node_link_down(n, bearer_id, false);
> }
> }
[Severity: Medium]
Without the rc == -ENOBUFS check, is the comment still right?
tipc_node_build_list() sets the bearer whether or not the send succeeds:
*bearer_id = n->active_links[selector & 1];
So after a successful tipc_named_node_up(), bearer is no longer -1.
On the first link to a peer, __tipc_node_link_up() sets both
TIPC_NOTIFY_LINK_UP and TIPC_NOTIFY_NODE_UP. n->link_id carries that local
bearer in its low 16 bits, and the same bearer is in active_links[0].
Say the bulk goes out fine (rc == 0, or -ELINKCONG mapped to 0), but
tipc_nametbl_publish() for TIPC_LINK_STATE fails with -ENOBUFS. Then this
returns without calling tipc_node_link_down().
Doesn't that undo the retry added by the earlier series patch "tipc: fix
missing link-up event on memory allocation failure"? TIPC_LINK_STATE
subscribers would never see the link-up event.
[ ... ]
> @@ -850,13 +887,33 @@ static void tipc_node_timeout(struct timer_list *t)
> #endif
> __skb_queue_head_init(&xmitq);
>
> + tipc_node_write_lock(n);
> /* Initial node interval to value larger (10 seconds), then it will be
> * recalculated with link lowest tolerance
> */
> - tipc_node_read_lock(n);
> n->keepalive_intv = 10000;
> - tipc_node_read_unlock(n);
> + remains = n->link_cnt;
> + if (n->dist_bulk) {
> + dist_bulk = true;
> + n->dist_bulk = false;
> + }
> + tipc_node_write_unlock_fast(n);
> + if (dist_bulk)
> + dist_rc = tipc_named_distribute(n->net, n->addr, &bearer);
> +
> for (bearer_id = 0; remains && (bearer_id < MAX_BEARERS); bearer_id++) {
> + /* 1. tipc_named_distribute() calls tipc_node_distribute() and
> + * tipc_node_distribute() returns -ENOBUFS.
> + * 2. tipc_named_distribute() calls __tipc_named_distribute()
> + * and __tipc_named_distribute() returns -ENOBUFS.
> + */
> + if (dist_rc == -ENOBUFS &&
> + (bearer == -1 || bearer == bearer_id)) {
> + rc = TIPC_LINK_DOWN_EVT;
> + goto link_down;
> + }
[Severity: Medium]
What happens if the peer has more than one link when the deferred bulk
fails? Suppose tipc_node_distribute() returns -ENOBUFS, for example from a
SYSTEM-importance backlog overflow or a failed skb_clone() in
tipc_link_xmit(). Then bearer holds active_links[0], and only that bearer
is taken down. n->dist_bulk was cleared above and is never set again.
This timer can fire up to one keepalive interval after node-up, so a second
link may be up by then. Taking one link down only triggers failover. The
node stays up, so no new TIPC_NOTIFY_NODE_UP runs tipc_named_node_up(), and
nothing sets dist_bulk again.
Would the peer then never receive the bulk carrying last_bulk? Its
bc_entry.named_open in tipc_named_dequeue() would stay false, and later
non-bulk publications from this node would be held indefinitely.
The __tipc_named_distribute() failure case takes all bearers down to
"Force the node down to retry distribution". This path doesn't.
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261116063529.6185-1-tung.quang.nguyen%40est.tech
^ permalink raw reply [flat|nested] 13+ messages in thread