Article View: linux.kernel.netdev
Article #6448[PATCH net] sfc: fix use-after-free of filter_work in efx_realloc_channels()
From: Sicong Huang
Date: Thu, 22 Oct 2026 13:39
Date: Thu, 22 Oct 2026 13:39
87 lines
12286 bytes
12286 bytes
With CONFIG_RFS_ACCEL, each channel has a delayed work item,
channel->filter_work, that expires aRFS filters. efx_poll() queues it
with mod_delayed_work(), and efx_filter_rfs_expire() always re-arms it
with schedule_delayed_work(dwork, 30 * HZ). Once efx_poll() has queued
it, the work is therefore always pending, queued or running. It is
only cancelled in efx_remove_filters(), which is not called on the ring
resize path.
Resizing the rings via ethtool -G calls efx_realloc_channels(). It
copies each channel, swaps the copies into efx->channel[] and frees the
old channel structures. Nothing on this path cancels the old channel's
filter_work. So the old filter_work can fire after its channel has
been freed. The timer core and delayed_work_timer_fn() then access
the freed delayed_work. efx_filter_rfs_expire() gets the freed channel
back via container_of(), dereferences it and re-arms the timer inside
the freed object.
A possible race is:
CPU0 CPU1
efx_ethtool_set_ringparam()
efx_realloc_channels()
efx_stop_all() //NAPI stopped, timer still armed
efx_copy_channel()
swap(efx->channel[i], ...)
efx_remove_channel(old)
kfree(old) //free here!
old->filter_work.timer fires
delayed_work_timer_fn()
efx_filter_rfs_expire()
channel = container_of(dwork, ...)
channel->rfs_last_expiry //UAF!
schedule_delayed_work(dwork, 30 * HZ)
Because the work re-arms itself every 30 seconds, this is not a narrow
timing window. One successful ethtool -G after efx_poll() has queued
filter_work is enough to trigger it.
The Siena driver has its own copy of this code in
efx_siena_realloc_channels() and has the same problem.
Fix this in both drivers by calling cancel_delayed_work_sync() on
filter_work before freeing an unused channel. The work does not take
the RTNL. It only trylocks efx->rps_mutex, and the filter table locks
it takes are never held while waiting for the RTNL, so waiting for it
under the RTNL cannot deadlock. On the copy failure and rollback paths,
the freed channels are new copies whose filter_work was never queued,
so the cancel does nothing there.
Signed-off-by: Sicong Huang <congei42@163.com>
---
drivers/net/ethernet/sfc/efx_channels.c | 3 +++
drivers/net/ethernet/sfc/siena/efx_channels.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/drivers/net/ethernet/sfc/efx_channels.c b/drivers/net/ethernet/sfc/efx_channels.c
index f4dc3f3f4416..3773a70e1e7d 100644
--- a/drivers/net/ethernet/sfc/efx_channels.c
+++ b/drivers/net/ethernet/sfc/efx_channels.c
@@ -896,6 +896,9 @@ int efx_realloc_channels(struct efx_nic *efx, u32 rxq_entries, u32 txq_entries)
for (i = 0; i < efx->n_channels; i++) {
channel = other_channel[i];
if (channel && channel->type->copy) {
+#ifdef CONFIG_RFS_ACCEL
+ cancel_delayed_work_sync(&channel->filter_work);
+#endif
efx_fini_napi_channel(channel);
efx_remove_channel(channel);
kfree(channel);
diff --git a/drivers/net/ethernet/sfc/siena/efx_channels.c b/drivers/net/ethernet/sfc/siena/efx_channels.c
index 1fc343598771..d20144f1679a 100644
--- a/drivers/net/ethernet/sfc/siena/efx_channels.c
+++ b/drivers/net/ethernet/sfc/siena/efx_channels.c
@@ -930,6 +930,9 @@ int efx_siena_realloc_channels(struct efx_nic *efx, u32 rxq_entries,
for (i = 0; i < efx->n_channels; i++) {
channel = other_channel[i];
if (channel && channel->type->copy) {
+#ifdef CONFIG_RFS_ACCEL
+ cancel_delayed_work_sync(&channel->filter_work);
+#endif
efx_fini_napi_channel(channel);
efx_siena_remove_channel(channel);
kfree(channel);
base-commit: f4377bf85887f57b59abb5479f7660a81ffe4449
--
2.34.1
Technical Details
Message-ID:
<20261022133927.3860186-1-congei42@163.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350593-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350593-linux-kernel-netdev=dewy.ru From: congei42@163.com (Sicong Huang) Newsgroups: linux.kernel.netdev Subject: [PATCH net] sfc: fix use-after-free of filter_work in efx_realloc_channels() Date: Thu, 22 Oct 2026 21:39:27 +0800 Organization: Usenet Network Message-ID: <20261022133927.3860186-1-congei42@163.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="220424"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:IZFRJk3frng4Y7umOCxbtHNtncg= sha256:i1/yd/YbvjXKZyxL71J0rosnS7PVhvMUbCUlyDd7U3o= sha1:h3B5ctVrY1EGucdpXBjnz8WJ918= sha256:qtqbNWcIpvlfXyOnd/NeEuLHPBMzVafpPqMAvpehRpw= 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 1B408111295; Thu, 22 Oct 2026 16:44:13 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.047 X-Spam-Status: No, score=-3.047 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=163.com 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 I4Pmo-1Os98v; Thu, 22 Oct 2026 16:44:10 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-350593-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=163.com X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id A2DB8111268; Thu, 22 Oct 2026 16:44:01 +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 B595C2E950; Thu, 22 Oct 2026 13:42:38 +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=1792676557; b=BGjtJfubJyQgkovKWBsGe/7lcLa/ijiGMHADjaSRXsiASce/57UF2PTUedKM9VBL9HVX KuXl+2bPooPjZTbBpgiG914p0mBAbBTl5VM1pnys0IW4cnG7YrtUvO+DubQx3L3K6FEUl Xv4tOQ6p0156jjcUyPQfzYLqSJYNmtV/4WW3I1ZktmQ2P1oMGZC6gBwO0DMq+JRnE1gDh pcDkOA/JsSArSn2YaidpFpE+MKSBYZaa2RzXp/XTyFvwgNg1JBWz312Pe8yg61F465T9v 9BCHfdtWNhKsW0NqSXqLl1P065bRVwPIf4oHXcRScvHvHzeukk8jKx75H3IyIy1fiVQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792676557; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature:Received:From:To: Cc:Subject:Date:Message-Id:X-Mailer:X-Mailing-List:List-Id:List-Post: List-Help:List-Subscribe:List-Unsubscribe:List-Owner:Precedence: MIME-Version:Content-Transfer-Encoding:X-CM-TRANSID: X-Coremail-Antispam:X-CM-SenderInfo; bh=dq6zyqOD1OLLx8fYAI+0jT8oHPgoBuLFM3qApv3melY=; b=YCYeLKyk6QSbEt3zDxMK6SHP4ZiHmN/5C8Sh/FXm0IPx77qJ9XzbWs0jWBhp52xia7qa xzhXyuRuKDJu0ReBhs9p0XbT50UpvZCuPZ1dnQbl1V2yk/Fx91hWpij8gZP4ipr4t1B+9 v1Wq4czBbpQrDWow+0p/hDm/IrpVDAi0Cila8xAL3dLVpx5e+ZDIsZ8X4XLM1XE+6JzdO 16FGnP0aKmFj7A9cMPP52exhv8PCmzLIwapzPvbBlITQfFfjKa5A+lqcGANWZlps82PEQ C86V8WjlXcCIi16ftjvaxdYDGK1A+c2ztZbO7e9m1RA1flYZza6d6AOlO/d/XHWPYVw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=cu5WGbJQ; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; 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 B231260A2619; Thu, 22 Oct 2026 13:42:37 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=cu5WGbJQ X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=117.135.210.5 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792676556; b=r11EKekhpk2TAbz2WMTAvRNKFA2OwUENvtVqBuBSNaX3hQhvM5tmm1ZIkgMUwP5p9oWh AJVFZUThTJrAblAcOHEJ5FS8pBh1oh4S8KMgYjkikR3UFRWc3hPqwH1nFypsUHBzESUvA rgnrjYzF7pk1QGG417IGyzeMV0E2fhGOWAsorLqlUVRNlXNNMgLEw5Z5tsq0PeFQZH8GB OnbyC8gQl2VRUhxeuGDErMthxFjC0er+3gk0FOOj0jmQSRy91PpqLYL6EVoBOykpa4j9P mQtB9U0T5xSzQEx+/XX36eQTk6VX3LKaVVJglodtNwf1DY1vTLsJ6oRjl7jDvDL1IpA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792676556; h=DMARC-Filter:DKIM-Signature:Received:From:To:Cc:Subject:Date: Message-Id:X-Mailer:MIME-Version:Content-Transfer-Encoding: X-CM-TRANSID:X-Coremail-Antispam:X-CM-SenderInfo; bh=dq6zyqOD1OLLx8fYAI+0jT8oHPgoBuLFM3qApv3melY=; b=pLs8OB3y+ddnRyUTWc/h8LRYcGlD6cyrwuHL+z54ptwzPc8mhqTngIUWirgSkK/yR0D5 t1Q6YA6dWL7IyQLl8QI1Se4inRuJnlBxvq975vU9oJI5fT4RKSHPGskXlp3/e6RSjoOMH pEQkfsrgGmtH8q+8NpkQouytObNHzztL0ru1aG7aDYWgIJj+XXMxpPCSEExBeg0h8Lfj2 tewTl4ZzXboL+MduHrfJbTiZGXAGRuK+C8fd065faTbp+mCQMFgDPBDQ+LGyHso2RE5Vg lkSqR14hQnVzKb9NfuLUBmNUEbN+/+DwUZbWnB7l0rfkyirVHvqBRnDpY68mWZwNCvw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass header.d=163.com header.i=@163.com header.a=rsa-sha256 header.s=s110527 header.b=cu5WGbJQ; arc=none smtp.remote-ip=117.135.210.5 X-Received: from m16.mail.163.com (m16.mail.163.com [117.135.210.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 805E6606A323; Thu, 22 Oct 2026 13:42:32 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 805E6606A323 X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=dq 6zyqOD1OLLx8fYAI+0jT8oHPgoBuLFM3qApv3melY=; b=cu5WGbJQqY3qP0n6Jw OYsR0OUt2AYMIZXoGA4f59+kve3Tlii9jTDt+9yFJD5XHAfhpkFqkv4ASr7/TgI5 Y5S29LDEaacAt+l/74RbsXzuYTZ/CpDrnk+qa+tnIA8SFrgdWP9kLkuYuqtHDQhu I4dEd/F3k0VAE2lZnS3VeVNAE= X-Received: from flipped.. (unknown []) by gzsmtp4 (Coremail) with SMTP id PygvCgCHR24QEtpqBWOrBQ--.45010S2; Thu, 22 Oct 2026 21:39:29 +0800 (CST) X-Cc: Edward Cree <ecree.xilinx@gmail.com>, Andrew Lunn <andrew+netdev@lunn.ch>, "David S . Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@kernel.org>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Kees Cook <kees@kernel.org>, linux-net-drivers@amd.com, linux-kernel@vger.kernel.org, Sicong Huang <congei42@163.com> X-Mailer: git-send-email 2.34.1 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 X-CM-TRANSID: PygvCgCHR24QEtpqBWOrBQ--.45010S2 X-Coremail-Antispam: 1Uf129KBjvJXoWxury7AF18ZFyrWF1DKFW3ZFb_yoWrGryrpa y5JrWUXry8Xay5tF1vqw18ZF1rGw4DGw1jgrn5Kw4ru3s5AFnxAFsYq3WY9F4DJrWxAr43 tr4YvrWrX3Z8taUanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0piivtPUUUUU= X-CM-SenderInfo: 5frqwvrlusqiywtou0bp/xtbC1BHZzGraEhHrGQAA3R