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

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>

authored by

Tung Nguyen and committed by
David S. Miller
d3092b2e 7ec8dc96

+2 -2
+2 -2
net/tipc/name_distr.c
··· 115 115 struct sk_buff *buf; 116 116 struct distr_item *item; 117 117 118 - list_del(&publ->binding_node); 118 + list_del_rcu(&publ->binding_node); 119 119 120 120 if (publ->scope == TIPC_NODE_SCOPE) 121 121 return NULL; ··· 147 147 ITEM_SIZE) * ITEM_SIZE; 148 148 u32 msg_rem = msg_dsz; 149 149 150 - list_for_each_entry(publ, pls, binding_node) { 150 + list_for_each_entry_rcu(publ, pls, binding_node) { 151 151 /* Prepare next buffer: */ 152 152 if (!skb) { 153 153 skb = named_prepare_buf(net, PUBLICATION, msg_rem,