Skip to content

Commit

Permalink
[IPV4] multipath_wrandom: Fix softirq-unsafe spin lock usage
Browse files Browse the repository at this point in the history
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: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Herbert Xu authored and David S. Miller committed Feb 3, 2006
1 parent 27852c2 commit f8addb3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions net/ipv4/multipath_wrandom.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ static void wrandom_set_nhinfo(__u32 network,
struct multipath_dest *d, *target_dest = NULL;

/* 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 */
list_for_each_entry_rcu(r, &state[state_idx].head, list) {
Expand Down Expand Up @@ -276,7 +276,7 @@ static void wrandom_set_nhinfo(__u32 network,
* we are finished
*/

spin_unlock(&state[state_idx].lock);
spin_unlock_bh(&state[state_idx].lock);
}

static void __multipath_free(struct rcu_head *head)
Expand All @@ -302,7 +302,7 @@ static void wrandom_flush(void)
for (i = 0; i < MULTIPATH_STATE_SIZE; ++i) {
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) {
struct multipath_dest *d;
list_for_each_entry_rcu(d, &r->dests, list) {
Expand All @@ -315,7 +315,7 @@ static void wrandom_flush(void)
__multipath_free);
}

spin_unlock(&state[i].lock);
spin_unlock_bh(&state[i].lock);
}
}

Expand Down

0 comments on commit f8addb3

Please sign in to comment.