From: Andrew Stellman <aste…@stellman-greene.com> tipc_node_check_dest() calls tipc_node_create() before it classifies a discovery request. For an established node, found by node address or by peer ID, tipc_node_create() overwrites the node and link capabilities. A request that is then rejected as a duplicate address has already changed them. Because of the peer ID lookup, this also happens when the request carries a node address the receiver doesn't know. Look up the node by address or peer ID first, as tipc_node_create() does. For an established node, do the peer net update that tipc_node_create() did at that point, and call tipc_node_create() only after the request is known not to be a duplicate. New and preliminary nodes still go through tipc_node_create() first. Tested on mainline (7cd8495c0f16) in arm64 QEMU with KASAN, replaying discovery requests over veth between two network namespaces and logging the result with a test-only pr_info. Without this patch, in both of two runs, a duplicate with the peer's node address but a new signature and media address changed the capabilities from 0xfff to 0x1, and one with an unknown node address and the peer's ID changed them to 0x21. With it, both stayed 0xfff in one run. In all three runs, a request with the peer's signature and media address still updated them, and a request with a new signature and media address sent while the link was down was accepted and set them to 0x1. KASAN reported nothing. No selftests were run. Fixes: 60020e185704 ("tipc: propagate peer node capabilities to socket layer") Signed-off-by: Andrew Stellman <aste…@stellman-greene.com> --- The issue was found by Claude Opus 5.5 and Claude Fable 5.2 running Quality Playbook, an LLM-driven code review tool: https://github.com/andrewstellman/quality-playbook The fix was drafted with OpenAI GPT-6 (Codex) and this changelog with Claude Opus 5.5, and both were reviewed by me. A reproducer is available on request. net/tipc/node.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/net/tipc/node.c b/net/tipc/node.c index 53b0993c2c2333..f0e3e06ff8c7bf 100644 --- a/net/tipc/node.c +++ b/net/tipc/node.c @@ -1176,6 +1176,7 @@ void tipc_node_check_dest(struct net *net, u32 addr, struct tipc_media_addr *maddr, bool *respond, bool *dupl_addr) { + struct tipc_net *tn = tipc_net(net); struct tipc_node *n; struct tipc_link *l; struct tipc_link_entry *le; @@ -1185,6 +1186,7 @@ void tipc_node_check_dest(struct net *net, u32 addr, bool link_is_reset = false; bool accept_addr = false; bool reset = false; + bool existing; char *if_name; unsigned long intv; u16 session; @@ -1192,8 +1194,20 @@ void tipc_node_check_dest(struct net *net, u32 addr, *dupl_addr = false; *respond = false; - n = tipc_node_create(net, addr, peer_id, capabilities, hash_mixes, - false); + spin_lock_bh(&tn->node_list_lock); + n = tipc_node_find(net, addr); + if (!n) + n = tipc_node_find_by_id(net, peer_id); + existing = n && !n->preliminary; + if (existing && (n->peer_hash_mix ^ hash_mixes)) + tipc_node_assign_peer_net(n, hash_mixes); + spin_unlock_bh(&tn->node_list_lock); + if (!existing) { + if (n) + tipc_node_put(n); + n = tipc_node_create(net, addr, peer_id, capabilities, + hash_mixes, false); + } if (!n) return; @@ -1310,6 +1324,15 @@ void tipc_node_check_dest(struct net *net, u32 addr, memcpy(&le->maddr, maddr, sizeof(*maddr)); exit: tipc_node_write_unlock(n); + /* Rejected duplicates must not update capabilities. */ + if (existing && !*dupl_addr) { + struct tipc_node *updated; + + updated = tipc_node_create(net, addr, peer_id, capabilities, + hash_mixes, false); + if (updated) + tipc_node_put(updated); + } if (reset && !link_is_reset) tipc_node_link_down(n, b->identity, false); tipc_node_put(n);
-- 2.53.0