Re: [PATCH net 2/3] igb: link queues to NAPIs under RTNL after runtime resume

From: netdev-bot+sashiko

Date: Tue Nov 17 2026 - 06:18:47 EST


Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · 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 new comment above igb_queue_napi_task() says: "The
q_vectors are only freed under RTNL with __IGB_DOWN set, so checking…

--

igb: link queues to NAPIs under RTNL after runtime resume

When __igb_open() is called on the resume path, it no longer links queues
to NAPIs. On system resume the links are set directly with RTNL held. On
runtime resume a new work item takes RTNL and sets them, checking
__IGB_DOWN first so that it does not touch freed q_vectors.

Closes: https://bugzilla.ipfire.org/show_bug.cgi?id=13562

> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index 028cdd90522cb..f1ce9aa696ab7 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -2115,6 +2115,30 @@ void igb_set_queue_napi(struct igb_adapter *adapter, int vector,
> NETDEV_QUEUE_TYPE_TX, napi);
> }
>
> +static void igb_link_queue_napis(struct igb_adapter *adapter)
> +{
> + int i;
> +
> + for (i = 0; i < adapter->num_q_vectors; i++)
> + igb_set_queue_napi(adapter, i, &adapter->q_vector[i]->napi);
> +}
> +
> +/* Linking queues to NAPIs requires RTNL, which isn't held when resuming
> + * from runtime suspend: do it from here instead. The q_vectors are only
> + * freed under RTNL with __IGB_DOWN set, so checking it under RTNL is safe.
> + */
> +static void igb_queue_napi_task(struct work_struct *work)
> +{
> + struct igb_adapter *adapter = container_of(work, struct igb_adapter,
> + queue_napi_task);
> +
> + rtnl_lock();
> + if (!test_bit(__IGB_DOWN, &adapter->state) &&
> + netif_running(adapter->netdev))
> + igb_link_queue_napis(adapter);
> + rtnl_unlock();
> +}

[Severity: Medium]
Is this statement accurate: "The q_vectors are only freed under RTNL with
__IGB_DOWN set"? The commit message makes the same claim.

On the runtime resume path, __igb_resume(dev, rpm=true) runs without RTNL.
It calls igb_init_interrupt_scheme(adapter, true), which sets num_q_vectors
and allocates q_vector[]. It then calls __igb_open(netdev, true). If MSI-X
setup fails there, igb_request_irq() frees and reallocates the q_vectors:

igb_request_irq() {
...
if (adapter->flags & IGB_FLAG_HAS_MSIX) {
err = igb_request_msix(adapter);
if (!err)
goto request_done;
/* fall back to MSI */
...
igb_clear_interrupt_scheme(adapter);
err = igb_init_interrupt_scheme(adapter, false);
...
}

igb_clear_interrupt_scheme()->igb_free_q_vectors() sets num_q_vectors to 0
and frees each q_vector[i]. The fallback then reallocates them with
num_q_vectors set to 1. None of this runs under RTNL.

igb_remove() also frees the q_vectors without RTNL. It is only safe because
set_bit(__IGB_DOWN) and cancel_work_sync(&adapter->queue_napi_task) run
before igb_clear_interrupt_scheme().

So RTNL does not seem to serialize igb_queue_napi_task() against the
runtime resume writer. The only handoff between them is the __IGB_DOWN bit.
The writer uses a plain clear_bit() in __igb_open() and the reader uses a
plain test_bit() here. Neither provides release or acquire ordering.

Can the following sequence happen?

runtime resume #1 queues queue_napi_task

the work is delayed (on rtnl_lock() or in the workqueue) past the
5 second pm_schedule_suspend() in igb_runtime_idle()

runtime suspend #2 takes RTNL, igb_down() sets __IGB_DOWN and
igb_clear_interrupt_scheme() NULLs q_vector[]

the work takes RTNL while runtime resume #2, without RTNL, reallocates
the q_vectors (possibly through the MSI fallback) and clears __IGB_DOWN

On weakly ordered CPUs such as arm64 or POWER, the work could see
__IGB_DOWN as cleared but still load stale num_q_vectors or q_vector[i]
values. For example, it could read num_q_vectors as N from before the
fallback and q_vector[1] as NULL from after it.

igb_set_queue_napi() would then dereference q_vector->rx.ring through a
NULL pointer, or through a pointer that was already passed to kfree_rcu().
The work does not hold rcu_read_lock().

This looks like a flag being used as a lock. One option is to pair
clear_bit_unlock() (or smp_mb__before_atomic() plus clear_bit()) in
__igb_open() with test_bit_acquire() here. Another is to rebuild the
q_vectors on the rpm resume path under the same lock the work takes.

At minimum, could the comment and the commit message state the real
invariant? That is, the q_vectors only change while __IGB_DOWN is set, and
igb_remove() cancels the work before it frees them.

[ ... ]

--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113105835.3821433-1-antonio%40mandelbit.com