Netdev List
 help / color / mirror / Atom feed
* [BUG] netdevsim: KASAN slab-use-after-free in ref_tracker_free
@ 2026-06-15  1:16 Shuangpeng Bai
  0 siblings, 0 replies; only message in thread
From: Shuangpeng Bai @ 2026-06-15  1:16 UTC (permalink / raw)
  To: netdev
  Cc: Jakub Kicinski, Andrew Lunn, David S. Miller, Eric Dumazet,
	Paolo Abeni, Simon Horman, linux-kernel

Hi netdev maintainers,

I hit the following KASAN report while testing an upstream kernel.

The issue was reproduced with netdevsim. I have not confirmed whether this is
specific to netdevsim or whether other net devices can trigger a similar issue.

The KASAN report shows a slab-use-after-free in ref_tracker_free(), reached from
sysfs_rtnl_lock() while reading phys_port_name.

I reproduced this on commit: e8c2f9fdadee7cbc75134dc463c1e0d856d6e5c7 (May 25 2026)

To help trigger the bug more reliably, we applied a minimal diagnostic patch
that only adds delays and print statements.

The reproducer and .config files are here.
https://gist.github.com/shuangpengbai/b49765d646ec4610917015371aa1c3ca

I'm happy to test debug patches or provide additional information.

Reported-by: Shuangpeng Bai <shuangpeng.kernel@gmail.com>

[ 3145.449971][T17497] BUG: KASAN: slab-use-after-free in ref_tracker_free (lib/ref_tracker.c:295)
[ 3145.452089][T17497] Read of size 1 at addr ffff888107678598 by task cat/17497
[ 3145.454439][T17497]
[ 3145.454977][T17497] Tainted: [W]=WARN
[ 3145.454980][T17497] Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[ 3145.454985][T17497] Call Trace:
[ 3145.454991][T17497]  <TASK>
[ 3145.454994][T17497]  dump_stack_lvl (lib/dump_stack.c:94 lib/dump_stack.c:120)
[ 3145.455002][T17497]  print_report (mm/kasan/report.c:378 mm/kasan/report.c:482)
[ 3145.455028][T17497]  kasan_report (mm/kasan/report.c:595)
[ 3145.455046][T17497]  ref_tracker_free (lib/ref_tracker.c:295)
[ 3145.455083][T17497]  sysfs_rtnl_lock (include/linux/netdevice.h:4491 include/linux/netdevice.h:4508 include/linux/netdevice.h:4534 net/core/net-sysfs.c:122)
[ 3145.455091][T17497]  phys_port_name_show (net/core/net-sysfs.c:665)
[ 3145.455118][T17497]  dev_attr_show (drivers/base/core.c:2421)
[ 3145.455128][T17497]  sysfs_kf_seq_show (fs/sysfs/file.c:65)
[ 3145.455135][T17497]  seq_read_iter (fs/seq_file.c:231)
[ 3145.455144][T17497]  vfs_read (fs/read_write.c:493 fs/read_write.c:574)
[ 3145.455169][T17497]  ksys_read (fs/read_write.c:717)
[ 3145.455181][T17497]  do_syscall_64 (arch/x86/entry/syscall_64.c:63 arch/x86/entry/syscall_64.c:94)
[ 3145.455188][T17497]  entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)
[ 3145.455193][T17497] RIP: 0033:0x7fcf098c43ce
[ 3145.455200][T17497] Code: c0 e9 b6 fe ff ff 50 48 8d 3d 6e 08 0b 00 e8 69 01 02 00 66 0f 1f 84 00 00 00 00 00 64 8b 04 25 18 00 00 00 85 c0 75 14 0f 05 <48> 3d 00 f0 ff ff 77 5a c3 66 0f 1f 84 00 00 00 00 00 48 83 ec 28
[ 3145.455204][T17497] RSP: 002b:00007ffd05e76b98 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
[ 3145.455211][T17497] RAX: ffffffffffffffda RBX: 0000000000020000 RCX: 00007fcf098c43ce
[ 3145.455214][T17497] RDX: 0000000000020000 RSI: 00007fcf095e4000 RDI: 0000000000000003
[ 3145.455217][T17497] RBP: 00007fcf095e4000 R08: 00007fcf095e3010 R09: 0000000000000000
[ 3145.455219][T17497] R10: fffffffffffffbc5 R11: 0000000000000246 R12: 0000000000000000
[ 3145.455222][T17497] R13: 0000000000000003 R14: 0000000000020000 R15: 0000000000020000
[ 3145.455227][T17497]  </TASK>
[ 3145.455229][T17497]
[ 3145.479014][T17497] Freed by task 17497 on cpu 0 at 3145.447575s:
[ 3145.479559][T17497]  kasan_save_track (mm/kasan/common.c:57 mm/kasan/common.c:78)
[ 3145.479963][T17497]  kasan_save_free_info (mm/kasan/generic.c:584)
[ 3145.480411][T17497]  __kasan_slab_free (mm/kasan/common.c:253 mm/kasan/common.c:285)
[ 3145.480813][T17497]  kfree (include/linux/kasan.h:235 mm/slub.c:2689 mm/slub.c:6251 mm/slub.c:6566)
[ 3145.481148][T17497]  device_release (drivers/base/core.c:2542)
[ 3145.481567][T17497]  kobject_put (lib/kobject.c:689 lib/kobject.c:720 include/linux/kref.h:65 lib/kobject.c:737)
[ 3145.481951][T17497]  sysfs_rtnl_lock (net/core/net-sysfs.c:121)
[ 3145.482351][T17497]  phys_port_name_show (net/core/net-sysfs.c:665)
[ 3145.482782][T17497]  dev_attr_show (drivers/base/core.c:2421)
[ 3145.483154][T17497]  sysfs_kf_seq_show (fs/sysfs/file.c:65)
[ 3145.483586][T17497]  seq_read_iter (fs/seq_file.c:231)
[ 3145.483975][T17497]  vfs_read (fs/read_write.c:493 fs/read_write.c:574)
[ 3145.484334][T17497]  ksys_read (fs/read_write.c:717)
[ 3145.484701][T17497]  do_syscall_64 (arch/x86/entry/syscall_64.c:63 arch/x86/entry/syscall_64.c:94)
[ 3145.485092][T17497]  entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:121)
[ 3145.485592][T17497]
[ 3145.485794][T17497] The buggy address belongs to the object at ffff888107678000
[ 3145.485794][T17497]  which belongs to the cache kmalloc-cg-8k of size 8192
[ 3145.486991][T17497] The buggy address is located 1432 bytes inside of
[ 3145.486991][T17497]  freed 8192-byte region [ffff888107678000, ffff88810767a000)
[ 3145.488159][T17497]
[ 3145.488367][T17497] The buggy address belongs to the physical page:


Best,
Shuangpeng

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-06-15  1:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-15  1:16 [BUG] netdevsim: KASAN slab-use-after-free in ref_tracker_free Shuangpeng Bai

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