* [PATCH net-next] xfrm: use net device refcount tracker helpers
@ 2021-12-07 19:32 Eric Dumazet
2021-12-09 9:20 ` Steffen Klassert
2021-12-09 20:00 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 4+ messages in thread
From: Eric Dumazet @ 2021-12-07 19:32 UTC (permalink / raw)
To: David S . Miller, Jakub Kicinski
Cc: netdev, Eric Dumazet, Eric Dumazet, Cong Wang, Steffen Klassert
From: Eric Dumazet <edumazet@google.com>
xfrm4_fill_dst() and xfrm6_fill_dst() build dst,
getting a device reference that will likely be released
by standard dst_release() code.
We have to track these references or risk a warning if
CONFIG_NET_DEV_REFCNT_TRACKER=y
Note to XFRM maintainers :
Error path in xfrm6_fill_dst() releases the reference,
but does not clear xdst->u.dst.dev, so I wonder
if this could lead to double dev_put() in some cases,
where a dst_release() _is_ called by the callers in their
error path.
This extra dev_put() was added in commit 84c4a9dfbf430 ("xfrm6:
release dev before returning error")
Fixes: 9038c320001d ("net: dst: add net device refcount tracking to dst_entry")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Cong Wang <amwang@redhat.com>
Cc: Steffen Klassert <steffen.klassert@secunet.com>
---
net/ipv4/xfrm4_policy.c | 2 +-
net/ipv6/xfrm6_policy.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
index 9ebd54752e03b81a01f6c53cc17cebbccd928137..9e83bcb6bc99dd8cb7e71c9f1dbb5b7ae5570626 100644
--- a/net/ipv4/xfrm4_policy.c
+++ b/net/ipv4/xfrm4_policy.c
@@ -77,7 +77,7 @@ static int xfrm4_fill_dst(struct xfrm_dst *xdst, struct net_device *dev,
xdst->u.rt.rt_iif = fl4->flowi4_iif;
xdst->u.dst.dev = dev;
- dev_hold(dev);
+ dev_hold_track(dev, &xdst->u.dst.dev_tracker, GFP_ATOMIC);
/* Sheit... I remember I did this right. Apparently,
* it was magically lost, so this code needs audit */
diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
index af7a4b8b1e9c4a46a0b0cf4245a981efa24b9152..fad687ee6dd81af9ee3591eb2333cfed8ceae8ce 100644
--- a/net/ipv6/xfrm6_policy.c
+++ b/net/ipv6/xfrm6_policy.c
@@ -74,11 +74,11 @@ static int xfrm6_fill_dst(struct xfrm_dst *xdst, struct net_device *dev,
struct rt6_info *rt = (struct rt6_info *)xdst->route;
xdst->u.dst.dev = dev;
- dev_hold(dev);
+ dev_hold_track(dev, &xdst->u.dst.dev_tracker, GFP_ATOMIC);
xdst->u.rt6.rt6i_idev = in6_dev_get(dev);
if (!xdst->u.rt6.rt6i_idev) {
- dev_put(dev);
+ dev_put_track(dev, &xdst->u.dst.dev_tracker);
return -ENODEV;
}
--
2.34.1.400.ga245620fadb-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] xfrm: use net device refcount tracker helpers
2021-12-07 19:32 [PATCH net-next] xfrm: use net device refcount tracker helpers Eric Dumazet
@ 2021-12-09 9:20 ` Steffen Klassert
2021-12-09 19:53 ` Jakub Kicinski
2021-12-09 20:00 ` patchwork-bot+netdevbpf
1 sibling, 1 reply; 4+ messages in thread
From: Steffen Klassert @ 2021-12-09 9:20 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S . Miller, Jakub Kicinski, netdev, Eric Dumazet, Cong Wang
On Tue, Dec 07, 2021 at 11:32:03AM -0800, Eric Dumazet wrote:
> From: Eric Dumazet <edumazet@google.com>
>
> xfrm4_fill_dst() and xfrm6_fill_dst() build dst,
> getting a device reference that will likely be released
> by standard dst_release() code.
>
> We have to track these references or risk a warning if
> CONFIG_NET_DEV_REFCNT_TRACKER=y
>
> Note to XFRM maintainers :
>
> Error path in xfrm6_fill_dst() releases the reference,
> but does not clear xdst->u.dst.dev, so I wonder
> if this could lead to double dev_put() in some cases,
> where a dst_release() _is_ called by the callers in their
> error path.
Yes, looks like it can, so this should be fixed.
>
> This extra dev_put() was added in commit 84c4a9dfbf430 ("xfrm6:
> release dev before returning error")
>
> Fixes: 9038c320001d ("net: dst: add net device refcount tracking to dst_entry")
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Cong Wang <amwang@redhat.com>
> Cc: Steffen Klassert <steffen.klassert@secunet.com>
As the refcount tracking infrastructure is not yet in ipsec-next:
Acked-by: Steffen Klassert <steffen.klassert@secunet.com>
Thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] xfrm: use net device refcount tracker helpers
2021-12-09 9:20 ` Steffen Klassert
@ 2021-12-09 19:53 ` Jakub Kicinski
0 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2021-12-09 19:53 UTC (permalink / raw)
To: Steffen Klassert
Cc: Eric Dumazet, David S . Miller, netdev, Eric Dumazet, Cong Wang
On Thu, 9 Dec 2021 10:20:36 +0100 Steffen Klassert wrote:
> On Tue, Dec 07, 2021 at 11:32:03AM -0800, Eric Dumazet wrote:
> > From: Eric Dumazet <edumazet@google.com>
> > release dev before returning error")
> >
> > Fixes: 9038c320001d ("net: dst: add net device refcount tracking to dst_entry")
> > Signed-off-by: Eric Dumazet <edumazet@google.com>
> > Cc: Cong Wang <amwang@redhat.com>
> > Cc: Steffen Klassert <steffen.klassert@secunet.com>
>
> As the refcount tracking infrastructure is not yet in ipsec-next:
>
> Acked-by: Steffen Klassert <steffen.klassert@secunet.com>
Applied, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH net-next] xfrm: use net device refcount tracker helpers
2021-12-07 19:32 [PATCH net-next] xfrm: use net device refcount tracker helpers Eric Dumazet
2021-12-09 9:20 ` Steffen Klassert
@ 2021-12-09 20:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-12-09 20:00 UTC (permalink / raw)
To: Eric Dumazet; +Cc: davem, kuba, netdev, edumazet, amwang, steffen.klassert
Hello:
This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Tue, 7 Dec 2021 11:32:03 -0800 you wrote:
> From: Eric Dumazet <edumazet@google.com>
>
> xfrm4_fill_dst() and xfrm6_fill_dst() build dst,
> getting a device reference that will likely be released
> by standard dst_release() code.
>
> We have to track these references or risk a warning if
> CONFIG_NET_DEV_REFCNT_TRACKER=y
>
> [...]
Here is the summary with links:
- [net-next] xfrm: use net device refcount tracker helpers
https://git.kernel.org/netdev/net-next/c/4177e4960594
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-12-09 20:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-07 19:32 [PATCH net-next] xfrm: use net device refcount tracker helpers Eric Dumazet
2021-12-09 9:20 ` Steffen Klassert
2021-12-09 19:53 ` Jakub Kicinski
2021-12-09 20:00 ` patchwork-bot+netdevbpf
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.