Commit 330e832a authored by Florian Westphal's avatar Florian Westphal Committed by Steffen Klassert

xfrm: unbreak xfrm_sk_policy_lookup

if we succeed grabbing the refcount, then
  if (err && !xfrm_pol_hold_rcu)

will evaluate to false so this hits last else branch which then
sets policy to ERR_PTR(0).

Fixes: ae33786f ("xfrm: policy: only use rcu in xfrm_sk_policy_lookup")
Reported-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
Tested-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
parent 7f92083e
......@@ -1268,12 +1268,14 @@ static struct xfrm_policy *xfrm_sk_policy_lookup(const struct sock *sk, int dir,
err = security_xfrm_policy_lookup(pol->security,
fl->flowi_secid,
policy_to_flow_dir(dir));
if (!err && !xfrm_pol_hold_rcu(pol))
goto again;
else if (err == -ESRCH)
if (!err) {
if (!xfrm_pol_hold_rcu(pol))
goto again;
} else if (err == -ESRCH) {
pol = NULL;
else
} else {
pol = ERR_PTR(err);
}
} else
pol = NULL;
}
......
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