Skip to content

Commit

Permalink
xfrm: Take xfrm_state_lock in xfrm_migrate_state_find
Browse files Browse the repository at this point in the history
A comment on xfrm_migrate_state_find() says that xfrm_state_lock
is held. This is apparently not the case, but we need it to
traverse through the state lists.

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
  • Loading branch information
Steffen Klassert committed Feb 20, 2014
1 parent 35ea790 commit 8c0cba2
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions net/xfrm/xfrm_state.c
Original file line number Diff line number Diff line change
Expand Up @@ -1215,11 +1215,12 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig, int *errp)
return NULL;
}

/* net->xfrm.xfrm_state_lock is held */
struct xfrm_state *xfrm_migrate_state_find(struct xfrm_migrate *m, struct net *net)
{
unsigned int h;
struct xfrm_state *x;
struct xfrm_state *x = NULL;

spin_lock_bh(&net->xfrm.xfrm_state_lock);

if (m->reqid) {
h = xfrm_dst_hash(net, &m->old_daddr, &m->old_saddr,
Expand All @@ -1236,7 +1237,7 @@ struct xfrm_state *xfrm_migrate_state_find(struct xfrm_migrate *m, struct net *n
m->old_family))
continue;
xfrm_state_hold(x);
return x;
break;
}
} else {
h = xfrm_src_hash(net, &m->old_daddr, &m->old_saddr,
Expand All @@ -1251,11 +1252,13 @@ struct xfrm_state *xfrm_migrate_state_find(struct xfrm_migrate *m, struct net *n
m->old_family))
continue;
xfrm_state_hold(x);
return x;
break;
}
}

return NULL;
spin_unlock_bh(&net->xfrm.xfrm_state_lock);

return x;
}
EXPORT_SYMBOL(xfrm_migrate_state_find);

Expand Down

0 comments on commit 8c0cba2

Please sign in to comment.