Skip to contentSkip to conversation

xfrm: unbreak xfrm_sk_policy_lookup

PATCH Applied Florian Westphal 2 participants 2 messages Nov 17, 2016 – Nov 18, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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 ae33786f73a7ce ("xfrm: policy: only use rcu in xfrm_sk_policy_lookup")
---
 net/xfrm/xfrm_policy.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
net/xfrm/xfrm_policy.c +6 -4
index fd6986634e6f..5bf7e1bfeac7 100644
@@ -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;
 	}
Signature · 1 line
2.7.3
maintainer Applied
#1 lore raw
Quoted 10 lines · Florian Westphal

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 ae33786f73a7ce ("xfrm: policy: only use rcu in xfrm_sk_policy_lookup")

Applied to the ipsec tree, thanks everyone!