The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH net 0/2] Fix ref_tracker warnings at boot
@ 2026-07-31  3:51 Jiangshan Yi
  2026-07-31  3:51 ` [PATCH net 1/2] net: cancel pending netdev_work on device unregistration Jiangshan Yi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Jiangshan Yi @ 2026-07-31  3:51 UTC (permalink / raw)
  To: andrew+netdev, davem, edumazet, kuba, pabeni
  Cc: horms, netdev, linux-kernel, 13667453960, Jiangshan Yi

This series fixes two ref_tracker warnings that appear at boot on
both TCG and KVM:

  WARNING: lib/ref_tracker.c:322 at ref_tracker_free
  WARNING: lib/ref_tracker.c:246 at ref_tracker_dir_exit

Patch 1 fixes the root cause: pending netdev_work is not canceled
during device unregistration, leaving a stale work_tracker.  When
netdev_work_proc() later runs during the RTNL release window of
netdev_wait_allrefs_any(), it triggers the double-free and leak
warnings.

Patch 2 is a defensive hardening: netdev_put() unconditionally calls
__dev_put() even when ref_tracker_free() returns -EINVAL (double-free),
over-decrementing the device refcount.  While patch 1 prevents the
double-free from occurring in the netdev_work path, patch 2 ensures
that any double-free from any source does not corrupt the refcount.

Tested on KVM (16 vCPU, 8 GB RAM) with KASAN/UBSAN/KFENCE enabled:
  Before: 2 ref_tracker WARNINGs, 80 UBSAN reports
  After:  0 WARNINGs, 53 UBSAN reports (23 network-related fixed)
          0 KASAN, 0 BUG, no regressions

Jiangshan Yi (2):
  net: cancel pending netdev_work on device unregistration
  net: guard refcount against tracker double-free

 include/linux/netdevice.h | 19 ++++++++++++-------
 net/core/dev.c            |  2 +-
 net/core/dev.h            |  2 ++
 net/core/netdev_work.c    | 10 ++++++++++
 4 files changed, 25 insertions(+), 8 deletions(-)

-- 
2.25.1

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

end of thread, other threads:[~2026-08-06  2:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-31  3:51 [PATCH net 0/2] Fix ref_tracker warnings at boot Jiangshan Yi
2026-07-31  3:51 ` [PATCH net 1/2] net: cancel pending netdev_work on device unregistration Jiangshan Yi
2026-07-31  3:51 ` [PATCH net 2/2] net: guard refcount against tracker double-free Jiangshan Yi
2026-08-06  2:27 ` [PATCH net 0/2] Fix ref_tracker warnings at boot Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox