All of lore.kernel.org
 help / color / mirror / Atom feed
* pull request (net): ipsec 2014-07-23
@ 2014-07-23  8:18 Steffen Klassert
  2014-07-23  8:18 ` [PATCH 1/2] xfrm: Fix refcount imbalance in xfrm_lookup Steffen Klassert
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Steffen Klassert @ 2014-07-23  8:18 UTC (permalink / raw)
  To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev

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(-)

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] xfrm: Fix refcount imbalance in xfrm_lookup
  2014-07-23  8:18 pull request (net): ipsec 2014-07-23 Steffen Klassert
@ 2014-07-23  8:18 ` Steffen Klassert
  2014-07-23 17:21   ` Eric Dumazet
  2014-07-23  8:18 ` [PATCH 2/2] xfrm: Fix installation of AH IPsec SAs Steffen Klassert
  2014-07-24  4:57 ` pull request (net): ipsec 2014-07-23 David Miller
  2 siblings, 1 reply; 7+ messages in thread
From: Steffen Klassert @ 2014-07-23  8:18 UTC (permalink / raw)
  To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev

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")
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 net/xfrm/xfrm_policy.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index a8ef510..0525d78 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -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;
 		}
 	}
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] xfrm: Fix installation of AH IPsec SAs
  2014-07-23  8:18 pull request (net): ipsec 2014-07-23 Steffen Klassert
  2014-07-23  8:18 ` [PATCH 1/2] xfrm: Fix refcount imbalance in xfrm_lookup Steffen Klassert
@ 2014-07-23  8:18 ` Steffen Klassert
  2014-07-24  4:57 ` pull request (net): ipsec 2014-07-23 David Miller
  2 siblings, 0 replies; 7+ messages in thread
From: Steffen Klassert @ 2014-07-23  8:18 UTC (permalink / raw)
  To: David Miller; +Cc: Herbert Xu, Steffen Klassert, netdev

From: Tobias Brunner <tobias@strongswan.org>

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 <fan.du@windriver.com>
Signed-off-by: Tobias Brunner <tobias@strongswan.org>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 net/xfrm/xfrm_user.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 412d9dc..d4db6eb 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -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;
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] xfrm: Fix refcount imbalance in xfrm_lookup
  2014-07-23  8:18 ` [PATCH 1/2] xfrm: Fix refcount imbalance in xfrm_lookup Steffen Klassert
@ 2014-07-23 17:21   ` Eric Dumazet
  2014-07-23 22:09     ` David Miller
  0 siblings, 1 reply; 7+ messages in thread
From: Eric Dumazet @ 2014-07-23 17:21 UTC (permalink / raw)
  To: Steffen Klassert; +Cc: David Miller, Herbert Xu, netdev

On Wed, 2014-07-23 at 10:18 +0200, Steffen Klassert wrote:
> 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")
> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
> ---
>  net/xfrm/xfrm_policy.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
> index a8ef510..0525d78 100644
> --- a/net/xfrm/xfrm_policy.c
> +++ b/net/xfrm/xfrm_policy.c
> @@ -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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] xfrm: Fix refcount imbalance in xfrm_lookup
  2014-07-23 17:21   ` Eric Dumazet
@ 2014-07-23 22:09     ` David Miller
  2014-07-23 22:54       ` Eric Dumazet
  0 siblings, 1 reply; 7+ messages in thread
From: David Miller @ 2014-07-23 22:09 UTC (permalink / raw)
  To: eric.dumazet; +Cc: steffen.klassert, herbert, netdev

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed, 23 Jul 2014 19:21:13 +0200

> On Wed, 2014-07-23 at 10:18 +0200, Steffen Klassert wrote:
>> 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")
>> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
>> ---
>>  net/xfrm/xfrm_policy.c | 2 ++
>>  1 file changed, 2 insertions(+)
>> 
>> diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
>> index a8ef510..0525d78 100644
>> --- a/net/xfrm/xfrm_policy.c
>> +++ b/net/xfrm/xfrm_policy.c
>> @@ -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.

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] xfrm: Fix refcount imbalance in xfrm_lookup
  2014-07-23 22:09     ` David Miller
@ 2014-07-23 22:54       ` Eric Dumazet
  0 siblings, 0 replies; 7+ messages in thread
From: Eric Dumazet @ 2014-07-23 22:54 UTC (permalink / raw)
  To: David Miller; +Cc: steffen.klassert, herbert, netdev

On Wed, 2014-07-23 at 15:09 -0700, David Miller wrote:
> From: Eric Dumazet <eric.dumazet@gmail.com>

> > 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.
> 
> 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 !

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: pull request (net): ipsec 2014-07-23
  2014-07-23  8:18 pull request (net): ipsec 2014-07-23 Steffen Klassert
  2014-07-23  8:18 ` [PATCH 1/2] xfrm: Fix refcount imbalance in xfrm_lookup Steffen Klassert
  2014-07-23  8:18 ` [PATCH 2/2] xfrm: Fix installation of AH IPsec SAs Steffen Klassert
@ 2014-07-24  4:57 ` David Miller
  2 siblings, 0 replies; 7+ messages in thread
From: David Miller @ 2014-07-24  4:57 UTC (permalink / raw)
  To: steffen.klassert; +Cc: herbert, netdev

From: Steffen Klassert <steffen.klassert@secunet.com>
Date: Wed, 23 Jul 2014 10:18:05 +0200

> 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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-07-24  4:57 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-23  8:18 pull request (net): ipsec 2014-07-23 Steffen Klassert
2014-07-23  8:18 ` [PATCH 1/2] xfrm: Fix refcount imbalance in xfrm_lookup Steffen Klassert
2014-07-23 17:21   ` Eric Dumazet
2014-07-23 22:09     ` David Miller
2014-07-23 22:54       ` Eric Dumazet
2014-07-23  8:18 ` [PATCH 2/2] xfrm: Fix installation of AH IPsec SAs Steffen Klassert
2014-07-24  4:57 ` pull request (net): ipsec 2014-07-23 David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.