netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: xfrm: don't double-hold dst when sk_policy in use.
@ 2017-08-23  8:14 Lorenzo Colitti
  2017-08-23 17:00 ` Wei Wang
  2017-08-25  5:16 ` Steffen Klassert
  0 siblings, 2 replies; 3+ messages in thread
From: Lorenzo Colitti @ 2017-08-23  8:14 UTC (permalink / raw)
  To: netdev; +Cc: weiwan, davem, steffen.klassert, misterikkit, Lorenzo Colitti

While removing dst_entry garbage collection, commit 52df157f17e5
("xfrm: take refcnt of dst when creating struct xfrm_dst bundle")
changed xfrm_resolve_and_create_bundle so it returns an xdst with
a refcount of 1 instead of 0.

However, it did not delete the dst_hold performed by xfrm_lookup
when a per-socket policy is in use. This means that when a
socket policy is in use, dst entries returned by xfrm_lookup have
a refcount of 2, and are not freed when no longer in use.

Cc: Wei Wang <weiwan@google.com>
Fixes: 52df157f17 ("xfrm: take refcnt of dst when creating struct xfrm_dst bundle")
Tested: https://android-review.googlesource.com/417481
Tested: https://android-review.googlesource.com/418659
Tested: https://android-review.googlesource.com/424463
Tested: https://android-review.googlesource.com/452776 passes on net-next
Signed-off-by: Lorenzo Colitti <lorenzo@google.com>
---
 net/xfrm/xfrm_policy.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 6f5a0dad50..69b16ee327 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -2226,7 +2226,6 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
 				goto no_transform;
 			}
 
-			dst_hold(&xdst->u.dst);
 			route = xdst->route;
 		}
 	}
-- 
2.14.1.480.gb18f417b89-goog

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

* Re: [PATCH net] net: xfrm: don't double-hold dst when sk_policy in use.
  2017-08-23  8:14 [PATCH net] net: xfrm: don't double-hold dst when sk_policy in use Lorenzo Colitti
@ 2017-08-23 17:00 ` Wei Wang
  2017-08-25  5:16 ` Steffen Klassert
  1 sibling, 0 replies; 3+ messages in thread
From: Wei Wang @ 2017-08-23 17:00 UTC (permalink / raw)
  To: Lorenzo Colitti
  Cc: Linux Kernel Network Developers, David S . Miller,
	steffen.klassert, misterikkit

> While removing dst_entry garbage collection, commit 52df157f17e5
> ("xfrm: take refcnt of dst when creating struct xfrm_dst bundle")
> changed xfrm_resolve_and_create_bundle so it returns an xdst with
> a refcount of 1 instead of 0.
>
> However, it did not delete the dst_hold performed by xfrm_lookup
> when a per-socket policy is in use. This means that when a
> socket policy is in use, dst entries returned by xfrm_lookup have
> a refcount of 2, and are not freed when no longer in use.
>
> Cc: Wei Wang <weiwan@google.com>
> Fixes: 52df157f17 ("xfrm: take refcnt of dst when creating struct xfrm_dst bundle")
> Tested: https://android-review.googlesource.com/417481
> Tested: https://android-review.googlesource.com/418659
> Tested: https://android-review.googlesource.com/424463
> Tested: https://android-review.googlesource.com/452776 passes on net-next
> Signed-off-by: Lorenzo Colitti <lorenzo@google.com>

Thanks for the fix.

Acked-by: Wei Wang <weiwan@google.com>


On Wed, Aug 23, 2017 at 1:14 AM, Lorenzo Colitti <lorenzo@google.com> wrote:
> While removing dst_entry garbage collection, commit 52df157f17e5
> ("xfrm: take refcnt of dst when creating struct xfrm_dst bundle")
> changed xfrm_resolve_and_create_bundle so it returns an xdst with
> a refcount of 1 instead of 0.
>
> However, it did not delete the dst_hold performed by xfrm_lookup
> when a per-socket policy is in use. This means that when a
> socket policy is in use, dst entries returned by xfrm_lookup have
> a refcount of 2, and are not freed when no longer in use.
>
> Cc: Wei Wang <weiwan@google.com>
> Fixes: 52df157f17 ("xfrm: take refcnt of dst when creating struct xfrm_dst bundle")
> Tested: https://android-review.googlesource.com/417481
> Tested: https://android-review.googlesource.com/418659
> Tested: https://android-review.googlesource.com/424463
> Tested: https://android-review.googlesource.com/452776 passes on net-next
> Signed-off-by: Lorenzo Colitti <lorenzo@google.com>
> ---
>  net/xfrm/xfrm_policy.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
> index 6f5a0dad50..69b16ee327 100644
> --- a/net/xfrm/xfrm_policy.c
> +++ b/net/xfrm/xfrm_policy.c
> @@ -2226,7 +2226,6 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig,
>                                 goto no_transform;
>                         }
>
> -                       dst_hold(&xdst->u.dst);
>                         route = xdst->route;
>                 }
>         }
> --
> 2.14.1.480.gb18f417b89-goog
>

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

* Re: [PATCH net] net: xfrm: don't double-hold dst when sk_policy in use.
  2017-08-23  8:14 [PATCH net] net: xfrm: don't double-hold dst when sk_policy in use Lorenzo Colitti
  2017-08-23 17:00 ` Wei Wang
@ 2017-08-25  5:16 ` Steffen Klassert
  1 sibling, 0 replies; 3+ messages in thread
From: Steffen Klassert @ 2017-08-25  5:16 UTC (permalink / raw)
  To: Lorenzo Colitti; +Cc: netdev, weiwan, davem, misterikkit

On Wed, Aug 23, 2017 at 05:14:39PM +0900, Lorenzo Colitti wrote:
> While removing dst_entry garbage collection, commit 52df157f17e5
> ("xfrm: take refcnt of dst when creating struct xfrm_dst bundle")
> changed xfrm_resolve_and_create_bundle so it returns an xdst with
> a refcount of 1 instead of 0.
> 
> However, it did not delete the dst_hold performed by xfrm_lookup
> when a per-socket policy is in use. This means that when a
> socket policy is in use, dst entries returned by xfrm_lookup have
> a refcount of 2, and are not freed when no longer in use.
> 
> Cc: Wei Wang <weiwan@google.com>
> Fixes: 52df157f17 ("xfrm: take refcnt of dst when creating struct xfrm_dst bundle")
> Tested: https://android-review.googlesource.com/417481
> Tested: https://android-review.googlesource.com/418659
> Tested: https://android-review.googlesource.com/424463
> Tested: https://android-review.googlesource.com/452776 passes on net-next
> Signed-off-by: Lorenzo Colitti <lorenzo@google.com>

Patch applied, thanks a lot!

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

end of thread, other threads:[~2017-08-25  5:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-23  8:14 [PATCH net] net: xfrm: don't double-hold dst when sk_policy in use Lorenzo Colitti
2017-08-23 17:00 ` Wei Wang
2017-08-25  5:16 ` Steffen Klassert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).