From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.179 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== 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== 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 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 ; Thu, 3 Dec 2026 16:43:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 1CF1C606A334 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=asu.edu Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=asu.edu 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 Received: by mail-dy1-f179.google.com with SMTP id 5a478bee46e88-3874e580e2cso33799eec.3 for ; Thu, 03 Dec 2026 08:43:51 -0800 (PST) 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) 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) Message-ID: <6b119c46.be2e0958.18ba9b.19f8@mx.google.com> Date: Thu, 03 Dec 2026 08:43:50 -0800 (PST) From: Rahul Priolkar To: Jakub Kicinski , Andrew Lunn , "David S. Miller" , Eric Dumazet , Paolo Abeni Cc: Yotam Gigi , netdev@vger.kernel.org Subject: [BUG] netdevsim: psample state changes can unbalance group references X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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