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: ae33786f73 ("xfrm: policy: only use rcu in xfrm_sk_policy_lookup")
Reported-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Tested-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
This commit is contained in:
Florian Westphal 2016-11-17 13:21:46 +01:00 committed by Steffen Klassert
parent 7f92083eb5
commit 330e832abd

View File

@ -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, err = security_xfrm_policy_lookup(pol->security,
fl->flowi_secid, fl->flowi_secid,
policy_to_flow_dir(dir)); policy_to_flow_dir(dir));
if (!err && !xfrm_pol_hold_rcu(pol)) if (!err) {
goto again; if (!xfrm_pol_hold_rcu(pol))
else if (err == -ESRCH) goto again;
} else if (err == -ESRCH) {
pol = NULL; pol = NULL;
else } else {
pol = ERR_PTR(err); pol = ERR_PTR(err);
}
} else } else
pol = NULL; pol = NULL;
} }