Skip to content
Snippets Groups Projects
Commit 3bccfbc7 authored by Venkat Yekkirala's avatar Venkat Yekkirala Committed by David S. Miller
Browse files

IPsec: fix handling of errors for socket policies


This treats the security errors encountered in the case of
socket policy matching, the same as how these are treated in
the case of main/sub policies, which is to return a full lookup
failure.

Signed-off-by: default avatarVenkat Yekkirala <vyekkirala@TrustedCS.com>
Signed-off-by: default avatarJames Morris <jmorris@namei.org>
parent 5b368e61
No related merge requests found
...@@ -1016,12 +1016,16 @@ static struct xfrm_policy *xfrm_sk_policy_lookup(struct sock *sk, int dir, struc ...@@ -1016,12 +1016,16 @@ static struct xfrm_policy *xfrm_sk_policy_lookup(struct sock *sk, int dir, struc
sk->sk_family); sk->sk_family);
int err = 0; int err = 0;
if (match) if (match) {
err = security_xfrm_policy_lookup(pol, fl->secid, policy_to_flow_dir(dir)); err = security_xfrm_policy_lookup(pol, fl->secid,
policy_to_flow_dir(dir));
if (match && !err) if (!err)
xfrm_pol_hold(pol); xfrm_pol_hold(pol);
else else if (err == -ESRCH)
pol = NULL;
else
pol = ERR_PTR(err);
} else
pol = NULL; pol = NULL;
} }
read_unlock_bh(&xfrm_policy_lock); read_unlock_bh(&xfrm_policy_lock);
...@@ -1313,8 +1317,11 @@ int xfrm_lookup(struct dst_entry **dst_p, struct flowi *fl, ...@@ -1313,8 +1317,11 @@ int xfrm_lookup(struct dst_entry **dst_p, struct flowi *fl,
pol_dead = 0; pol_dead = 0;
xfrm_nr = 0; xfrm_nr = 0;
if (sk && sk->sk_policy[1]) if (sk && sk->sk_policy[1]) {
policy = xfrm_sk_policy_lookup(sk, XFRM_POLICY_OUT, fl); policy = xfrm_sk_policy_lookup(sk, XFRM_POLICY_OUT, fl);
if (IS_ERR(policy))
return PTR_ERR(policy);
}
if (!policy) { if (!policy) {
/* To accelerate a bit... */ /* To accelerate a bit... */
...@@ -1607,8 +1614,11 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb, ...@@ -1607,8 +1614,11 @@ int __xfrm_policy_check(struct sock *sk, int dir, struct sk_buff *skb,
} }
pol = NULL; pol = NULL;
if (sk && sk->sk_policy[dir]) if (sk && sk->sk_policy[dir]) {
pol = xfrm_sk_policy_lookup(sk, dir, &fl); pol = xfrm_sk_policy_lookup(sk, dir, &fl);
if (IS_ERR(pol))
return 0;
}
if (!pol) if (!pol)
pol = flow_cache_lookup(&fl, family, fl_dir, pol = flow_cache_lookup(&fl, family, fl_dir,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment