Skip to content

Commit

Permalink
openvswitch: Fix race.
Browse files Browse the repository at this point in the history
ovs_vport_cmd_dump() did rcu_read_lock() only after getting the
datapath, which could have been deleted in between.  Resolved by
taking rcu_read_lock() before the get_dp() call.

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
  • Loading branch information
Jarno Rajahalme authored and Jesse Gross committed Feb 16, 2014
1 parent 04382a3 commit 42ee19e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions net/openvswitch/datapath.c
Original file line number Diff line number Diff line change
Expand Up @@ -1762,11 +1762,12 @@ static int ovs_vport_cmd_dump(struct sk_buff *skb, struct netlink_callback *cb)
int bucket = cb->args[0], skip = cb->args[1];
int i, j = 0;

rcu_read_lock();
dp = get_dp(sock_net(skb->sk), ovs_header->dp_ifindex);
if (!dp)
if (!dp) {
rcu_read_unlock();
return -ENODEV;

rcu_read_lock();
}
for (i = bucket; i < DP_VPORT_HASH_BUCKETS; i++) {
struct vport *vport;

Expand Down

0 comments on commit 42ee19e

Please sign in to comment.