Commit 8c0cba22 authored by Steffen Klassert's avatar Steffen Klassert

xfrm: Take xfrm_state_lock in xfrm_migrate_state_find

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: default avatarSteffen Klassert <steffen.klassert@secunet.com>
parent 35ea790d
...@@ -1215,11 +1215,12 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig, int *errp) ...@@ -1215,11 +1215,12 @@ static struct xfrm_state *xfrm_state_clone(struct xfrm_state *orig, int *errp)
return NULL; return NULL;
} }
/* net->xfrm.xfrm_state_lock is held */
struct xfrm_state *xfrm_migrate_state_find(struct xfrm_migrate *m, struct net *net) struct xfrm_state *xfrm_migrate_state_find(struct xfrm_migrate *m, struct net *net)
{ {
unsigned int h; unsigned int h;
struct xfrm_state *x; struct xfrm_state *x = NULL;
spin_lock_bh(&net->xfrm.xfrm_state_lock);
if (m->reqid) { if (m->reqid) {
h = xfrm_dst_hash(net, &m->old_daddr, &m->old_saddr, h = xfrm_dst_hash(net, &m->old_daddr, &m->old_saddr,
...@@ -1236,7 +1237,7 @@ struct xfrm_state *xfrm_migrate_state_find(struct xfrm_migrate *m, struct net *n ...@@ -1236,7 +1237,7 @@ struct xfrm_state *xfrm_migrate_state_find(struct xfrm_migrate *m, struct net *n
m->old_family)) m->old_family))
continue; continue;
xfrm_state_hold(x); xfrm_state_hold(x);
return x; break;
} }
} else { } else {
h = xfrm_src_hash(net, &m->old_daddr, &m->old_saddr, h = xfrm_src_hash(net, &m->old_daddr, &m->old_saddr,
...@@ -1251,11 +1252,13 @@ struct xfrm_state *xfrm_migrate_state_find(struct xfrm_migrate *m, struct net *n ...@@ -1251,11 +1252,13 @@ struct xfrm_state *xfrm_migrate_state_find(struct xfrm_migrate *m, struct net *n
m->old_family)) m->old_family))
continue; continue;
xfrm_state_hold(x); 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); EXPORT_SYMBOL(xfrm_migrate_state_find);
......
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