Skip to contentSkip to conversation

tipc: fix unsafe rcu locking when accessing publication list

PATCH In review Jon Maloy 2 participants 2 messages Oct 13, 2018 – Oct 16, 2018

Subsystems (3)
lore
Share & tools
lore

Jon Maloy

author
#0 lore raw

PATCH 1/1 tipc: fix unsafe rcu locking when accessing publication list

From: Tung Nguyen <[email protected]>

The binding table's 'cluster_scope' list is rcu protected to handle races between threads changing the list and those traversing the list at the same moment. We have now found that the function named_distribute() uses the regular list_for_each() macro to traverse the said list. Likewise, the function tipc_named_withdraw() is removing items from the same list using the regular list_del() call. When these two functions execute in parallel we see occasional crashes.

This commit fixes this by adding the missing _rcu() suffixes.

---
 net/tipc/name_distr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/tipc/name_distr.c +2 -2
index 51b4b96..3cfeb9d 100644
@@ -115,7 +115,7 @@ struct sk_buff *tipc_named_withdraw(struct net *net, struct publication *publ)
 	struct sk_buff *buf;
 	struct distr_item *item;
 
-	list_del(&publ->binding_node);
+	list_del_rcu(&publ->binding_node);
 
 	if (publ->scope == TIPC_NODE_SCOPE)
 		return NULL;
@@ -147,7 +147,7 @@ static void named_distribute(struct net *net, struct sk_buff_head *list,
 			ITEM_SIZE) * ITEM_SIZE;
 	u32 msg_rem = msg_dsz;
 
-	list_for_each_entry(publ, pls, binding_node) {
+	list_for_each_entry_rcu(publ, pls, binding_node) {
 		/* Prepare next buffer: */
 		if (!skb) {
 			skb = named_prepare_buf(net, PUBLICATION, msg_rem,
Signature · 1 line
2.1.4
maintainer
#1 lore raw

From: Jon Maloy <[email protected]>
Date: Fri, 12 Oct 2018 22:46:55 +0200

Quoted 10 lines

From: Tung Nguyen <[email protected]>

The binding table's 'cluster_scope' list is rcu protected to handle races between threads changing the list and those traversing the list at the same moment. We have now found that the function named_distribute() uses the regular list_for_each() macro to traverse the said list. Likewise, the function tipc_named_withdraw() is removing items from the same list using the regular list_del() call. When these two functions execute in parallel we see occasional crashes.

Quoted 4 lines

This commit fixes this by adding the missing _rcu() suffixes.

Applied and queued up for -stable.