xfrm: use net device refcount tracker helpers
Subsystems (3)
PATCH 1/1 xfrm: use net device refcount tracker helpers
From: Eric Dumazet <[email protected]>
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")
--- net/ipv4/xfrm4_policy.c | 2 +- net/ipv6/xfrm6_policy.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
net/ipv4/xfrm4_policy.c +1 -1
@@ -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 */
net/ipv6/xfrm6_policy.c +2 -2
@@ -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 ; }
Signature · 1 line
2.34.1.400.ga245620fadb-goog
Quoted 9 lines · Eric Dumazet
From: Eric Dumazet <[email protected]>
xfrm4_fill_dst()andxfrm6_fill_dst()build dst, getting a device reference that will likely be released by standarddst_release()code.We have to track these references or risk a warning if
CONFIG_NET_DEV_REFCNT_TRACKER=y
Quoted 7 lines
Note to XFRM maintainers :
Error path in
xfrm6_fill_dst()releases the reference, but does not clearxdst->u.dst.dev, so I wonder if this could lead to doubledev_put()in some cases, where adst_release()_is_ called by the callers in their error path.
Yes, looks like it can, so this should be fixed.
Quoted 8 lines
This extra
dev_put()was added in commit84c4a9dfbf430("xfrm6:
release dev before returning error")Fixes 9038c320001d ("net: dst: add net device refcount tracking to dst_entry")Signed-off-by Eric Dumazet <[email protected]>Cc Cong Wang <[email protected]>Cc Steffen Klassert <[email protected]>
As the refcount tracking infrastructure is not yet in ipsec-next:
Thanks!
Quoted 4 lines · On Thu, 9 Dec 2021 10:20:36 +0100 Steffen Klassert wrote:
Quoted 3 lines · Eric Dumazet
From: Eric Dumazet <[email protected]>
release dev before returning error")
Quoted 8 lines
Quoted 4 lines
Fixes 9038c320001d ("net: dst: add net device refcount tracking to dst_entry")Signed-off-by Eric Dumazet <[email protected]>Cc Cong Wang <[email protected]>Cc Steffen Klassert <[email protected]>As the refcount tracking infrastructure is not yet in ipsec-next:
Acked-by Steffen Klassert <[email protected]>
Applied, thanks!
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Tue, 7 Dec 2021 11:32:03 -0800 you wrote:
From: Eric Dumazet <[email protected]>
xfrm4_fill_dst()andxfrm6_fill_dst()build dst, getting a device reference that will likely be released by standarddst_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!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html