Skip to content

Commit d3092b2

Browse files
Tung Nguyendavem330
authored andcommitted
tipc: fix unsafe rcu locking when accessing publication list
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. Signed-off-by: Tung Nguyen <tung.q.nguyen@dektech.com.au> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7ec8dc9 commit d3092b2

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎net/tipc/name_distr.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ struct sk_buff *tipc_named_withdraw(struct net *net, struct publication *publ)
115115
struct sk_buff *buf;
116116
struct distr_item *item;
117117

118-
list_del(&publ->binding_node);
118+
list_del_rcu(&publ->binding_node);
119119

120120
if (publ->scope == TIPC_NODE_SCOPE)
121121
return NULL;
@@ -147,7 +147,7 @@ static void named_distribute(struct net *net, struct sk_buff_head *list,
147147
ITEM_SIZE) * ITEM_SIZE;
148148
u32 msg_rem = msg_dsz;
149149

150-
list_for_each_entry(publ, pls, binding_node) {
150+
list_for_each_entry_rcu(publ, pls, binding_node) {
151151
/* Prepare next buffer: */
152152
if (!skb) {
153153
skb = named_prepare_buf(net, PUBLICATION, msg_rem,

0 commit comments

Comments
 (0)