Article View: linux.kernel.netdev
Article #27541Re: [PATCH net v2 4/5] ionic: fix ethtool coalesce updates racing a reset
From: netdev-bot+sashiko
Date: Sat, 05 Dec 2026 23:06
Date: Sat, 05 Dec 2026 23:06
162 lines
13517 bytes
13517 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 (1) · Medium: 1 · Low: 0
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).
- [Medium] ionic_set_coalesce()
(drivers/net/ethernet/pensando/ionic/ionic_ethtool.c) reads…
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the ethtool -S
callback in the same file has the same race the patch fixes for…
--
ionic: fix ethtool coalesce updates racing a reset
This patch holds lif->queue_lock across the whole update in
ionic_set_coalesce(). That covers saving the new settings and writing
each queue's interrupt control register. The PCI and firmware reset
paths tear down and restart the queues under queue_lock without rtnl,
so the lock keeps the coalesce update from racing them.
> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
> index 1360a3dfb7c66..bc0601dbcf63a 100644
> --- a/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
> +++ b/drivers/net/ethernet/pensando/ionic/ionic_ethtool.c
> @@ -555,6 +555,8 @@ static int ionic_set_coalesce(struct net_device *netdev,
> tx_coal > IONIC_INTR_CTRL_COAL_MAX)
> return -ERANGE;
>
> + mutex_lock(&lif->queue_lock);
> +
> /* Save the new values */
> lif->rx_coalesce_usecs = coalesce->rx_coalesce_usecs;
> lif->rx_coalesce_hw = rx_coal;
[Severity: Medium]
Can rx_coal and tx_coal still be computed from a half-rewritten ident
during a reset? ionic_set_coalesce() reads the ident values and does
the conversions before it takes the lock:
ident = &lif->ionic->ident;
if (ident->dev.intr_coal_div == 0) {
...
rx_coal = ionic_coal_usec_to_hw(lif->ionic, coalesce->rx_coalesce_usecs);
if (!rx_coal && coalesce->rx_coalesce_usecs)
rx_coal = 1;
During PCI reset recovery, ionic_reset_done()->ionic_setup_one()->
ionic_identify() rewrites ident. It holds neither rtnl nor queue_lock:
ionic_identify() {
memset(ident, 0, sizeof(*ident));
...
err = ionic_dev_cmd_wait(ionic, DEVCMD_TIMEOUT);
if (!err) {
sz = min(sizeof(ident->dev), sizeof(idev->dev_cmd_regs->data));
memcpy_fromio(&ident->dev, &idev->dev_cmd_regs->data, sz);
}
...
}
The firmware-up path does the same through ionic_lif_handle_fw_up()->
ionic_identify(). ionic_reset_prepare() doesn't call
netif_device_detach(), so ethtool -C can run during this window.
Nothing in ionic_set_coalesce() checks IONIC_LIF_F_FW_RESET.
If ethtool -C reads the zeroed divisor, it returns a spurious -EIO.
It can also pass the divisor check just before the memset, or read mult
and div at different points in the rewrite. In both cases
ionic_coal_usec_to_hw() returns 0:
if (!div || !mult)
return 0;
Any non-zero request is then forced to 1. Under the new lock, that 1 is
stored in lif->rx_coalesce_hw and lif->tx_coalesce_hw. Then
ionic_restart_lif()->ionic_txrx_alloc() programs it into every new
queue.
The commit message says the restart "can pick up a half-written update"
and that taking queue_lock for the whole update fixes this. Is that
fully covered while the inputs are still read outside the lock, from
state the reset rewrites?
Would it help to move the conversion under queue_lock and return -EBUSY
while IONIC_LIF_F_FW_RESET is set, as ionic_set_channels() already
does?
> @@ -598,6 +600,7 @@ static int ionic_set_coalesce(struct net_device *netdev,
> }
> }
> }
> + mutex_unlock(&lif->queue_lock);
>
> return 0;
> }
[Severity: High]
This is a pre-existing issue and was not introduced by this patch.
ionic_get_stats() in the same file looks like it has the same
check-then-use race against the reset paths:
ionic_get_stats() {
...
if (test_bit(IONIC_LIF_F_FW_RESET, lif->state))
return;
memset(buf, 0, stats->n_stats * sizeof(*buf));
for (i = 0; i < ionic_num_stats_grps; i++)
ionic_stats_groups[i].get_values(lif, &buf);
}
This runs under rtnl only. The get_values callbacks reach these
functions:
ionic_sw_stats_get_values()->ionic_get_lif_stats()->
ionic_add_lif_txq_stats() / ionic_add_lif_rxq_stats()
ionic_sw_stats_get_txq_values() / ionic_sw_stats_get_rxq_values()
All of them index &lif->txqstats[q_num] and &lif->rxqstats[q_num] for
each queue.
ionic_reset_prepare() and ionic_lif_handle_fw_down() both set
IONIC_LIF_F_FW_RESET. They then call ionic_qcqs_free() under queue_lock,
without rtnl:
ionic_qcqs_free() {
...
if (lif->rxqcqs) {
devm_kfree(dev, lif->rxqstats);
lif->rxqstats = NULL;
...
if (lif->txqcqs) {
devm_kfree(dev, lif->txqstats);
lif->txqstats = NULL;
...
}
ionic_reset_prepare() never calls netif_device_detach(), so the
netif_device_present() check in the ethtool core doesn't block callers
during a PCI reset. In the firmware reset path, the detach happens after
a caller may already have passed that check.
Suppose ethtool -S passes the IONIC_LIF_F_FW_RESET test just before the
reset sets the bit. Can it still be in the read loop when these arrays
are freed? It would then copy freed memory into the user's stats buffer,
or read through a NULL base and oops.
Does ionic_get_stats() need the same queue_lock treatment as
ionic_set_coalesce()?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261204-b4-pr60-v2-0-9e0b5408a68e%40amd.com
Technical Details
Message-ID:
<179651196781.3148.9629649457918353005@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-378176-linux-kernel-netdev=dewy.ruReferences:
<20261204-b4-pr60-v2-4-9e0b5408a68e@amd.com>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-378176-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v2 4/5] ionic: fix ethtool coalesce updates racing a reset Date: Sat, 05 Dec 2026 23:06:07 +0000 Organization: Usenet Network Message-ID: <179651196781.3148.9629649457918353005@kernel.org> References: <20261204-b4-pr60-v2-4-9e0b5408a68e@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="3139705"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:dyv6yu91NTHfiUVg5jt988TQXqw= sha256:zd5rs8101Zi8UWiilwy+X9il37Z3KiPi2Y5nERDUOzM= sha1:DH3i0PyLGjE3INBT6cfGy4/MPa0= sha256:yO8cO2NNfO8SpNO3jLF22Sl/kbL4f+4RRu/QwM6kNJk= 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 1F93910E0E9; Sun, 6 Dec 2026 02:06:28 +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 I34y-qqpr39K; Sun, 6 Dec 2026 02:06:21 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-378176-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 DD38E117EE5; Sun, 6 Dec 2026 02:06:11 +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 652D62808B; Sat, 5 Dec 2026 23:06:10 +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=1796511970; b=Hiw0q3mlEGTfp2/vn3eeDpvAwEClzVlqA0uHloNDwwR/IcUcgRC5pJDK+8XVcjVRQVds sddeno6nbu8JZy0B318fy9np9b2+cy8oGZxyfsU8WBa5kgqo45ObdCJ0o0uZm3gQFACYr jLjR8K2xzD2LS7hLEL0n2et/16JVLdiEn1HzHiTjLaNi8raxXOYAJSi4tgevJVgq1WFNa KiVZtJeTSh5lPzTytkMYFlEvuYLDZ7mP1we9d0Fk0+US3/IyBJ5QJ/XMg+c+33tGI18Rc /WzLQ3P+kDarvEcm6wTaN3oyHNcfNmq8hWqYvKo7VKxmZS3WXIfGayxFrLFNfsT4c0g== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796511970; 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=xnh3c4uJ4tb9exw+JE/xfZQCmS4eJfEE2aJUGgPUejs=; b=5GOigh2bADBMH0AkXQ82xzFZZJXzsMNJ5XC0w60mb2IySZGZXmGDDOea3QcWrKZs06oT MrWAU2VK/N+y5E52LGLCj0ZkldCaiF41DYcZhwRjofFVU/ZvJHHwEIN/g3LGfRKaVzOAA EZCTKA8TKlwWg6QfsoiVQAc8Mzp6fTdp88aDPhSFKKq2mqVAWmAI6CISYGbqxbY90R1nf CugfZO1cZqUmo/bJXkNWzcC95iIK9SrLKwDdoBuwTFCO00jevCqsh8FoKNg4R8yNUyGtj 9hWm7+ZodZlBfjvF8KXj65xD6ExPvYaKlSZqe8lWGWlHPPYstcWeviG0c3C1AVP5xMw== 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=O7TtcWfj; 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 1BAC3606A338; Sat, 5 Dec 2026 23:06:10 +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=O7TtcWfj 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=1796511969; b=oTNRNBUVwuaXt9T/aSffMB/4+RC6ZR8CTSng1pEMBIMh8fOMX9+F9jOpns2LuxhNz6yQ QZXH76B378SupvLq8xIHqgEwHmJSqC8bpXuc+rd5EPdKW7+vGNDICpwAoIKQWdrjh/9bs bNUfOFzH6XXJtBsUsTHU23LRHWTcpYfySggYrSwmICTsJJcf1eJZOZW8oRkMWc68Z4QQL o/SDYC7YLjZjtYvVN95qfyuIECg3Yxqkecg8B43RP0CTu2BJFPB3AxjUPzWwmDRK4pLII wMIp6wuyvYCh9rRjvBN1tleae3kFh0bp7Dlzc4TVk/9TYCkoVL1bSxao+CDGUmx7yWA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796511969; 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=xnh3c4uJ4tb9exw+JE/xfZQCmS4eJfEE2aJUGgPUejs=; b=lVP3Q74I212YL2JF4P5M0LMiqtNhYOk5f/MVrwclntmN8zokuXGjHRwOF4mAq78mjUmn pU92XDZJnt627lSP8QaIGSWinkK+ebl1ZOsHa/ZY5x2U+tB3a/ALXGueVOhQtYzDiT3iA 8nADSE6vgMyKOBrwSnMft7d3p+jtJDYy/HtGRYBhF1kGmsRYSMd/fvKB8BoOoO0clB/Zb SIZaco4qwQnTiJR8cZT76H/gYTZxHEpdGqrxVdO3U5Kt+KNouG4/rAF7abTrikLzHlon3 3aTPJwe6f26bfOJMqBozGoQIKIRF0+j5hodq/DOKOLK+Rwj5y73bjuteED2PR4PO4YQ== 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=O7TtcWfj; 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 38A9A606A330; Sat, 5 Dec 2026 23:06:08 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3846A1F0092B; Sat, 5 Dec 2026 23:06:08 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796511968; bh=xnh3c4uJ4tb9exw+JE/xfZQCmS4eJfEE2aJUGgPUejs=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=O7TtcWfj/YQzu5hjFAHLqd6BEkhuUa32mBRUWbzohYWPWYXe88rfE0Yi2xTsJCw3t BuCRdWYcALJOdfgsEizIM0IT9lvgPDa8E94MMfcbDb6enSI3KXxtVBcijoFyBkfurf 3jg8HUxY1B3ZIf66ZgTqCDOPD7zwryqoonTtuhdsZibgBpYf6s3L2pvbVt9+Qhs1Yh 4Dqy4HlqQ3LRIi3MbhshbboEkpnjVviSKxAM+azDGuf4I+Za/v7cTsZZELrK4OLOg+ FeyuqKyadaXHwb+jh9eKilO5k2LId37HQrD4M+wB5g2yC7bn4W/ssnHuetnkMnTL0b lYcI7R0TQ/21Q== X-Cc: brett.creeley@amd.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, eric.joyner@amd.com, abhijit.gangurde@amd.com, allen.hubbe@amd.com X-In-Reply-To: <20261204-b4-pr60-v2-4-9e0b5408a68e@amd.com> X-sashiko-severity: Medium 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