tipc: fix NULL deref in tipc_named_node_up() on empty publication list
Subsystems (3)
PATCH 1/1 tipc: fix NULL deref in tipc_named_node_up() on empty publication list
named_distribute() builds the bulk messages for @pls into @list and then dereferences the tail skb:
hdr = buf_msg(skb_peek_tail(list)); msg_set_last_bulk(hdr);
If @pls is empty no skb is enqueued, skb_peek_tail() returns NULL, and msg_set_last_bulk() writes through buf_msg(NULL).
tipc_named_node_up() passes &nt->cluster_scope. With a node-id configuration the TIPC_NODE_STATE name is published by tipc_net_finalize() from a work item, which sets the node address before publishing the name. The node accepts links once the address is set, so a link that comes up before the publish runs named_distribute() on an empty cluster_scope:
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
TIPC genl ops use GENL_UNS_ADMIN_PERM, so an unprivileged user can reach this from a user+net namespace.
Return early from named_distribute() when the list is empty, and skip tipc_node_xmit() for an empty chain. The empty chain would otherwise hit tipc_lxc_xmit() -> buf_msg(skb_peek(list)), the same zero-skb case fixed for tipc_link_xmit() in commit b77413446408 ("tipc: fix NULL deref in tipc_link_xmit()").
--- net/tipc/name_distr.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
net/tipc/name_distr.c +6 -2
@@ -192,7 +192,10 @@ 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); } - hdr =buf_msg (skb_peek_tail (list)); + skb =skb_peek_tail (list); +if (!skb) +return ; + hdr =buf_msg (skb);msg_set_last_bulk (hdr);msg_set_named_seqno (hdr, seqno); }
@@ -219,7 +222,8 @@ void tipc_named_node_up(struct net *net, u32 dnode, u16 capabilities)read_lock_bh (&nt->cluster_scope_lock);named_distribute (net, &head, dnode, &nt->cluster_scope, seqno); -tipc_node_xmit (net, &head, dnode,0 ); +if (!skb_queue_empty (&head)) +tipc_node_xmit (net, &head, dnode,0 );read_unlock_bh (&nt->cluster_scope_lock); }
Signature · 1 line
2.43.0
Tung Quang Nguyen
maintainerQuoted 26 lines
Subject: [PATCH net] tipc: fix NULL deref in
tipc_named_node_up()on empty publication list
named_distribute()builds the bulk messages for @pls into @list and then dereferences the tail skb:hdr = buf_msg(skb_peek_tail(list)); msg_set_last_bulk(hdr);If @pls is empty no skb is enqueued,
skb_peek_tail()returns NULL, andmsg_set_last_bulk()writes throughbuf_msg(NULL).
tipc_named_node_up()passes&nt->cluster_scope. With a node-id configuration theTIPC_NODE_STATEname is published bytipc_net_finalize()from a work item, which sets the node address before publishing the name. The node accepts links once the address is set, so a link that comes up before the publish runsnamed_distribute()on an emptycluster_scope: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
Quoted 8 lines
TIPC genl ops use
GENL_UNS_ADMIN_PERM, so an unprivileged user can reach this from a user+net namespace.Return early from
named_distribute()when the list is empty, and skiptipc_node_xmit()for an empty chain. The empty chain would otherwise hittipc_lxc_xmit()-> buf_msg(skb_peek(list)), the same zero-skb case fixed fortipc_link_xmit()in commitb77413446408("tipc: fix NULL deref intipc_link_xmit()").
It needs to return earlier in tipc_named_node_up() like this:
net/tipc/name_distr.c +4 -0
@@ -218,6 +218,10 @@ void tipc_named_node_up(struct net *net, u32 dnode, u16 capabilities)spin_unlock_bh (&tn->nametbl_lock);read_lock_bh (&nt->cluster_scope_lock); +if (list_empty (&nt->cluster_scope)) { +read_unlock_bh (&nt->cluster_scope_lock); +return ; + }named_distribute (net, &head, dnode, &nt->cluster_scope, seqno);tipc_node_xmit (net, &head, dnode,0 );read_unlock_bh (&nt->cluster_scope_lock);
Quoted 40 lines
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| 8 ++++++--1 file changed, 6 insertions(+), 2 deletions(-)net/tipc/name_distr.c index renamed from net/tipc/name_distr.c +0
-0
ba4f4906e13b..c04fea4650a5100644net/tipc/name_distr.c +4
-1@@ -192,7 +192,10 @@ 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); } - hdr =buf_msg (skb_peek_tail (list)); + skb =skb_peek_tail (list); +if (!skb) +return ; + hdr =buf_msg (skb);msg_set_last_bulk (hdr);msg_set_named_seqno (hdr, seqno);}
net/tipc/name_distr.c +2
-2@@ -219,7 +222,8 @@ void tipc_named_node_up(struct net *net, u32 dnode, u16 capabilities) read_lock_bh(&nt->cluster_scope_lock);named_distribute (net, &head, dnode, &nt->cluster_scope, seqno); -tipc_node_xmit (net, &head, dnode,0 ); +if (!skb_queue_empty (&head)) +tipc_node_xmit (net, &head, dnode,0 );read_unlock_bh (&nt->cluster_scope_lock); } --2.43.0
Quoted 91 lines · Tung Quang Nguyen <[email protected]> 于2026年7月6日周一 17:21写道:
Quoted 27 lines
Subject: [PATCH net] tipc: fix NULL deref in
tipc_named_node_up()on empty publication list
named_distribute()builds the bulk messages for @pls into @list and then dereferences the tail skb:hdr = buf_msg(skb_peek_tail(list)); msg_set_last_bulk(hdr);If @pls is empty no skb is enqueued,
skb_peek_tail()returns NULL, andmsg_set_last_bulk()writes throughbuf_msg(NULL).
tipc_named_node_up()passes&nt->cluster_scope. With a node-id configuration theTIPC_NODE_STATEname is published bytipc_net_finalize()from a work item, which sets the node address before publishing the name. The node accepts links once the address is set, so a link that comes up before the publish runsnamed_distribute()on an emptycluster_scope: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
Quoted 8 lines
TIPC genl ops use
GENL_UNS_ADMIN_PERM, so an unprivileged user can reach this from a user+net namespace.Return early from
named_distribute()when the list is empty, and skiptipc_node_xmit()for an empty chain. The empty chain would otherwise hittipc_lxc_xmit()-> buf_msg(skb_peek(list)), the same zero-skb case fixed fortipc_link_xmit()in commitb77413446408("tipc: fix NULL deref intipc_link_xmit()").It needs to return earlier in
tipc_named_node_up()like this:net/tipc/name_distr.c +4
-0@@ -218,6 +218,10 @@ void tipc_named_node_up(struct net *net, u32 dnode, u16 capabilities)spin_unlock_bh (&tn->nametbl_lock);read_lock_bh (&nt->cluster_scope_lock); +if (list_empty (&nt->cluster_scope)) { +read_unlock_bh (&nt->cluster_scope_lock); +return ; + }named_distribute (net, &head, dnode, &nt->cluster_scope, seqno);tipc_node_xmit (net, &head, dnode,0 );read_unlock_bh (&nt->cluster_scope_lock);Quoted 38 lines
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| 8 ++++++--1 file changed, 6 insertions(+), 2 deletions(-)net/tipc/name_distr.c index renamed from net/tipc/name_distr.c +0
-0
ba4f4906e13b..c04fea4650a5100644net/tipc/name_distr.c +4
-1@@ -192,7 +192,10 @@ 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); } - hdr =buf_msg (skb_peek_tail (list)); + skb =skb_peek_tail (list); +if (!skb) +return ; + hdr =buf_msg (skb);msg_set_last_bulk (hdr);msg_set_named_seqno (hdr, seqno);}
net/tipc/name_distr.c +2
-1@@ -219,7 +222,8 @@ void tipc_named_node_up(struct net *net, u32 dnode, u16 capabilities) read_lock_bh(&nt->cluster_scope_lock);named_distribute (net, &head, dnode, &nt->cluster_scope, seqno); -tipc_node_xmit (net, &head, dnode,0 ); +if (!skb_queue_empty (&head)) +tipc_node_xmit (net, &head, dnode,0 );read_unlock_bh (&nt->cluster_scope_lock); }
Quoted 4 lines
Quoted 3 lines
--
2.43.0
Thanks for your review. v2 sent.