Article View: linux.kernel.netdev
Article #26069Re: [PATCH net 4/4] ionic: fix ethtool coalesce updates racing a PCI reset
From: netdev-bot+sashiko
Date: Thu, 03 Dec 2026 00:42
Date: Thu, 03 Dec 2026 00:42
186 lines
14889 bytes
14889 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 (2) · 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] The commit message and the Fixes: tag cover only the PCI reset
(FLR) path: ionic_reset_prepare()/ionic_reset_done(), added by…
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but
ionic_get_stats() (ethtool -S) has the same check-then-use race with…
- [High] This problem wasn't introduced by this patch, but
ionic_qcq_disable() cancels the DIM work before it quiesces the…
--
ionic: fix ethtool coalesce updates racing a PCI reset
This patch holds lif->queue_lock for all of the update in
ionic_set_coalesce(). The PCI reset teardown frees the queues and unmaps
BAR0 under queue_lock without rtnl, and the restart reprograms the queues
from the saved coalesce settings. With the lock held, the ethtool update
can no longer race with either of them.
> A PCI reset clears LIF_F_UP, frees the queues and unmaps BAR0
> without rtnl, so an update that passed the test just before the reset
> reads freed queues and writes the unmapped BAR.
[ ... ]
> Fixes: a79b559e99be ("ionic: add FLR recovery support")
[Severity: Medium]
Is the PCI reset the only path where this race happens? The firmware reset
path does the same teardown, also without rtnl:
ionic_lif_deferred_work()
ionic_lif_handle_fw_down()
mutex_lock(&lif->queue_lock);
ionic_stop_queues(lif) <- clears IONIC_LIF_F_UP
ionic_txrx_free(lif) <- devm_kfree(lif->rxqcqs[i]), sets it NULL
ionic_qcqs_free(lif) <- frees the rxqcqs/txqcqs arrays
mutex_unlock(&lif->queue_lock);
Suppose an ionic_set_coalesce() call has already passed the
test_bit(IONIC_LIF_F_UP) check. It would then read lif->rxqcqs[i]->flags
after the qcq has been freed or set to NULL.
The fw_down teardown dates from c672412f6172 ("ionic: remove lifs on fw
reset"). ionic_lif_handle_fw_down() has held queue_lock since
2624d95972db ("ionic: widen queue_lock use around lif init and deinit").
So this patch closes the firmware reset race as well.
Could the commit message describe the firmware reset path too? Would it be
more accurate for the Fixes: tag to point at the commit that opened that
race?
With only the FLR commit in the tag, stable trees that have queue_lock in
fw_down but not FLR recovery, such as 6.1.y, won't pick this fix up
automatically.
> 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;
[ ... ]
> @@ -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, but does ionic_get_stats() have the same
check-then-use race with PCI reset and firmware reset? It runs under rtnl
only and tests the flag without any lock:
drivers/net/ethernet/pensando/ionic/ionic_ethtool.c: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);
}
The get_values path goes through ionic_sw_stats_get_values() into two
groups of helpers:
- ionic_get_lif_stats() dereferences lif->hwstamp_txq->q.index and
lif->hwstamp_rxq->q.index.
- ionic_sw_stats_get_txq_values() and ionic_sw_stats_get_rxq_values()
index &lif->txqstats[q_num] and &lif->rxqstats[q_num].
Meanwhile, ionic_reset_prepare() sets IONIC_LIF_F_FW_RESET and then does
this under queue_lock only:
ionic_reset_prepare()
set_bit(IONIC_LIF_F_FW_RESET, lif->state);
...
mutex_lock(&lif->queue_lock);
ionic_txrx_free(lif) <- devm_kfree() of hwstamp_txq/hwstamp_rxq
ionic_qcqs_free(lif) <- devm_kfree(dev, lif->rxqstats);
lif->rxqstats = NULL; (same for txqstats)
ionic_lif_handle_fw_down() does the same after test_and_set_bit() of
IONIC_LIF_F_FW_RESET.
Suppose an ETHTOOL_GSTATS request passes the flag test just before a
reset. Can it copy freed stats memory into the user's ethtool buffer, or
oops on a NULL lif->txqstats or lif->rxqstats?
[Severity: High]
This isn't a bug introduced by this patch, but ionic_dim_work() also writes
this coalesce register, and queue_lock doesn't serialize it. Can it run on
a freed qcq after BAR0 has been unmapped?
ionic_qcq_disable() cancels the DIM work before it masks the interrupt and
disables NAPI:
drivers/net/ethernet/pensando/ionic/ionic_lif.c:ionic_qcq_disable() {
...
cancel_work_sync(&qcq->dim.work);
ionic_intr_mask(idev->intr_ctrl, qcq->intr.index,
IONIC_INTR_MASK_SET);
synchronize_irq(qcq->intr.vector);
...
napi_disable(&qcq->napi);
...
}
At the cancel, the queue is still enabled in hardware and the interrupt is
still unmasked. A NAPI poll can complete between cancel_work_sync() and
napi_disable() and queue the work again:
ionic_rx_napi() / ionic_tx_napi() / ionic_txrx_napi()
ionic_dim_update()
net_dim()
dim->state = DIM_APPLY_NEW_PROFILE;
schedule_work(&dim->work);
DIM is on by default, since ionic_lif_alloc() sets IONIC_LIF_F_RX_DIM_INTR
and IONIC_LIF_F_TX_DIM_INTR. Nothing cancels or flushes dim.work after
this point.
ionic_stop(), ionic_reset_prepare() and ionic_lif_handle_fw_down() then
call ionic_txrx_free(). It devm_kfree()s the qcq that contains the still
queued work_struct.
When ionic_dim_work() runs later, it does this on the freed qcq:
ionic_intr_coal_init(lif->ionic->idev.intr_ctrl,
intr->index, intr->dim_coal_hw);
In the PCI reset case, ionic_reset_prepare() has also called
ionic_dev_teardown() and ionic_clear_pci() by then. That would make this
iowrite32 hit the unmapped BAR0.
This ordering seems to date back to 04a834592bf5 ("ionic: dynamic
interrupt moderation"). Should cancel_work_sync(&qcq->dim.work) be moved
after napi_disable()?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202-b4-pr60-v1-0-b1f6706e065b%40amd.com
Technical Details
Message-ID:
<179625854521.3146.11030796304497825514@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376170-linux-kernel-netdev=dewy.ruReferences:
<20261202-b4-pr60-v1-4-b1f6706e065b@amd.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376170-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net 4/4] ionic: fix ethtool coalesce updates racing a PCI reset Date: Thu, 03 Dec 2026 00:42:25 +0000 Organization: Usenet Network Message-ID: <179625854521.3146.11030796304497825514@kernel.org> References: <20261202-b4-pr60-v1-4-b1f6706e065b@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="2098295"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:+oGB+2A/PdFCa4Xyzm517LJzl38= sha256:AdYRi1nNyCNwLYg6pI1VY87BlxCKpBc3YY3inmu8HVY= sha1:W/eFNP7LejDBR64/0YCykPfOUZ0= sha256:pShZuHDTr0BrACanBIhqQL3Z8N0dYXxc1ZlBAQ7dOlA= 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 D426D1177BE; Thu, 3 Dec 2026 03:42:43 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.491 X-Spam-Status: No, score=-3.491 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.001, 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, T_PDS_OTHER_BAD_TLD=0.01] 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 0mjeveGUrFit; Thu, 3 Dec 2026 03:42:40 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-376170-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id 68EAE1177C2; Thu, 3 Dec 2026 03:42:32 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id DAF1B60257A; Thu, 3 Dec 2026 00:42:31 +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=1796258547; b=ljQC4oNgk0c/QproVJ4sDYCMU9mQddB5On0+hE9PLz2dwLXsjZ/yPTZjnKKq0A5zvCro gHU15hXkxm0bg0UQQqPQ3F42ylWruTNvr1Ke0NoTqnujlkFJvajeLAPASdVNvlNn3qp/k MldScPSTFgi5wMVzmvtowJiIHZcVZYDmay1oQKvj8JGMW9HOcvRZVnqDcCvNd3jRH52q9 3wUIOiYo2hPyP5j52lNY0fgA5DKi3EF0ArcshmNxKqi9O7AtB7LNOcAgdJ80F52ovgbZs OBsSmHtiDsfOENrX4YIK64VKKU2JEM/hn5rNBGy5KcdC7DW8GvSktEjEHjfkn2suM5w== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796258547; 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=7K5o/BsigUxSL9lUP71NUtE/Eksgq7UuqSS8FoA+6qI=; b=0RUJ8oSSbIlnzRraDa3q/2enIRrfIcz6kWhHeNkmk+ZSHOrH86tu4Cj7/ETLplX02VDY HyOgNn+95tDBJDxyd0jcvUobWcwwvHasBTesrawtFfHCiARUatw+Ldwt2ehM8cCPRoda4 GoGqs/EeZnHgJ/3urZiUBFgnEmjfnjK5nmqg0BAfxhnY9jl4it+a0yecUmT1QLwys6ABf sxor1d3ROTGM0uioQp9TboeSUyTaXnBQUHHBt98Vh6trcAh6TMUkUpjUL5pIwssRC/7+V oOU+299CHeNx7tYwfCN1n5k2Ntsvwn/dkHOiqchUAw0nDlcqJ/vTIel/pg/NiNjBF1A== 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=CYtIOiVu; 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 46A17606A68B; Thu, 3 Dec 2026 00:42:27 +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=CYtIOiVu 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=1796258546; b=XdQCCpWakChUAPruxe1Vnt9WaQFqmMlVxIutJdGjxomnf88eCTd1i0Qj0s0TqQ14CK93 VVOEtEny3QrwDgtHiO0vqlkhb5AUkVqXaI3ii29DxHwAvcMPChBmS+xZtQzuGKtmSTcMu xX8B0JJFZkAsuNO8kSSfi2wXRNSw0zugUmyRglFQbnW+Et3WS4eY25IoQ4A9fLqiQmf73 e86Eg/yay+sTzewWr1LF0tiOH86j7+7YVnAtK3p6igQR7Nz90xH69UToZL1qGIl6E6+6f 0WZMubtijWCueVHxNRMxfnLfMoQh+AknCD67DSYOUO04EPwTdSvfTit4rcQBX4GG+rw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796258546; 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=7K5o/BsigUxSL9lUP71NUtE/Eksgq7UuqSS8FoA+6qI=; b=D2iJIuk3wTO7+9E+2TyGI6Wg+p+ps9utAsXRD4wVYc4t1/eHH9u6r1IO9LsB0yTH8ibX BqT8iaAUESQ31QmraJGC6CjnbyXrloxEgiaEkfvZduK1t61HEdbZM4FMR6Ww36a99LSra LWUcr+nHJ/I+2V8LQStmUriMVu38H2f2XyfA1AojXeFNY9ahn0UXRHmAo35nJ/kzik+yI qpH1lxqf91T85rrl6PxY0IS8ZrBNZlYla5OiOp9aWHqTYSoPIBOiCvMGr+qZJE9GZzTcx qoEQKFOHsJDgL6+FP53YBRs8cRvWoEnmJy8drHz5n7Resn3+gmZwSUjgW/KH1p1Eafg== 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=CYtIOiVu; 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 673AB606A33A; Thu, 3 Dec 2026 00:42:26 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99A921F000C1; Thu, 3 Dec 2026 00:42:25 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796258546; bh=7K5o/BsigUxSL9lUP71NUtE/Eksgq7UuqSS8FoA+6qI=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=CYtIOiVuj8Nyzrhc0sjBf90p4NhiWoA6RSAvz6ekZMi0SH2M+V+xsdsKzxsHI6Gai t4rpqDuiH2jKQHgIpXCY+W6/w7W656cuP2DuuX72vuaGNhwfIoLL8dbPU3R9CBBmGb Yq2yng9dZT0MvWHeEV8jQlTTkM1y9Rcx/MH9XpXtPze6EHR7AvOInq70CC5/TtET5k 6wHMTqLdGD9e1V6oBxtQ+B3g0qW4TGD8D6C871/CW9/VtH87c12Foi9uYnkkadoVKP hX75Dob5g9LufPUmM8mJl1IoFU3UQyEJNi7S5sXVEMAuGAsHJ0WHSX0IUO+1Bpnwe7 ifLdOXpdQwIcQ== 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: <20261202-b4-pr60-v1-4-b1f6706e065b@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