Skip to contentSkip to conversation

pull request (net): ipsec 2014-07-23

PATCH In review Steffen Klassert 3 participants 7 messages Jul 23, 2014 – Jul 24, 2014

Subsystems (3)
lore
Share & tools
lore
author maintainer
#5 lore raw

PATCH 2/2 xfrm: Fix installation of AH IPsec SAs

In reply to Steffen Klassert

From: Tobias Brunner <[email protected]>

The SPI check introduced in ea9884b3acf3311c8a11db67bfab21773f6f82ba was intended for IPComp SAs but actually prevented AH SAs from getting installed (depending on the SPI).

Fixes ea9884b3acf3 ("xfrm: check user specified spi for IPComp")
Cc Fan Du <[email protected]>
---
 net/xfrm/xfrm_user.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
net/xfrm/xfrm_user.c +3 -4
index 412d9dc..d4db6eb 100644
@@ -177,9 +177,7 @@ static int verify_newsa_info(struct xfrm_usersa_info *p,
 		    attrs[XFRMA_ALG_AEAD]	||
 		    attrs[XFRMA_ALG_CRYPT]	||
 		    attrs[XFRMA_ALG_COMP]	||
-		    attrs[XFRMA_TFCPAD]		||
-		    (ntohl(p->id.spi) >= 0x10000))
-
+		    attrs[XFRMA_TFCPAD])
 			goto out;
 		break;
 
@@ -207,7 +205,8 @@ static int verify_newsa_info(struct xfrm_usersa_info *p,
 		    attrs[XFRMA_ALG_AUTH]	||
 		    attrs[XFRMA_ALG_AUTH_TRUNC]	||
 		    attrs[XFRMA_ALG_CRYPT]	||
-		    attrs[XFRMA_TFCPAD])
+		    attrs[XFRMA_TFCPAD]		||
+		    (ntohl(p->id.spi) >= 0x10000))
 			goto out;
 		break;
 
Signature · 1 line
1.9.1
author maintainer
#1 lore raw

PATCH 1/2 xfrm: Fix refcount imbalance in xfrm_lookup

In reply to Steffen Klassert

xfrm_lookup must return a dst_entry with a refcount for the caller. Git commit 1a1ccc96abb ("xfrm: Remove caching of xfrm_policy_sk_bundles") removed this refcount for the socket policy case accidentally. This patch restores it and sets DST_NOCACHE flag to make sure that the dst_entry is freed when the refcount becomes null.

Fixes 1a1ccc96abb ("xfrm: Remove caching of xfrm_policy_sk_bundles")
---
 net/xfrm/xfrm_policy.c | 2 ++
 1 file changed, 2 insertions(+)
net/xfrm/xfrm_policy.c +2 -0
index a8ef510..0525d78 100644
@@ -2097,6 +2097,8 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
 				goto no_transform;
 			}
 
+			dst_hold(&xdst->u.dst);
+			xdst->u.dst.flags |= DST_NOCACHE;
 			route = xdst->route;
 		}
 	}
Signature · 1 line
1.9.1

Steffen Klassert

author maintainer
#0 lore raw

Just two fixes this time, both are stable candidates.

1) Fix the dst_entry refcount on socket policy usage.

2) Fix a wrong SPI check that prevents AH SAs from getting installed, dependent on the SPI. From Tobias Brunner.

Please pull or let me know if there are problems.

Thanks!

The following changes since commit d7933ab727ed035bdf420d7381b831ba959cecc5:

Merge branch 'for-next' of git://git.samba.org/sfrench/cifs-2.6 (2014-06-25 21:47:28 -0700)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec.git master

for you to fetch changes up to a0e5ef53aac8e5049f9344857d8ec5237d31e58b:

xfrm: Fix installation of AH IPsec SAs (2014-06-30 07:42:12 +0200)

----------------------------------------------------------------
Steffen Klassert (1):
xfrm: Fix refcount imbalance in xfrm_lookup

Tobias Brunner (1):
xfrm: Fix installation of AH IPsec SAs

 net/xfrm/xfrm_policy.c | 2 ++
 net/xfrm/xfrm_user.c   | 7 +++----
 2 files changed, 5 insertions(+), 4 deletions(-)
#2 lore raw

Re: [PATCH 1/2] xfrm: Fix refcount imbalance in xfrm_lookup

In reply to Steffen Klassert
Quoted 17 lines · Steffen Klassert

