Article View: linux.kernel.netdev
Article #26509[BUG] netdevsim: psample state changes can unbalance group references
From: Rahul Priolkar
Date: Thu, 03 Dec 2026 16:43
Date: Thu, 03 Dec 2026 16:43
57 lines
12528 bytes
12528 bytes
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
Technical Details
Message-ID:
<6b119c46.be2e0958.18ba9b.19f8@mx.google.com>Path:
mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376766-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376766-linux-kernel-netdev=dewy.ru
From: rahul.priolkar@asu.edu (Rahul Priolkar)
Newsgroups: linux.kernel.netdev
Subject: [BUG] netdevsim: psample state changes can unbalance group references
Date: Thu, 03 Dec 2026 08:43:50 -0800 (PST)
Organization: Usenet Network
Message-ID: <6b119c46.be2e0958.18ba9b.19f8@mx.google.com>
Injection-Info: usenet.network;
logging-data="2544398"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:VUMpHUKY9bQjCz8dzu6azqdWY9k= sha256:cKbRyatI7R5t4uTMgvwhEOuMtwOvkWc0zhABN4aIQu0=
sha1:EGRWxEdspWQKyftMXtmnHeFDAS4= sha256:EAwX8+7Hc30LUyI0kSUcmHKZY3PhUywF8x+bCLyf4ME=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 80A721179DD; Thu, 3 Dec 2026 19:44:09 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.399
X-Spam-Status: No, score=-3.399 tagged_above=-9999 required=6.31
tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
HEADER_FROM_DIFFERENT_DOMAINS=0.001, MAILING_LIST_MULTI=-1,
RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=asu.edu
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id sSc4bVV9oJxg;
Thu, 3 Dec 2026 19:44:07 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-376766-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=asu.edu
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id B7E291179DA; Thu, 3 Dec 2026 19:43:56 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by tor.lore.kernel.org (Postfix) with ESMTP id C2CB922B5E; Thu, 3 Dec 2026 16:43:55 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1796316233;
b=kmbCHYh5ujzqyUFShdiDDKnWoazjD7QB1ga9kvyPpqANrtBghKhdOcX8XgeSf8aO26CO
dh7Ag8Q45xkI22m7U2EMBZVsHO5b5tLIYSN1Ic0C/GPIw9h7ThHM4Yu/Gx3avVb0LMePt
Qh5iflMEX2A+Jbx4D3Uj6SluXl/gUK00rBY70okqFUp3I/+hDEihve4SOqba/h97iiwcL
B2QPpubxv1EESbD0nkTbY/2ln/874FFOZW9CXP/ctSldaBDr1A25dkJN+AoefHPFwT88t
sZHeUDwurlYkwgGszqFAMkaVWst7FNnvn2DdLz26Y45rjSuOfizl9t6KcQlODpi46kw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796316233;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:Received:Message-ID:Date:From:To:Cc:Subject:
X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence;
bh=aED5fHdKiVtmzKPrZs0G40dlGhIapxgRp09criShIrs=;
b=dRHywI4xjZeeFok33YHCXsrnxzMxyRs5qHwNeNKmO/FTY0awhc9cVRrr6NmYeR4926nE
OV5coDWT7qp/sZlosibot1RBmLHo1UeshvyM8L85FPsD/ozhcICXxvnlclt25LzBVaK8o
w1s+lMHxnvzb7v9objjXyFiTy1Kiop8GxUJmK4ifE3f+/eIUn3+wKGB4uDqeGBBqVI6F+
nNGX9MS7/MG8KhVlYFRchBIy2Vc6828DnmyxfyxNhVm0T1xByM5d+rIgq/aBsIA6x7ICu
NiwJEyoY/Hh1/+fWMDDcDBVIT49z1ZiryIZy5W2STh45yoc3GdUoAGBxy8u8e1iUlRw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=asu.edu header.i=@asu.edu header.a=rsa-sha256 header.s=google header.b="S/gXs9AD";
dmarc=pass header.from=asu.edu;
spf=pass smtp.mailfrom=asu.edu;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id 5D2E6606A33A;
Thu, 3 Dec 2026 16:43:53 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=asu.edu header.i=@asu.edu header.a=rsa-sha256 header.s=google header.b=S/gXs9AD
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.179
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796316232;
b=gcfCqXG7/5ypEXX64j7i9Gem1GKW194nET1K7x2Opp31D8KHrV/CcI2Qg2T2Y2z6uk0z
2rhhfUM97IHyb8DAuwko8lAEPbPRoH7OS1xyd2dSgeuw3Ck6xNC4/lSynWIt6aujpgleC
8Qc8eDDP3kN4vPJ8WdGOHTEncgzjjm+/7RhlCk0N+yYg6uQV44i8+d+IjCRo2ukDGKZGm
hS0SSj7znbnj5UESvmz/wp3EHjEEs4dM79RDJr1Vt95J0M3VWN+1KCsx5wbOlwo37cZZO
E9TXqIOaNSdG8Hlil0lF5xJzXqVPSDzwb75zr5L3wJhRTvyUdtOp+dVmmh5bUsQbLSw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796316232;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
Message-ID:Date:From:To:Cc:Subject;
bh=aED5fHdKiVtmzKPrZs0G40dlGhIapxgRp09criShIrs=;
b=LU8H3GADeSTEbN8zn68NJ+mx0JoxwU0JSulBcJ0rSnO2GADE9PIp2q5nlWSoZZLWYdE2
qfeg3M1rPlGY08BbTTsMjVApT4sWE+MkUzWLsmJk0qlWLveAAaNZJFWABuFi45IzrmFZm
FGlz/lgpVqhaBkS+CCG5qK6kO3v/NwLiFjHwQg/DxKboXTtcjQA2WRTlw7u1S80GNs0q0
iTnNqZV6+xITpzwlBi4HcfPhsxHAhttNZvGjLyQ5FyUXh1aVQEnBioUdSIg/zo3O4PPbU
4Xb9c1QrycbAT667vtajR9VPwjvfc7uebO/26F4nsUwM+485UD6ZQ3f9kACw7/qnTPg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=asu.edu;
spf=pass smtp.mailfrom=asu.edu;
dkim=pass header.d=asu.edu header.i=@asu.edu header.a=rsa-sha256 header.s=google header.b="S/gXs9AD";
arc=none smtp.remote-ip=74.125.82.179
X-Received: from mail-dy1-f179.google.com (mail-dy1-f179.google.com [74.125.82.179])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1CF1C606A334
for <netdev@vger.kernel.org>; Thu, 3 Dec 2026 16:43:51 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1CF1C606A334
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=asu.edu
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=asu.edu
X-Received: by mail-dy1-f179.google.com with SMTP id 5a478bee46e88-3874e580e2cso33799eec.3
for <netdev@vger.kernel.org>; Thu, 03 Dec 2026 08:43:51 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=asu.edu; s=google; t=1796316231; x=1796921031; darn=vger.kernel.org;
h=subject:cc:to:from:date:message-id:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=aED5fHdKiVtmzKPrZs0G40dlGhIapxgRp09criShIrs=;
b=S/gXs9ADx7DcrugjvkFbGgnNLri4n1M1OEEq/Giaw9YFUz/29AHuu5QHwufOdynfIy
k8iBTVvi5HOypcZonHCiuvvjYkiomjXdkanZIc+CFi6bh6b3msrHgVeQE84YwuScjEsF
fq6khy3NwsUpIBSnDGpm5oG4UrBL3QxuyvPE/f1oWFDtHW4GiE/Fh+1Mmlv5BqPqx+if
ZEeuUhwTDjUFnCGzEdlwg1x86wmDKpSpJcrZGyEVV5buc806bPkO2e4S6Eb0e013RbKw
pQ/0O+f3FL/ConjcEaWak7xHL0Dsb06sx8cYx7aYLqld+OAb4cIHC75/JUwYrl/2eMtQ
pVpg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796316231; x=1796921031;
h=subject:cc:to:from:date:message-id:x-gm-gg:x-gm-message-state:from
:to:cc:subject:date:message-id:reply-to:content-type;
bh=aED5fHdKiVtmzKPrZs0G40dlGhIapxgRp09criShIrs=;
b=hjDKzWELC1Fd0cLWj08gdxiKGPZVQ2vgzkchCgcIxFjvEiOSdCBBrqnZ74tNXYJDE0
aaOqME2y+/PKeVAWiH0ASemR5ZHYP8AZNgng5s9UT6E/7ytsyMRy4oWHDBtiuIi064I/
CQirmSh7W17XGMupQwBToMTtN/GuntKp8+BFdR+vppo1pI/VtHF0wPJ2q5+GReqWnGB9
jmHFU1FEzlrTUga+QYO0sxIr6U7+2Y2eHcaBvYL9vJX6e/jIsSeZv/jGwgmSc/5/jeEw
9/0wOvHhIxvSpS+ZLOlZ328DucPV3dhOn3tWkG4yYSZ0pxjks8+jtAdqkIuwlyoKtRfh
caDw==
X-Forwarded-Encrypted: i=1; AL+hErG8nnWsWynCKwvxM7mDBdxfXhaWszNMBH16xfxs0Y2xvOH0lycMJC4KEtnpl+eZtVc7KeOE0Hk=@vger.kernel.org
X-Gm-Message-State: APuU4Z8jdomu0ZNAU8LtmNjbxdQCp52jfxjZThSMT4nQz2JSupzzwOBV
ZgQZuWbjMAaiVtdPIbYNvHX0i25356W/xa24ZPPH0uGGimao8Nfp1EDAqHuZuOR7YQ==
X-Gm-Gg: AZFdTZefZDIJjPljLkf0b05G8VSxM+cLgRDDodmSWDECAek4chZ3+9QFQWg0TAI+U6q
+R6zyewdXpeWfjVkQIACdrO0nL9NujmZAK8/0fjTK/rZP2PXPOkujdMOFAEBfPGvUGdUcdp6s73
a2j7HvcSTDK/v+z4V6pARfGDiALXZwKzT1Kft47Sl9WhrU0pq+C2/ATRRgbBRDOrU9uET2DB6ZX
m6KDdevHIzJ1PnOh6lPUG26UJEssULMfbg8lAFhnfcNKoA0tkWkWmFxSFC+yCNVfh4x7yTGEmVP
A8G6AMHx+J88ga3VNVkulau81RL+s7gLpUy3hP8W8u2CvreBfwSIJRBQhTv8uIPhgMNu3GaGP6v
moEUj7FiwBVRdgLrY0mEO/65t3HGOlqlg8GScEGvMpEp5XDWdci2FWmt0420qc91U7Z8JWPKAl0
C+gWlw6I6SX5LbXbwZpzpWxwF6acM1c8sZFcV0AJfJ8dzDKVcR70MKrZbvPw3rMMMXVbjQJiRzC
Fynt+epbYcqJ0IhIT4oe2wL9NkkAp+Y7qsy1zVE4/TJtcP3USx2xxW52uFSPrTXSFDYP/2c9/f5
EBeUXOZJRGvibfPkr+57GIzqgGeJAaueLA==
X-Received: by 2002:a05:7301:d808:b0:384:cea9:a109 with SMTP id 5a478bee46e88-3874488225cmr3129021eec.0.1796316231013;
Thu, 03 Dec 2026 08:43:51 -0800 (PST)
X-Received: from 07-netdevsim-psample-toggle.eml ([2607:fb91:4185:7cd1:d36:ab6e:2627:426c])
by smtp.gmail.com with ESMTPSA id 5a478bee46e88-385672ce402sm123239986eec.16.2026.12.03.08.43.49
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Thu, 03 Dec 2026 08:43:50 -0800 (PST)
X-Cc: Yotam Gigi <yotam.gi@gmail.com>, netdev@vger.kernel.org
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list