From: Rahul Priolkar <rahul.priolkar@asu.edu>
To: Jakub Kicinski <kuba@kernel.org>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Paolo Abeni <pabeni@redhat.com>
Cc: Yotam Gigi <yotam.gi@gmail.com>, netdev@vger.kernel.org
Subject: [BUG] netdevsim: psample state changes can unbalance group references
Date: Thu, 03 Dec 2026 08:43:50 -0800 (PST) [thread overview]
Message-ID: <6b119c46.be2e0958.18ba9b.19f8@mx.google.com> (raw)
Hello,
We tested packet sampling in the netdevsim driver on Linux v7.4-rc4.
When two requests turned sampling on at the same time, the driver
sometimes counted the same device twice as a user of the sampling group.
When two requests turned sampling off at the same time, the driver
could release the group while it was still in use. We ran both tests
as root through the driver's debugfs interface.
We repeated the tests on v7.4-rc5 (fe6ff8d5d675) in an x86_64 KVM
guest. Both enable runs leaked a reference. In one of two disable
runs, KASAN reported 2,191 use-after-free accesses in
psample_sample_packet() after the extra reference drop. We saw no
failure in 25,000 trials with the updates serialized.
The saved rc4 trace below shows an eight-byte read 16 bytes into a
freed 64-byte object. The allocation stack goes through
psample_group_get(). The free ran through RCU, and KASAN lists
psample_group_put() on the stack that queued the work. The guest
later faulted in psample_sample_packet() and panic'ed.
BUG: KASAN: slab-use-after-free in psample_sample_packet+0x17c/0x2430
Read of size 8 at addr ffff888022846e10 by task kworker/1:2/994
Workqueue: events nsim_dev_psample_report_work
Call Trace:
kasan_report+0x117/0x150
psample_sample_packet+0x17c/0x2430
nsim_dev_psample_report_work+0x75d/0xb20
process_scheduled_works+0xc42/0x1630
worker_thread+0xa4c/0xfb0
Allocated by task 28499:
__kmalloc_cache_noprof+0x343/0x620
psample_group_get+0x120/0x3c0
nsim_dev_psample_enable_write+0x229/0x370
Freed by task 25:
__kasan_slab_free+0x70/0x90
__rcu_free_sheaf_prepare+0x137/0x2b0
rcu_free_sheaf+0x36/0x210
rcu_core+0x933/0x1230
Last potentially related work creation:
kvfree_call_rcu+0xa1/0x430
psample_group_put+0x245/0x2c0
nsim_dev_psample_enable_write+0x1e6/0x370
The buggy address is located 16 bytes inside of
freed 64-byte region [ffff888022846e00, ffff888022846e40) (cache kmalloc-64)
...
Oops: general protection fault, probably for non-canonical address 0xdffffc000000008a: 0000 [#1] SMP KASAN NOPTI
KASAN: null-ptr-deref in range [0x0000000000000450-0x0000000000000457]
Workqueue: events nsim_dev_psample_report_work
RIP: 0010:psample_sample_packet+0x195/0x2430
Kernel panic - not syncing: Fatal exception
Can you confirm these findings in netdevsim?
Thanks,
Rahul Priolkar
reply other threads:[~2026-12-03 16:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6b119c46.be2e0958.18ba9b.19f8@mx.google.com \
--to=rahul.priolkar@asu.edu \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=yotam.gi@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox