Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tipc: make node link identity publish thread safe

The using of the node address and node link identity are not thread safe,
meaning that two publications may be published the same values, as result
one of them will get failure because of already existing in the name table.
To avoid this we have to use the node address and node link identity values
from inside the node item's write lock protection.

Fixes: 50a3499ab853 ("tipc: simplify signature of tipc_namtbl_publish()")
Acked-by: Jon Maloy <jmaloy@redhat.com>
Signed-off-by: Hoang Le <hoang.h.le@dektech.com.au>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Hoang Le and committed by
David S. Miller
3058e01d b94cbc90

+6 -6
+6 -6
net/tipc/node.c
··· 423 423 write_unlock_bh(&n->lock); 424 424 425 425 if (flags & TIPC_NOTIFY_NODE_DOWN) 426 - tipc_publ_notify(net, publ_list, n->addr, n->capabilities); 426 + tipc_publ_notify(net, publ_list, sk.node, n->capabilities); 427 427 428 428 if (flags & TIPC_NOTIFY_NODE_UP) 429 - tipc_named_node_up(net, n->addr, n->capabilities); 429 + tipc_named_node_up(net, sk.node, n->capabilities); 430 430 431 431 if (flags & TIPC_NOTIFY_LINK_UP) { 432 - tipc_mon_peer_up(net, n->addr, bearer_id); 433 - tipc_nametbl_publish(net, &ua, &sk, n->link_id); 432 + tipc_mon_peer_up(net, sk.node, bearer_id); 433 + tipc_nametbl_publish(net, &ua, &sk, sk.ref); 434 434 } 435 435 if (flags & TIPC_NOTIFY_LINK_DOWN) { 436 - tipc_mon_peer_down(net, n->addr, bearer_id); 437 - tipc_nametbl_withdraw(net, &ua, &sk, n->link_id); 436 + tipc_mon_peer_down(net, sk.node, bearer_id); 437 + tipc_nametbl_withdraw(net, &ua, &sk, sk.ref); 438 438 } 439 439 } 440 440