Article View: linux.kernel.netdev
Article #27391Re: [PATCH net] sfc: falcon: Fix potential stale NAPI thread references on channel copy
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 13:23
Date: Sat, 05 Dec 2026 13:23
131 lines
13073 bytes
13073 bytes
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 ยท High: 1 ยท Medium: 0 ยท Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] The patch fixes the falcon helper but leaves the same bug in the
other two sfc channel-clone helpers.
- [Low] The commit message understates both the trigger and the impact.
--
sfc: falcon: Fix potential stale NAPI thread references on channel copy
This patch clears napi_str.thread in ef4_copy_channel(). A cloned falcon
channel then no longer inherits the NAPI kthread pointer of the channel it
was copied from. Without the change, removing the old channels stops that
thread while the clone still points at it.
> Channel cloning copies the NAPI thread pointer without acquiring a
> reference. If threaded NAPI is disabled by an earlier thread creation
> failure, a later cloned channel can retain that old pointer. Removing
> the old channels then leaves it pointing to a stopped thread.
[Severity: Low]
Is an earlier thread creation failure the only way to trigger this?
netdev_nl_napi_set_config() calls napi_set_threaded() on a single NAPI.
For drivers registered with netif_napi_add(), napi->config is NULL. Only
napi->thread gets set, and dev->threaded stays DISABLED.
A later ethtool -G then copies the pointer into the clone.
netif_napi_add_weight_locked() does not overwrite it, because
napi_get_threaded_config() falls back to dev->threaded:
net/core/dev.c:netif_napi_add_weight_locked() {
...
if (napi_get_threaded_config(dev, napi))
if (napi_kthread_create(napi))
dev->threaded = NETDEV_NAPI_THREADED_DISABLED;
...
}
__netif_napi_del_locked() on the old NAPI then calls kthread_stop(), and
the task can be freed.
At that point the clone holds a pointer to a freed task_struct, not just
to a stopped thread. These paths dereference it later:
- __netif_napi_del_locked() calls kthread_stop() on it.
- napi_set_threaded() and netif_set_threaded() skip thread creation and
set THREADED.
- netdev_nl_napi_fill_one() calls task_pid_nr_ns() on it.
Could the commit message describe this as a use-after-free? A netlink
napi-set followed by ethtool -G reaches it without any allocation failure.
> diff --git a/drivers/net/ethernet/sfc/falcon/efx.c b/drivers/net/ethernet/sfc/falcon/efx.c
> index 0c197b4486458..d4431b7064754 100644
> --- a/drivers/net/ethernet/sfc/falcon/efx.c
> +++ b/drivers/net/ethernet/sfc/falcon/efx.c
> @@ -466,6 +466,7 @@ ef4_copy_channel(const struct ef4_channel *old_channel)
> INIT_HLIST_NODE(&channel->napi_str.napi_hash_node);
> channel->napi_str.napi_id = 0;
> channel->napi_str.state = 0;
> + channel->napi_str.thread = NULL;
> memset(&channel->eventq, 0, sizeof(channel->eventq));
[Severity: High]
Two other helpers have the same code. Do they need this change too?
- efx_copy_channel() in drivers/net/ethernet/sfc/efx_channels.c
- efx_copy_channel() in drivers/net/ethernet/sfc/siena/efx_channels.c
Both do the same struct copy and reset only these fields:
drivers/net/ethernet/sfc/efx_channels.c:efx_copy_channel() {
...
*channel = *old_channel;
channel->napi_dev = NULL;
INIT_HLIST_NODE(&channel->napi_str.napi_hash_node);
channel->napi_str.napi_id = 0;
channel->napi_str.state = 0;
memset(&channel->eventq, 0, sizeof(channel->eventq));
...
}
So napi_str.thread is still copied from the old channel. The sfc version
is used by the default channel type and by the PTP channel type
(.copy = efx_copy_channel in ptp.c).
efx_realloc_channels() and efx_siena_realloc_channels() appear to follow
the same sequence as falcon:
ethtool -G
efx_realloc_channels()
efx_copy_channel() <- clone keeps old napi_str.thread
netif_napi_add() on clone <- pointer is not overwritten when
napi_get_threaded_config() is false
efx_fini_napi_channel(old)
netif_napi_del()
__netif_napi_del_locked()
kthread_stop(napi->thread)
After this, the new channel's NAPI holds a pointer to a freed
task_struct:
- The next ethtool -G, or driver removal, calls kthread_stop() on it
again.
- netif_set_threaded() sees a non-NULL pointer and skips
napi_kthread_create(), so NAPI scheduling wakes the freed task.
- napi_enable_locked() sets NAPIF_STATE_THREADED when
n->dev->threaded && n->thread.
- netdev_nl_napi_fill_one() calls task_pid_nr_ns() on it.
Two paths reach this. One is the earlier kthread creation failure the
commit message describes. The other is a netlink napi-set with
threaded=enabled followed by ethtool -G.
All three helpers share the same Fixes: tag. Should this patch also cover
the sfc and siena helpers, or come with companion patches for them?
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204130610.2419077-1-liguangshuo%40mail.sdu.edu.cn
Technical Details
Message-ID:
<179647699531.3146.16235073420230238974@kernel.org>Path:
mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378000-linux-kernel-netdev=dewy.ruReferences:
<20261204130610.2419077-1-liguangshuo@mail.sdu.edu.cn>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378000-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] sfc: falcon: Fix potential stale NAPI thread references on channel copy Date: Sat, 05 Dec 2026 13:23:15 +0000 Organization: Usenet Network Message-ID: <179647699531.3146.16235073420230238974@kernel.org> References: <20261204130610.2419077-1-liguangshuo@mail.sdu.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3035367"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:ufE+xGoWgeG6P203/0fIPpU69V8= sha256:8M7e8zdLWoAMNdyZzm7LZzBwmsHjtx7I/SqrN2S4DnQ= sha1:A48p5YtwxDsHcgKXfs7XpM0UeDE= sha256:yFJ/CRATKLvJbQe8Ksgfg6BQymNUtCc+evMZowPKqAo= 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 1E0D7117E1D; Sat, 5 Dec 2026 16:23:42 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.639 X-Spam-Status: No, score=-3.639 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.14, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org 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 hZYSNWAHinG6; Sat, 5 Dec 2026 16:23:36 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-378000-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id F14FE117E27; Sat, 5 Dec 2026 16:23:25 +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 6F5E32A563; Sat, 5 Dec 2026 13:23:21 +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=1796476997; b=3Qb6Q0NBFPpTDUxNsr8POLgFaqi8x/VCVP5RqaHAT2DsSqiS2FQ9XyfRpwqrTbk8cbRh 0wE5Xroux2zWXCFUJTng/B7cwsvtMOUfo/wfeTGzVI8R5TuGKZA42n/P1aCqxm26RQ6/L cGtREOnt2YnKqfFF/vYA0Xm+S/8JU7TcW79PyB4Ml2nN5nNueu/VhDDSQO2vC5kWVwD5C 3GFvQspitBONm5qHz4yFg5rqfMib4nXN97Bi21H/pPT+AGhUQj5t20a4xn0zsKfREx60O SML18vwQMWLH/tlmXYhMCNEepSRKS6LHLQLCg8C6QpeUevA2jVyYi230UL2/6fL4FEA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796476997; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=umY/gBdFwR2pIVsocwZTY/QXPSwayRe2zPqZtw40OZU=; b=tquVxvjkBp6ts1u+fiFEViT7xLt9L17T1ZCeeNiAT6FpT6NuaWJa8IZiVO3ELrGkAsI9 vRvE9HPAacR2NaWbgz4ijcLtf8Rl1RdPO5eFZI1VV0ZYtMrm43F1BS4fFA4Oe/a8KgLsC 79Pn4U8W+3AMD7NHnqTI+RkjlCXYIDlKpjiQTTI55/G/CsIFsomRHpb1EuLOJuZVC2vT5 /wGd2fJjr0rCXHItR7gpTkuu5cdAeE8sRI2MMLHe1LqBrPMynv+gON/PnOA7Tdh7byXsR PRvxdql3/m6kMTchwzBgxsBpIwhMc9SLaUuf4pL7vkMbY8Y7q7Aki0moSeCk9qrXycw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lnYW8eyM; 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 7212A606A684; Sat, 5 Dec 2026 13:23:17 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lnYW8eyM X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796476996; b=Hnp+IvWNLEumN00+looVsiPp2S9Q3nVgw8p3tNVem31ulFXqnwlI5SJaNCnv8LG4PDHu ZBvhhkVHnJw29ye1eyrTPX1BpXvaE1GvY1j+3rM68fyUiPP4KfkJmBVviCJt54jFZIV/n AH5/RGd6gJlr/zpJsYVukCBZsFo93YT++sk2oO1yaCpZLtyyGyn1VFF8zPEEhN9n07qwp c8E5sp+Jm++N03eDVfZurID1odo9/j0LMiPcWpRthhYpjqqoLOPJvsFExqZI3OhqTvk4m Rrqp48f/lNIA9W5Pjtr4ob51JO+fkeSG2MoXb7jM6Axww9gzbWbgg5i+smflU7P975Q== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796476996; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=umY/gBdFwR2pIVsocwZTY/QXPSwayRe2zPqZtw40OZU=; b=0txolgUdnBoflJ7TfZBcXy9YoVNzSzyLWU9EW4PLZGDa6Fv70k8iAFKgKwJtSi30O+kk 33H+LXYEkYXudsVmAC4HmJ3rpz4O7xNY1MFIlnD21cHffGf1B3zT5g3qUPynbjy9y5TMR K7ERnX+iJNv5fme7ARLj+gZkRLxtEekNLUZ3acaYYIuncf3DIIBXFpJ5TvhfuOdEAxKAH R0LCbo/+IpTqslc8yW5D6FlC3E/S+kokIUxd3q53Ock1cUAZ1/Uvlvcf/9MeWQtoMcKcX WDjHpaFUCFy8zw4wR7gFVQdQwg7cJ3KHd1zEO7VPB4RTyPNwT9tJI5MSapVPaZhFhvw== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lnYW8eyM; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F2EB606A338; Sat, 5 Dec 2026 13:23:16 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id B24061F0092B; Sat, 5 Dec 2026 13:23:15 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796476996; bh=umY/gBdFwR2pIVsocwZTY/QXPSwayRe2zPqZtw40OZU=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=lnYW8eyMSzwxGEZXua24+18rI0D2OCa5lQUFD5frXq5Fo1skRMXelkJAnmUG2FZSn Fyxk6ZFVMtrHMd5uF7B2Wg9B5QpRM7PpeE08AzneVBVyoXACoXwPQj2GESX3e3dVe5 sx2Re4UOflvnIdQU+J/sawiRXzN7A60espKxtzEZBJMdF19uty36DkPXs6oqrVa9xG dNXnMBMpDvBtvloWyE0o72yKvE/c4DHW4y+UkgTywgklyv33taImY624NWKCq8ODqy KWyfhtmh8JXcWluzNrWPK95s5XkKMpENmgwh5ikcwmrxQdJhY53dkv+B5+vCx8EIjT CK9o+SGcx1XPw== X-Cc: alex.austin@amd.com, andy.moreton@amd.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, alexanderduyck@fb.com, weiwan@google.com, hannes@stressinduktion.org, netdev@vger.kernel.org, linux-net-drivers@amd.com, linux-kernel@vger.kernel.org X-In-Reply-To: <20261204130610.2419077-1-liguangshuo@mail.sdu.edu.cn> X-sashiko-severity: High 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