Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: poros@redhat.com
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
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	[thread overview]
Message-ID: <179628491355.3146.6554967854382312283@kernel.org> (raw)
In-Reply-To: <20261202071642.2527605-2-poros@redhat.com>

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

  reply	other threads:[~2026-12-03  8:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  7:16 [PATCH net v7 0/4] ice: fix DFLT Rx rule handling for promisc and switchdev Petr Oros
2026-12-02  7:16 ` [PATCH net v7 1/4] ice: stop the service task before the PF is unloaded Petr Oros
2026-12-03  8:01   ` netdev-bot+sashiko [this message]
2026-12-02  7:16 ` [PATCH net v7 2/4] ice: do not leave switchdev mode while subfunction ports exist Petr Oros
2026-12-03  8:01   ` netdev-bot+sashiko
2026-12-02  7:16 ` [PATCH net v7 3/4] ice: resync uplink filters after a switchdev session Petr Oros
2026-12-03  8:01   ` netdev-bot+sashiko
2026-12-02  7:16 ` [PATCH net v7 4/4] ice: use a VLAN agnostic multicast promisc rule pair for PF VSIs Petr Oros

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=179628491355.3146.6554967854382312283@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=aaron.ma@canonical.com \
    --cc=aleksandr.loktionov@intel.com \
    --cc=alice.michael@intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=grzegorz.nitka@intel.com \
    --cc=horms@kernel.org \
    --cc=intel-wired-lan@lists.osuosl.org \
    --cc=ivecera@redhat.com \
    --cc=jacob.e.keller@intel.com \
    --cc=jbrandeb@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcin.szycik@linux.intel.com \
    --cc=martyna.szapar-mudlaw@linux.intel.com \
    --cc=michal.swiatkowski@linux.intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=patryk.holda@intel.com \
    --cc=pmenzel@molgen.mpg.de \
    --cc=poros@redhat.com \
    --cc=przemyslaw.kitszel@intel.com \
    --cc=sx.rinitha@intel.com \
    --cc=wojciech.drewek@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox