Commit f8addb32 authored by Herbert Xu's avatar Herbert Xu Committed by David S. Miller

[IPV4] multipath_wrandom: Fix softirq-unsafe spin lock usage

The spin locks in multipath_wrandom may be obtained from either process
context or softirq context depending on whether the packet is locally
or remotely generated.  Therefore we need to disable BH processing when
taking these locks.

This bug was found by Ingo's lock validator.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 27852c26
...@@ -228,7 +228,7 @@ static void wrandom_set_nhinfo(__u32 network, ...@@ -228,7 +228,7 @@ static void wrandom_set_nhinfo(__u32 network,
struct multipath_dest *d, *target_dest = NULL; struct multipath_dest *d, *target_dest = NULL;
/* store the weight information for a certain route */ /* store the weight information for a certain route */
spin_lock(&state[state_idx].lock); spin_lock_bh(&state[state_idx].lock);
/* find state entry for gateway or add one if necessary */ /* find state entry for gateway or add one if necessary */
list_for_each_entry_rcu(r, &state[state_idx].head, list) { list_for_each_entry_rcu(r, &state[state_idx].head, list) {
...@@ -276,7 +276,7 @@ static void wrandom_set_nhinfo(__u32 network, ...@@ -276,7 +276,7 @@ static void wrandom_set_nhinfo(__u32 network,
* we are finished * we are finished
*/ */
spin_unlock(&state[state_idx].lock); spin_unlock_bh(&state[state_idx].lock);
} }
static void __multipath_free(struct rcu_head *head) static void __multipath_free(struct rcu_head *head)
...@@ -302,7 +302,7 @@ static void wrandom_flush(void) ...@@ -302,7 +302,7 @@ static void wrandom_flush(void)
for (i = 0; i < MULTIPATH_STATE_SIZE; ++i) { for (i = 0; i < MULTIPATH_STATE_SIZE; ++i) {
struct multipath_route *r; struct multipath_route *r;
spin_lock(&state[i].lock); spin_lock_bh(&state[i].lock);
list_for_each_entry_rcu(r, &state[i].head, list) { list_for_each_entry_rcu(r, &state[i].head, list) {
struct multipath_dest *d; struct multipath_dest *d;
list_for_each_entry_rcu(d, &r->dests, list) { list_for_each_entry_rcu(d, &r->dests, list) {
...@@ -315,7 +315,7 @@ static void wrandom_flush(void) ...@@ -315,7 +315,7 @@ static void wrandom_flush(void)
__multipath_free); __multipath_free);
} }
spin_unlock(&state[i].lock); spin_unlock_bh(&state[i].lock);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment