Re: [PATCH net v7 1/4] ice: stop the service task before the PF is unloaded
From: Ivan Vecera
Date: Thu Dec 03 2026 - 05:56:08 EST
On 12/2/26 08:16, Petr Oros wrote:
Commit 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinitReviewed-by: Ivan Vecera <ivecera@xxxxxxxxxx>
paths") moved the service task stop and the cancel of the AdminQ event
waiters from after ice_free_vfs() to the end of ice_remove(). Since then
a queued or running service task can still walk pf->vsi[] while
ice_remove_arfs(), ice_unload() and ice_deinit() free the aRFS filters,
the netdev, the LAG and the VSIs. A last run that takes longer than a
timer period also arms the service timer again after the stop at the
end has deleted it, and the timer then fires after the PF is freed.
Stop the service task and cancel the waiters after ice_free_vfs() again,
and make that stop final. The new ice_service_task_shutdown() also
disables the work and shuts the timer down, so a caller that passed the
ICE_SERVICE_DIS test before the stop can no longer queue the work, and
a run in progress can no longer arm the timer after its delete. The
recovery mode branch of ice_remove() gets the same final stop. The stop
in ice_deinit_dev() stays for its other callers. As
before that commit, a devlink flash that is still running when the
driver is removed fails, at the latest when its next AdminQ wait times
out.
This only hardens the removal path. ice_devlink_reinit_down() and the
error paths of ice_probe() and ice_devlink_reinit_up() also tear the PF
down before they stop the service task, all three are older than that
commit and are not changed here.
Found by AI code review. Validated on an E810-C (FW 8.1.1, ICE COMMS
package 1.3.55.0) with a test-only 12 s delay in ice_sync_fltr_subtask()
after it took the VSI pointer, armed right before a promisc change and
rmmod ice. Without this patch KASAN reports a slab-use-after-free in
ice_vsi_fltr_changed() on the freed main VSI, and the kernel then faults
in call_timer_fn() on the timer function of the unloaded module. With it
rmmod waits for the run and nothing is reported. Also tested by removing
the driver during switchdev sessions and with four VFs bound to iavf. No
kernel selftests cover this.
Fixes: 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit paths")
Signed-off-by: Petr Oros <poros@xxxxxxxxxx>