Re: [PATCH net 4/4] ionic: fix ethtool coalesce updates racing a PCI reset

From: Rao, Nikhil

Date: Thu Dec 03 2026 - 12:46:59 EST



On 12/2/2026 4:42 PM, netdev-bot+sashiko@xxxxxxxxxx wrote:
[ ... ] [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.

v2 will describe both resets and add Fixes: c672412f6172 ("ionic: remove lifs on fw reset").

[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:

It does. It predates this series and is not a BAR access; I'll fix it separately.

[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()?

Yes, v2 adds a patch that cancels it after napi_disable().