Subject: Re: [PATCH net v3 2/7] tipc: fix dangling link in cluster_scope list in
tipc_service_delete()
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.
quoted
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
[ ... ]
quoted
@@ -941,6 +942,13 @@ static void tipc_service_delete(struct net *net, struct
tipc_service *sc)
quoted
rbtree_postorder_for_each_entry_safe(sr, tmpr, &sc->ranges,
tree_node) {quoted
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?
Although it cannot hit a specific bug now, we should not leave hundreds of dangling links
like that in case hundreds of net namespaces are created and destroyed repeatedly. This
may cause unexpected behaviors.
So, Fixes tag is needed.
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?
Yes, I can mention that in the next version.
---
pw-bot: cr