xfrm_lookup must return a dst_entry with a refcount for the caller. Git commit 1a1ccc96abb ("xfrm: Remove caching of xfrm_policy_sk_bundles") removed this refcount for the socket policy case accidentally. This patch restores it and sets DST_NOCACHE flag to make sure that the dst_entry is freed when the refcount becomes null.

Fixes 1a1ccc96abb ("xfrm: Remove caching of xfrm_policy_sk_bundles")
---
 net/xfrm/xfrm_policy.c | 2 ++
 1 file changed, 2 insertions(+)
net/xfrm/xfrm_policy.c +0 -0
index a8ef510..0525d78 100644

net/xfrm/xfrm_policy.c struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig, · line 2104

Quoted 8 lines
net/xfrm/xfrm_policy.c +2 -0
@@ -2097,6 +2097,8 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
 				goto no_transform;
 			}
 
+			dst_hold(&xdst->u.dst);
+			xdst->u.dst.flags |= DST_NOCACHE;
 			route = xdst->route;
 		}
 	}

Hmm... are you sure ?

Before 1a1ccc96abb we did a dst_hold() because we kept the dst in xfrm_policy_sk_bundles. So keeping a reference count was mandatory.

But after, I don't understand why it is needed at all.

maintainer
#3 lore raw

Re: [PATCH 1/2] xfrm: Fix refcount imbalance in xfrm_lookup

From: Eric Dumazet <[email protected]>
Date: Wed, 23 Jul 2014 19:21:13 +0200

Quoted 30 lines · Steffen Klassert
Quoted 17 lines

xfrm_lookup must return a dst_entry with a refcount for the caller. Git commit 1a1ccc96abb ("xfrm: Remove caching of xfrm_policy_sk_bundles") removed this refcount for the socket policy case accidentally. This patch restores it and sets DST_NOCACHE flag to make sure that the dst_entry is freed when the refcount becomes null.

Fixes 1a1ccc96abb ("xfrm: Remove caching of xfrm_policy_sk_bundles")
---
 net/xfrm/xfrm_policy.c | 2 ++
 1 file changed, 2 insertions(+)
net/xfrm/xfrm_policy.c +0 -0
index a8ef510..0525d78 100644

net/xfrm/xfrm_policy.c struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig, · line 2104

Quoted 8 lines
net/xfrm/xfrm_policy.c +2 -0
@@ -2097,6 +2097,8 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
 				goto no_transform;
 			}
 
+			dst_hold(&xdst->u.dst);
+			xdst->u.dst.flags |= DST_NOCACHE;
 			route = xdst->route;
 		}
 	}

Hmm... are you sure ?

Quoted 4 lines

Before 1a1ccc96abb we did a dst_hold() because we kept the dst in xfrm_policy_sk_bundles. So keeping a reference count was mandatory.

But after, I don't understand why it is needed at all.

It should be needed.

We create a new bundle here, from scratch, based upon the socket policy.

Such new bundles make routes with dst refcount == 0.

All callers expect that the route given back to them is either the original 'dst' passed into xfrm_lookup() unmolested, or a new 'dst' having a refcount taken for this caller.

That's why all call sites expect that they can just go "dst_release(dst)" and these objects it works.

So, if we returned 'dst' with refcount == 0 it would not work.

#4 lore raw

Re: [PATCH 1/2] xfrm: Fix refcount imbalance in xfrm_lookup

Quoted 16 lines · David Miller

From: Eric Dumazet <[email protected]>

Quoted 6 lines

Hmm... are you sure ?

Before 1a1ccc96abb we did a dst_hold() because we kept the dst in xfrm_policy_sk_bundles. So keeping a reference count was mandatory.

But after, I don't understand why it is needed at all.

It should be needed.

We create a new bundle here, from scratch, based upon the socket policy.

Such new bundles make routes with dst refcount == 0.

Quoted 8 lines

All callers expect that the route given back to them is either the original 'dst' passed into xfrm_lookup() unmolested, or a new 'dst' having a refcount taken for this caller.

That's why all call sites expect that they can just go "dst_release(dst)" and these objects it works.

So, if we returned 'dst' with refcount == 0 it would not work.

OK, I understood, thanks !

maintainer
#6 lore raw
In reply to Steffen Klassert

From: Steffen Klassert <[email protected]>
Date: Wed, 23 Jul 2014 10:18:05 +0200

Quoted 8 lines

Just two fixes this time, both are stable candidates.

1) Fix the dst_entry refcount on socket policy usage.

2) Fix a wrong SPI check that prevents AH SAs from getting installed, dependent on the SPI. From Tobias Brunner.

Please pull or let me know if there are problems.

Pulled, and both patches queued up for -stable, thanks.