aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/node.c
diff options
context:
space:
mode:
authorJon Maloy <jon.maloy@ericsson.com>2018-07-18 13:50:06 -0400
committerDavid S. Miller <davem@davemloft.net>2018-07-20 15:36:13 -0400
commit40999f11ce677ce3c5d0e8f5f76c40192a26b479 (patch)
tree5b5dac9106b60eb5d67e5f204a55ecaeb6db9b43 /net/tipc/node.c
parentf91a0effcaa6a2eec647cdc53d0d16bff5144c10 (diff)
tipc: make link capability update thread safe
The commit referred to below introduced an update of the link capabilities field that is not safe. Given the recently added feature to remove idle node and link items after 5 minutes, there is a small risk that the update will happen at the very moment the targeted link is being removed. To avoid this we have to perform the update inside the node item's write lock protection. Fixes: 9012de508956 ("tipc: add sequence number check for link STATE messages") Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/node.c')
-rw-r--r--net/tipc/node.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/net/tipc/node.c b/net/tipc/node.c
index 52fd80b0e728..3819ab14e073 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -370,13 +370,17 @@ static struct tipc_node *tipc_node_create(struct net *net, u32 addr,
370 spin_lock_bh(&tn->node_list_lock); 370 spin_lock_bh(&tn->node_list_lock);
371 n = tipc_node_find(net, addr); 371 n = tipc_node_find(net, addr);
372 if (n) { 372 if (n) {
373 if (n->capabilities == capabilities)
374 goto exit;
373 /* Same node may come back with new capabilities */ 375 /* Same node may come back with new capabilities */
376 write_lock_bh(&n->lock);
374 n->capabilities = capabilities; 377 n->capabilities = capabilities;
375 for (bearer_id = 0; bearer_id < MAX_BEARERS; bearer_id++) { 378 for (bearer_id = 0; bearer_id < MAX_BEARERS; bearer_id++) {
376 l = n->links[bearer_id].link; 379 l = n->links[bearer_id].link;
377 if (l) 380 if (l)
378 tipc_link_update_caps(l, capabilities); 381 tipc_link_update_caps(l, capabilities);
379 } 382 }
383 write_unlock_bh(&n->lock);
380 goto exit; 384 goto exit;
381 } 385 }
382 n = kzalloc(sizeof(*n), GFP_ATOMIC); 386 n = kzalloc(sizeof(*n), GFP_ATOMIC);