tipc: fix NULL deref in tipc_named_node_up() on empty publication list
Subsystems (3)
v3 cover tipc: fix NULL deref in tipc_named_node_up() on empty publication list
named_distribute() stamps the last_bulk flag on the tail skb of the publication list. When the list is empty no skb is enqueued and the tail access dereferences NULL. tipc_named_node_up() hits this on an empty cluster_scope, which happens with a node-id configuration where cluster_scope is populated only later by tipc_net_finalize(). It is reachable by an unprivileged user over a UDP bearer in a user+net namespace.
Patch 1 guards tipc_node_xmit() against an empty list, so the allocation- failure path in named_distribute() cannot pass an empty list down to tipc_lxc_xmit(), which has the same tail-of-empty-list deref.
Patch 2 emits an item-less bulk when the publication list is empty, so the peer still receives the last_bulk flag and does not stall this node's later name updates.
Changes in v3:
- Split into two patches; add patch 1 to guard tipc_node_xmit() against the tipc_lxc_xmit() deref reachable via the allocation-failure path.
- Break out of the build loop on allocation failure instead of returning, so the last_bulk flag is still applied to the last queued skb.
Changes in v2:
- Instead of returning early on an empty cluster_scope (which would stall the peer, since it waits for a bulk with the last_bulk flag before accepting later name updates), emit an item-less bulk so the peer opens normally.
Thanks to Tung Quang Nguyen for the review of v1.
Weiming Shi (2):
tipc: guard against empty list in tipc_node_xmit()
tipc: fix NULL deref in tipc_named_node_up() on empty publication list
net/tipc/name_distr.c | 16 +++++++++++++++- net/tipc/node.c | 3 +++ 2 files changed, 18 insertions(+), 1 deletion(-)
base-commit: 4595d2c77ea4bfe4ae0efa38770a59ee5d2f06d3
Signature · 1 line
2.43.0
PATCH v3 1/2 tipc: guard against empty list in tipc_node_xmit()
tipc_node_xmit() passes @list to tipc_lxc_xmit(), which dereferences buf_msg(skb_peek(list)) without checking, so an empty list causes a NULL pointer dereference. named_distribute() can hand it an empty list when a bulk allocation fails. tipc_link_xmit() was already guarded in commit b77413446408 ("tipc: fix NULL deref in tipc_link_xmit()"); guard tipc_node_xmit() itself so the tipc_lxc_xmit() path is covered too.
--- net/tipc/node.c | 3 +++ 1 file changed, 3 insertions(+)
net/tipc/node.c +3 -0
@@ -1695,6 +1695,9 @@ int tipc_node_xmit(struct net *net, struct sk_buff_head *list,int bearer_id;int rc; +if (skb_queue_empty (list)) +return 0 ; +if (in_own_node (net, dnode)) {tipc_loopback_trace (net, list);spin_lock_init (&list->lock);
Signature · 1 line
2.43.0
PATCH v3 2/2 tipc: fix NULL deref in tipc_named_node_up() on empty publication list
In reply to Weiming Shinamed_distribute() ends by stamping the last_bulk flag on the tail skb via buf_msg(skb_peek_tail(list)). When the publication list is empty no skb is enqueued, skb_peek_tail() returns NULL, and buf_msg(NULL) is dereferenced.
tipc_named_node_up() runs this on &nt->cluster_scope. With a node-id configuration cluster_scope is populated only later by tipc_net_finalize(), so a peer link that comes up first reaches named_distribute() with an empty list. It is reachable by an unprivileged user (TIPC genl ops use GENL_UNS_ADMIN_PERM) over a UDP bearer in a user+net namespace:
KASAN: null-ptr-deref in range [0x00000000000000d8-0x00000000000000df] RIP: 0010:tipc_named_node_up (net/tipc/name_distr.c:196) tipc_named_node_up (net/tipc/name_distr.c:196 net/tipc/name_distr.c:221) tipc_node_write_unlock (net/tipc/node.c:428) tipc_rcv (net/tipc/node.c:2185) tipc_udp_recv (net/tipc/udp_media.c:392) Kernel panic - not syncing: Fatal exception in interrupt
The peer holds back this node's later name updates until it sees a bulk with the last_bulk flag, so simply skipping the empty bulk would stall it. Emit an item-less bulk when the list is empty, and break out of the build loop on allocation failure instead of returning, so the last_bulk flag is applied to the last queued skb.
--- net/tipc/name_distr.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
net/tipc/name_distr.c +15 -1
@@ -165,7 +165,7 @@ static void named_distribute(struct net *net, struct sk_buff_head *list, dnode);if (!skb) {pr_warn ("Bulk publication failure\n" ); -return ; +break ; } hdr =buf_msg (skb);msg_set_bc_ack_invalid (hdr, true);
@@ -192,6 +192,20 @@ static void named_distribute(struct net *net, struct sk_buff_head *list,skb_trim (skb,INT_H_SIZE + (msg_dsz - msg_rem));__skb_queue_tail (list, skb); } + +if (skb_queue_empty (list)) { + skb =named_prepare_buf (net,PUBLICATION ,0 , dnode); +if (!skb) { +pr_warn ("Bulk publication failure\n" ); +return ; + } + hdr =buf_msg (skb); +msg_set_bc_ack_invalid (hdr, true); +msg_set_bulk (hdr); +msg_set_non_legacy (hdr); +__skb_queue_tail (list, skb); + } + hdr =buf_msg (skb_peek_tail (list));msg_set_last_bulk (hdr);msg_set_named_seqno (hdr, seqno);
Signature · 1 line
2.43.0
Tung Quang Nguyen
maintainerQuoted 48 lines
named_distribute()ends by stamping thelast_bulkflag on the tail skb via buf_msg(skb_peek_tail(list)). When the publication list is empty no skb is enqueued,skb_peek_tail()returns NULL, andbuf_msg(NULL)is dereferenced.
tipc_named_node_up()runs this on&nt->cluster_scope. With a node-id configurationcluster_scopeis populated only later bytipc_net_finalize(), so a peer link that comes up first reachesnamed_distribute()with an empty list. It is reachable by an unprivileged user (TIPC genl ops useGENL_UNS_ADMIN_PERM) over a UDP bearer in a user+net namespace:KASAN: null-ptr-deref in range [0x00000000000000d8-0x00000000000000df] RIP: 0010:tipc_named_node_up (net/tipc/name_distr.c:196) tipc_named_node_up (net/tipc/name_distr.c:196 net/tipc/name_distr.c:221) tipc_node_write_unlock (net/tipc/node.c:428) tipc_rcv (net/tipc/node.c:2185) tipc_udp_recv (net/tipc/udp_media.c:392) Kernel panic - not syncing: Fatalexception in interrupt
The peer holds back this node's later name updates until it sees a bulk with the
last_bulkflag, so simply skipping the empty bulk would stall it.
Emit an item-less bulk when the list is empty, and break out of the build loop on allocation failure instead of returning, so thelast_bulkflag is applied to the last queued skb.Fixes cad2929dc432 ("tipc: update a binding service via broadcast")Reported-by Xiang Mei <[email protected]>Assisted-by Claude:claude-opus-4-8Signed-off-by Weiming Shi <[email protected]>---
net/tipc/name_distr.c| 16 +++++++++++++++-1 file changed, 15 insertions(+), 1 deletion(-)net/tipc/name_distr.c index renamed from net/tipc/name_distr.c +0
-0
ba4f4906e13b..dbcfa965de34100644net/tipc/name_distr.c +1
-1@@ -165,7 +165,7 @@ static void named_distribute(struct net *net, structsk_buff_head *list, dnode);if (!skb) {pr_warn ("Bulk publication failure\n" ); -return ; +break ; } hdr =buf_msg (skb);msg_set_bc_ack_invalid(hdr, true);net/tipc/name_distr.c +0
-0@@ -192,6 +192,20 @@ static void named_distribute(struct net *net, struct sk_buff_head *list,
net/tipc/name_distr.c static void named_distribute(struct net *net, struct · line 202
Quoted 10 lines
net/tipc/name_distr.c +7
-0skb_trim (skb,INT_H_SIZE + (msg_dsz - msg_rem));__skb_queue_tail (list, skb); } + +if (skb_queue_empty (list)) { + skb =named_prepare_buf (net,PUBLICATION ,0 , dnode); +if (!skb) { +pr_warn ("Bulk publication failure\n" ); +return ; + }
This approach is wrong because:
1. When 'list' is empty, it is caused by memory allocation failure before. So, it is likely that 'skb' could be NULL again because of memory allocation failure.
2. Even if 'skb' is not NULL, allocation of non-data (zero-in-size) message will break the receiving peer when it handles this message.
Quoted 12 lines
net/tipc/name_distr.c +7
-0+ hdr =buf_msg (skb); +msg_set_bc_ack_invalid (hdr, true); +msg_set_bulk (hdr); +msg_set_non_legacy (hdr); +__skb_queue_tail (list, skb); + } + hdr =buf_msg (skb_peek_tail (list));msg_set_last_bulk (hdr);msg_set_named_seqno(hdr, seqno);--
2.43.0
Quoted 55 lines · Tung Quang Nguyen <[email protected]> 于2026年7月16日周四 17:28写道:
Quoted 55 lines
named_distribute()ends by stamping thelast_bulkflag on the tail skb via buf_msg(skb_peek_tail(list)). When the publication list is empty no skb is enqueued,skb_peek_tail()returns NULL, andbuf_msg(NULL)is dereferenced.
tipc_named_node_up()runs this on&nt->cluster_scope. With a node-id configurationcluster_scopeis populated only later bytipc_net_finalize(), so a peer link that comes up first reachesnamed_distribute()with an empty list. It is reachable by an unprivileged user (TIPC genl ops useGENL_UNS_ADMIN_PERM) over a UDP bearer in a user+net namespace:KASAN: null-ptr-deref in range [0x00000000000000d8-0x00000000000000df] RIP: 0010:tipc_named_node_up (net/tipc/name_distr.c:196) tipc_named_node_up (net/tipc/name_distr.c:196 net/tipc/name_distr.c:221) tipc_node_write_unlock (net/tipc/node.c:428) tipc_rcv (net/tipc/node.c:2185) tipc_udp_recv (net/tipc/udp_media.c:392) Kernel panic - not syncing: Fatalexception in interrupt
The peer holds back this node's later name updates until it sees a bulk with the
last_bulkflag, so simply skipping the empty bulk would stall it.
Emit an item-less bulk when the list is empty, and break out of the build loop on allocation failure instead of returning, so thelast_bulkflag is applied to the last queued skb.Fixes cad2929dc432 ("tipc: update a binding service via broadcast")Reported-by Xiang Mei <[email protected]>Assisted-by Claude:claude-opus-4-8Signed-off-by Weiming Shi <[email protected]>---
net/tipc/name_distr.c| 16 +++++++++++++++-1 file changed, 15 insertions(+), 1 deletion(-)net/tipc/name_distr.c index renamed from net/tipc/name_distr.c +0
-0
ba4f4906e13b..dbcfa965de34100644net/tipc/name_distr.c +1
-1@@ -165,7 +165,7 @@ static void named_distribute(struct net *net, structsk_buff_head *list, dnode);if (!skb) {pr_warn ("Bulk publication failure\n" ); -return ; +break ; } hdr =buf_msg (skb);msg_set_bc_ack_invalid(hdr, true);net/tipc/name_distr.c +3
-0@@ -192,6 +192,20 @@ static void named_distribute(struct net *net, struct sk_buff_head *list,skb_trim (skb,INT_H_SIZE + (msg_dsz - msg_rem));__skb_queue_tail (list, skb); } + +if (skb_queue_empty (list)) { + skb =named_prepare_buf (net,PUBLICATION ,0 , dnode);
Quoted 22 lines
net/tipc/name_distr.c static void named_distribute(struct net *net, struct sk_buff_head *list, · line 201
Quoted 4 lines
net/tipc/name_distr.c +4
-0+if (!skb) { +pr_warn ("Bulk publication failure\n" ); +return ; + }This approach is wrong because:
1. When 'list' is empty, it is caused by memory allocation failure before. So, it is likely that 'skb' could be NULL again because of memory allocation failure.
2. Even if 'skb' is not NULL, allocation of non-data (zero-in-size) message will break the receiving peer when it handles this message.Quoted 12 lines
net/tipc/name_distr.c +7
-0+ hdr =buf_msg (skb); +msg_set_bc_ack_invalid (hdr, true); +msg_set_bulk (hdr); +msg_set_non_legacy (hdr); +__skb_queue_tail (list, skb); + } + hdr =buf_msg (skb_peek_tail (list));msg_set_last_bulk (hdr);msg_set_named_seqno(hdr, seqno);--
2.43.0
Thanks for your review. Fixed and v4 sent.