🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #17812

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

#17812
From: netdev-bot+sashiko
Date: Tue, 17 Nov 2026 11:18
128 lines
13033 bytes
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
Technical Details
Message-ID: <179491431306.3136.1748912400459389536@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365194-linux-kernel-netdev=dewy.ru
References: <20261113105835.3821433-2-antonio@mandelbit.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-365194-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 2/3] igb: link queues to NAPIs under RTNL after runtime resume
Date: Tue, 17 Nov 2026 11:18:33 +0000
Organization: Usenet Network
Message-ID: <179491431306.3136.1748912400459389536@kernel.org>
References: <20261113105835.3821433-2-antonio@mandelbit.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2313835"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:3Z58ATyCGviLk+3CwS6+EAdQ+Vg= sha256:nGe04rTF8Lafq/9+lGynLBWKWENNRL1L3j1eF+cu+zg=
	sha1:4od2nnGvpfUfqXNHhQHw+DpKr+A= sha256:9pEt6gurTn/XTws4BZ3Yb77fGfL0GbVVsNmR5AVuIYM=
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 211E5114F1A; Tue, 17 Nov 2026 14:19:11 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, 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] 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 J1v-mpyBzft4;
	Tue, 17 Nov 2026 14:19:07 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-365194-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id DAAAD114F1D; Tue, 17 Nov 2026 14:18:57 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 620303170F; Tue, 17 Nov 2026 11:18:37 +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=1794914315;
	b=VZNptRXE2KSe+wLs6b58Rwp10DW3d8uDmg3SxMsH2R8/W6V69Hr1XvdAVy08EWspPolW
	 EnYIQBTEdvSl0C+CAAs1KyQqEFxZ0fn27OBbsYzXCFfSRBfKiOfA2Izm4eXBe+uxfH8BI
	 xFIOOYqFKIPAPlC/VsdsCqjszbBh3LHzVkOseIJ5Jas4JobSlA1yF7KW+GJgDy+oiFFI1
	 o6IPhoj3ItqosLLyXKsZ+PZJGdil1pMa3iShUYbcSxP3jfjfyIhVUrBTVd7zFAZyDtuwl
	 0BFhf4cwnc09dMhjSUI2onbrhJuZwB7vVHVKw1t+9WK4oJTDpcrWjuAr6hbsuW17OWQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794914315;
	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=R7dVIQ4XDHgLNO3WaDmdHDUJK2S7GdX6/1fBTD2EHk0=;
	b=mBBYX38bsfKHR0o01lpcQ7W9JHgM2qOsCEmmBsxQBosv9d4//TzglHnBzFrU4enEgWOD
	 K++D65E0XfudjgOLaHkVrRbVYc9heSAnEtt2OEC+7ZRYV6bRmUvMmMfH6cPpL9ErkkDvf
	 S+ibJ1iMu/kGoIGX886UPQ9LcMjeuyxyLo9u75/u2LzoGocMC49X92miUrMwyzDcYOy86
	 qT7T3aRhKuGFMLY2U8rZgsJjfvFGFyGbDtzAeDppeVee/qpBmTKXaAdYq9hz7ZgGpBuDo
	 CR/aWDr2eCVdOim8LY67qjX8iHvao5VSFSVSj/dnq3OfDvy7Kytsjs+2WGZx/LBQE1w==
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=EYFB0ZrL;
	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 26879606A880;
	Tue, 17 Nov 2026 11:18:35 +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=EYFB0ZrL
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=1794914314;
	b=qmD+DxCytIXbskUYc0W9EuoGB8BVsUnd+qK1c68AXH8oRr2MkFdSuRc3neH3Hxf6IwL9
	 OzRjE+lPdRe5jeYWD9rTvolc+Ae26Gttt6CAljLQ6lBtjzNVI/ini0QLDWlJvJDKmpJqa
	 e4ozVM5wKPGzhRspJUFUNmqKvFTQzQqJ4JRwlNFM7gLBqmbgBD4YQlplSbic0gwiQ8jM3
	 rf50TheG29tmljQ9YWezY7OgmGRoZukHzn0SQbr8K+sRhaIkCc/Uz2+mdVKRBdSl6lilN
	 HyfGtR1TQvnusPwGC1B4fZ5K4TIKutWDPIyq/hhMu/Z4ILSSgIBY+TfOMaI41J3BjYg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794914314;
	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=R7dVIQ4XDHgLNO3WaDmdHDUJK2S7GdX6/1fBTD2EHk0=;
	b=1c6Y5AoSj4UsU+fycA3mxnVo66ihKCnfljsj2vG6yL5VmVA2JJJsCSCQrjubBMieNXXI
	 OBzNMMAyaYWXy3bcSG0ZJyZhHe3n+BfKlkj43JHRBcivj/I45HUrKWAIpRzYWgVkAtEtG
	 7nqjxXBIHFhM1cfHKF/KxnsIxt2BLR9Vt+j2DzpdDhKbOJpLDc1yHg3fRvVFOHPjEo6un
	 hSSEATODoeX3R3vzuFAwHBCGvrAwIgAZ8HMNczaC3/pn3Vn7FXmNGBk/dfgTmvoocYJdd
	 MuVDoygSUdGwsYNQJQxAjqoIl8YIU3d//rK7Pv1BGZjHEw9xh1dk3t3SEGIWH2jwRKw==
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=EYFB0ZrL;
	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 41867606A323;
	Tue, 17 Nov 2026 11:18:34 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 783CA1F000C6;
	Tue, 17 Nov 2026 11:18:33 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794914314;
	bh=R7dVIQ4XDHgLNO3WaDmdHDUJK2S7GdX6/1fBTD2EHk0=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=EYFB0ZrLqXIET4JkS/BVKgd6yRyKcwaD/R+wLWk80JIO7h+Efxbkdl3Yp5cqC8GG1
	 7PL12tm0vPfLGwk3d5cQLYJnR8mwvIzW8gV3P54eH9tcSr//VkM0sp/vBQcfde9ozp
	 KIVKtSjAl35HrzPLbYWvObkN9BqvTqqPKnDv63sweM9InhRe6Ghr0d4/Fgz1a60xyo
	 f77DC9+MHuSmsi4hBUxfogtMZUDJ8kTsYLeCyQhxB2xXWywf9JsjWnsQz+O7EjY+GA
	 oapVy78v/gPJLfES95xA+6CiJ5QaYtqbH/ik/Bnf/tdApTkNBAlwMr48u0XW5jXKij
	 LP++VaSceUBsg==
X-Cc: intel-wired-lan@lists.osuosl.org, anthony.l.nguyen@intel.com,
 przemyslaw.kitszel@intel.com, andrew+netdev@lunn.ch, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com,
 zheng.z.yan@intel.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
 stable@vger.kernel.org
X-In-Reply-To: <20261113105835.3821433-2-antonio@mandelbit.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