πŸš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26201

Re: [PATCH net v7 1/4] ice: stop the service task before the PF is unloaded

#26201
From: netdev-bot+sashiko
Date: Thu, 03 Dec 2026 08:01
150 lines
13955 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The patch fixes a second, older bug in the recovery mode branch
  of ice_remove() (drivers/net/ethernet/intel/ice/ice_main.c), but the…
- [Low] ice: clear_bit(ICE_SERVICE_SCHED) before disable_work_sync() in
  shutdown

--

ice: stop the service task before the PF is unloaded

This patch moves the service task stop and the AdminQ waiter cancel in
ice_remove() back to right after ice_free_vfs(). It adds
ice_service_task_shutdown(), which also calls disable_work_sync() and
timer_shutdown_sync() so nothing can re-arm the work or the timer. The
recovery mode branch of ice_remove() now uses the same final stop.

> diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c
> index 47c6798c97e8f..b05eda1bf50ae 100644
> --- a/drivers/net/ethernet/intel/ice/ice_main.c
> +++ b/drivers/net/ethernet/intel/ice/ice_main.c

[ ... ]

> @@ -5375,7 +5391,7 @@ static void ice_remove(struct pci_dev *pdev)
>  	}
>  
>  	if (ice_is_recovery_mode(&pf->hw)) {
> -		ice_service_task_stop(pf);
> +		ice_service_task_shutdown(pf);
>  		scoped_guard(devl, priv_to_devlink(pf)) {
>  			ice_deinit_devlink(pf);
>  		}

[Severity: Low]
This change looks right, but it seems to fix a second, older bug that
the Fixes tag doesn't cover. Should this also carry a Fixes tag for
1de25c6b984d ("ice: support FW Recovery Mode")?

The recovery mode branch of ice_remove() comes from 1de25c6b984d, and
8a37f9e2ff40 never changed it. Before this patch the branch called
ice_service_task_stop() once and returned. That function runs
timer_delete_sync() first and cancel_work_sync() second.

If ice_service_task_recovery_mode() is running at that moment, it
re-arms the timer unconditionally after the delete:

ice_service_task_recovery_mode() {
    ...
	ice_service_task_complete(pf);

	mod_timer(&pf->serv_tmr, jiffies + msecs_to_jiffies(100));
}

cancel_work_sync() only waits for that run to finish. After that,
ice_service_timer() keeps re-arming itself no matter what
ICE_SERVICE_DIS says:

ice_service_timer() {
    ...
	mod_timer(&pf->serv_tmr, round_jiffies(pf->serv_tmr_period + jiffies));
	ice_service_task_schedule(pf);
}

So the timer can still fire after the PF has been freed and the module
has been unloaded.

The commit message only says "The recovery mode branch of ice_remove()
gets the same final stop". Trees that have 1de25c6b984d but not
8a37f9e2ff40 would not see that this fix applies to them. Could the
message also say that this path is fixed, and add the extra tag?

Fixes: 1de25c6b984d ("ice: support FW Recovery Mode")

[ ... ]

> @@ -1707,6 +1707,22 @@ static int ice_service_task_stop(struct ice_pf *pf)
>  	return ret;
>  }
>  
> +/**
> + * ice_service_task_shutdown - stop the service task for PF removal
> + * @pf: board private structure
> + *
> + * A caller that passed the ICE_SERVICE_DIS test before the stop can
> + * still queue the work after it, and a run in progress can arm the
> + * timer after its delete. The PF is going away, so make both
> + * permanently dead, nothing restarts them.
> + */
> +static void ice_service_task_shutdown(struct ice_pf *pf)
> +{
> +	ice_service_task_stop(pf);
> +	disable_work_sync(&pf->serv_task);
> +	timer_shutdown_sync(&pf->serv_tmr);
> +}
> +
>  /**
>   * ice_service_task_restart - restart service task and schedule works
>   * @pf: board private structure

[Severity: Low]
ice_service_task_shutdown() starts with ice_service_task_stop(), and
that clears ICE_SERVICE_SCHED right after cancel_work_sync(), before
disable_work_sync() has run. That leaves the window this helper is
meant to close still open for the SCHED bit.

ice_service_task_schedule() tests the bits and queues the work in
separate steps:

	if (!test_bit(ICE_SERVICE_DIS, pf->state) &&
	    !test_and_set_bit(ICE_SERVICE_SCHED, pf->state) &&
	    !test_bit(ICE_NEEDS_RESTART, pf->state))
		queue_work(ice_wq, &pf->serv_task);

So this interleaving looks possible:

  1. CPU0 in ice_service_task_schedule() passes the ICE_SERVICE_DIS
     test and sets ICE_SERVICE_SCHED.
  2. CPU1 in ice_remove() runs ice_service_task_stop(), which sets
     ICE_SERVICE_DIS, finds nothing queued in cancel_work_sync() and
     clears ICE_SERVICE_SCHED.
  3. CPU0 calls queue_work(), so pf->serv_task is now pending while
     ICE_SERVICE_SCHED is clear.
  4. A worker starts running it before CPU1 reaches
     disable_work_sync(), which then waits for that run to finish.

ice_service_task() and ice_service_task_recovery_mode() both finish
through ice_service_task_complete(), which then hits:

	WARN_ON(!test_bit(ICE_SERVICE_SCHED, pf->state));

If CPU0 instead does its test_and_set_bit() after the clear, the work
is cancelled by disable_work_sync() and ICE_SERVICE_SCHED is left set
on a PF that is going away.

Neither case is a use-after-free, since disable_work_sync() still
drains the run before the VSIs are freed, but rmmod can splat a
warning. Would it be cleaner to open code the final stop so the bit
is cleared last: set ICE_SERVICE_DIS, timer_shutdown_sync(),
disable_work_sync(), and only then clear_bit(ICE_SERVICE_SCHED)? Once
the timer is shut down, a run that calls mod_timer() on its way out
is a no-op, and once the work is disabled nothing can queue it again.

-- 
Sashiko AI review Β· https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202071642.2527605-1-poros%40redhat.com
Technical Details
Message-ID: <179628491355.3146.6554967854382312283@kernel.org>
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376385-linux-kernel-netdev=dewy.ru
References: <20261202071642.2527605-2-poros@redhat.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-fra.pugleaf.net!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!srl.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376385-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v7 1/4] ice: stop the service task before the PF is unloaded
Date: Thu, 03 Dec 2026 08:01:53 +0000
Organization: Usenet Network
Message-ID: <179628491355.3146.6554967854382312283@kernel.org>
References: <20261202071642.2527605-2-poros@redhat.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2430957"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:BRQTWJwc8cuq0sdzP1DO6PKN6jk= sha256:8gURirTasRVpVrsNB8WQ9JqmgERrXt4XWtS0rOyCzV4=
	sha1:VVhdE1FACcKtOSGA6Vqw6/KfG3A= sha256:SDw/76XrwFibZMeaJMCTlREYAwMbd6Ng+pT7tI8GzAI=
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 D0E32117878; Thu,  3 Dec 2026 11:02:17 +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 wOH8ZpFmWE7H;
	Thu,  3 Dec 2026 11:02:14 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-376385-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 9AE83117870; Thu,  3 Dec 2026 11:02:02 +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 44F482A9E0; Thu,  3 Dec 2026 08:01:57 +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=1796284916;
	b=x/qhUFrNjzbcRjmvMThF31GGvRMhOIv0vo5Ql167Fj29/T8q1w/bBlIL390D7U2DrfiD
	 2by+ZzjSXJ/rCvKHseqd+Pgt9cklSPP+KsQVNIzyGssyMl8x4oqePLByljv0ux3UqAtkl
	 jVNviuaXlKSvGVfw4EitbBdmftzwRwvrPixdrefKtCB5ZWH8n105zdrzz4Bo015Lrthox
	 7vuuDGTQWLsUF9rpuGTB/AelPRIOlkEA/GTRCes3AnqMcuOFe/kx50q0i6ZhGQ7aVOkeH
	 1ElLqJrH5hCGYCrt5L+ez9FCBQ92c4AuvSFaa31j4V7tyOMHQyBctTMpkJZENu1RxpQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796284916;
	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=vBi8/Mx0xtlD5bQ1hSif6l6um898TQw0v4TSrtyV5+A=;
	b=omEsMOgppg0bHrWeXfe4X1yFpsIxVbidbZI7QDWWxQUapIzwwFFbqHt9HrP9zSZyOX8L
	 YnuJwF1r2fxoosPXYBBgcS8eAXYXR6EP1/S4g41YzoHdRMr89gsgei+n9pVl5vSV9johz
	 vklLZwxH0IBTepK4/E59e4da/ZpMyxGtA5Qb0z0tp6mBP7F2NRzPt+j2kHo6w6YOZJ6mz
	 KnYzhY1GoEj08FXjP2ZW4DQwCqyujKcot+oGIs9hBOWN03d24ae5PdkoRP/p/KUpVTFFI
	 fhB5OEhtaheVlzytgppezeBy1KgUuTAjk3Ejx9E13QaCUfGLF+sltxLaOS8gMlwr7aQ==
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=c2lyKwJu;
	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 BA2EC606A335;
	Thu,  3 Dec 2026 08:01:56 +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=c2lyKwJu
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=1796284915;
	b=WI4sIYANiBsr/FaDzTb2dMXd9wnKc7CfGjjxj6AXA0wpJsby6927L7WEJnH5TVH0Kwrr
	 WDR+SMuaXAPnR83htXchd3dvJ1WJKLBWWQofCoACThcDbFct1l1IcVXp3+KsMGlaISlu+
	 mz5kZBGUVPP8jSVxMJy+PMRVa05DB2QfYTVMm5SCtHk48sDb7iKfl7DgdzXH1ZlhrD+nW
	 E8IexkmTMpEZZTF+qTJnQKffo5bfZutRl5qxZdkCjt+NZQ8TU6/AkynpE3rZIaafh7QTu
	 N76cGuH98C7Kv3ris8X4buSbwAOCkqRiluJlDaj2O+EUp4/2QaUqQ9r11+ogK20pw4g==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796284915;
	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=vBi8/Mx0xtlD5bQ1hSif6l6um898TQw0v4TSrtyV5+A=;
	b=UIRAZ/l3MLc2vAn01lBucDrU1ZbeQJNe331ewiemLK2Zi50l/IuivGqqS7HHmyTR10Lv
	 Txmb/Qy+HzblBGkCCItmVec+gYb2zaqQ4892Mit6FtGWvifDDuwDYLiJOeCjei6RnV8KI
	 Yp/8B3bkmCs5U5bfwurLMmcY5K0jvfL5jqslr9VOQJxVxoie2c8b7xorpRCiLSn2DnWwC
	 59gTT9iUWAMrGxYcy7qtK2BcvYkDgt+bM/GSZywZFwQipOwd+utsD47cpKfOyB59Hwad1
	 h3XkbraXAUWZBIU7BYeRWgv3PYN0LAEMIjupD7g32Qky2lacoHWoSrDrzCGzzmupD9w==
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=c2lyKwJu;
	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 D62C4606A322;
	Thu,  3 Dec 2026 08:01:55 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BEF41F00893;
	Thu,  3 Dec 2026 08:01:53 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796284915;
	bh=vBi8/Mx0xtlD5bQ1hSif6l6um898TQw0v4TSrtyV5+A=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=c2lyKwJukTOHLliy6cbufOB9zNTm+K60oEoA8xhTqs0FNA/IBj8jjp1bVpT0/lnNz
	 VH7HPSySxZNeiFPtCg+wZExgKtFc7N3v0TnqF18aYxx9FLkJrIAQvrIXKgo/tz+i8D
	 IDgLN/ZFrNKHl9msptHUG7IFRwD+j0UMdFfUeY0gUrOmSlMeCCeE2DQMTopVnfY+ri
	 Ede+S0wpQmG+09gnILdHVHj1WTdoBCBwoLDItAxsVMO97Ap5KqH4jsg9BhR0pVBS5A
	 T/txqf/wnmVSsjmGQUKGutW20GXgRovK0PYaSFPo/tT+9BT/5r/gPgJAv9khnIx0/t
	 8AFdtvyaZCr5A==
X-Cc: netdev@vger.kernel.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,
 aleksandr.loktionov@intel.com, horms@kernel.org,
 michal.swiatkowski@linux.intel.com, grzegorz.nitka@intel.com,
 pmenzel@molgen.mpg.de, wojciech.drewek@intel.com,
 marcin.szycik@linux.intel.com, martyna.szapar-mudlaw@linux.intel.com,
 ivecera@redhat.com, alice.michael@intel.com, jacob.e.keller@intel.com,
 jbrandeb@kernel.org, patryk.holda@intel.com, sx.rinitha@intel.com,
 aaron.ma@canonical.com, intel-wired-lan@lists.osuosl.org,
 linux-kernel@vger.kernel.org
X-In-Reply-To: <20261202071642.2527605-2-poros@redhat.com>
X-sashiko-severity: Low
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