From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796131384; b=oA9McwNvin8v5WNnzSCyhzSmx1V4kn2DuLpBWp2wOUUtux3ebFrZEOW63RlcqLfpoqlH NuTwj7vKp1gVgGVF5oB43P2uTGj/OqtRqKTpp2WgVB62CzoCp7JBO82p4lloX9onFmBhV L0EZdlr5MjN7m8d1LUUVumD9R35PLwDjtpSFjtISCQwDB5b1etVYZZs8krrQUj05Ujj0z LV8pTL0MCnPag3lG14glAKeRCaoXR3wuk3ErXFFEaBke6MUzsX2f7bWh9b5r6G6vVoS7h B17LT8RH+fh1LcFmG8+ImtfzTOEoaHlDseTkvaxJI/lRhkjdaHW/DMKeAYVNC1Bkp3Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796131384; 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=EM5phAbsGZmGMgp9PKxGF7MJU/rIT5d+MFTUUBy6OH4=; b=BfpuN0/MHPvJ9b20prpiRhovO43dtZL2wBwgxyFfj26Llh5XnBp/K4l395VHfYVgEmtZ uVir/2re1nIouEOJdc0PONx4EhVi77/P1Wx3I/BZfJdL6EBVVOaGvGe4+U6zmRUNULixb saxy90PKuwLWEB5phs+5Gh02GybXYU5vCxVMvsux9GgQpSk4uqvcKD0+u+6lqxwWAMz+f lQA3rd7k5b5XUNnLIeL+vOczTWHboQh1uUoM2zrPiW1sRuQ/aCPPEPNTLOnpJfGidswtF VfhTH/mQ3eHRf3smiN4VF3efHUEJ8VKmebMKY5zATnNwbG/fC68Rj+oSlRbQQ29GvPg== 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=elh7CIC7; arc=none smtp.remote-ip=100.103.45.18 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 E84A1606A327; Tue, 1 Dec 2026 13:23:03 +0000 (UTC) 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=elh7CIC7 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 485681F00923; Tue, 1 Dec 2026 13:23:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796131383; bh=EM5phAbsGZmGMgp9PKxGF7MJU/rIT5d+MFTUUBy6OH4=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=elh7CIC75NHAM1L/VOdrx1ljnT1xia9dLsVmjPDoGlh2djiEfFd9LKXdANg34sJ94 7/ZG1ZTIE1yEQnMRqybuI0Cj8l7EbBnMZmlNFQuXIgwmoWZBDq/omoqy1MhRQGaJP6 AMbwscOV9VeBblLETWoy8NKlVNShLi0a8qLkNKhKSUqDtw0DPE6da0en/1mdwFF8eK tC4n+G4CndtxV4Csnptlccqm7oGnjUVkYbnSj85dcNpTOjgok5qbOjJt86yTwIVKnD XRBTM6LMoWOdxtG8I66asPy5ep/Z+aBi+U5HEYyb6zummJ25yKqb8Sq+peQMXp3p91 StiDTDZqF58cQ== Subject: Re: [PATCH net v6 1/4] ice: stop the service task before the PF is unloaded 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 Date: Tue, 01 Dec 2026 13:23:01 +0000 Message-ID: <179613138179.3146.62995099966356105@kernel.org> In-Reply-To: <20261130132107.1177185-2-poros@redhat.com> References: <20261130132107.1177185-2-poros@redhat.com> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider. Critical: 0 · High: 1 (1) · Medium: 0 · 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). - [High] The new early ice_service_task_stop() in ice_remove() does not keep the service work from being queued again during teardown. Pre-existing issues: - [High] This problem wasn't introduced by this patch, but it is a high- severity sibling of the timer use-after-free the patch fixes, in the… -- ice: stop the service task before the PF is unloaded This patch moves ice_service_task_stop() and ice_aq_cancel_waiting_tasks() in ice_remove() back to right after ice_free_vfs(). Commit 8a37f9e2ff40 had moved them to the end of ice_remove(). The goal is to keep the service task from walking pf->vsi[] while aRFS, the netdev, the LAG and the VSIs are freed. > diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c > index 47c6798c97e8f..6dede87b78944 100644 > --- a/drivers/net/ethernet/intel/ice/ice_main.c > +++ b/drivers/net/ethernet/intel/ice/ice_main.c > @@ -5387,6 +5387,9 @@ static void ice_remove(struct pci_dev *pdev) > ice_free_vfs(pf); > } > > + ice_service_task_stop(pf); > + ice_aq_cancel_waiting_tasks(pf); > + [Severity: High] Does this stop keep the service work from being queued again during the rest of ice_remove()? ice_service_task_schedule() checks ICE_SERVICE_DIS without a lock. Only after that does it do the SCHED test_and_set and the queue_work(): void ice_service_task_schedule(struct ice_pf *pf) { 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); } ice_service_task_stop() clears SCHED at the end: if (pf->serv_task.func) cancel_work_sync(&pf->serv_task); clear_bit(ICE_SERVICE_SCHED, pf->state); Several callers of ice_service_task_schedule() are still live at this point: - ice_misc_intr(). The misc IRQ is not freed until ice_deinit()->ice_deinit_pf(). - ice_set_rx_mode() and ice_rx_flow_steer(). The netdev stays registered until ice_unload(). Can this sequence happen? CPU1 (e.g. ice_set_rx_mode()) ice_service_task_schedule() test_bit(ICE_SERVICE_DIS) == 0 CPU0 ice_remove() ice_service_task_stop() set ICE_SERVICE_DIS timer_delete_sync() cancel_work_sync() /* nothing pending */ clear_bit(ICE_SERVICE_SCHED) test_and_set_bit(ICE_SERVICE_SCHED) succeeds queue_work(ice_wq, &pf->serv_task) ice_remove_arfs() ice_unload() ice_deinit() ice_vsi_release_all() ice_service_task() would then walk pf->vsi[] through ice_sync_fltr_subtask(), ice_check_for_hang_subtask(), ice_sync_arfs_fltrs() and so on, while CPU0 frees those structures. The mod_timer() at the end of that run can also arm serv_tmr again. The only later cancel is the one in ice_deinit_dev(), which runs after the VSIs are freed. On non-RT kernels the window is a few instructions. On PREEMPT_RT, threaded IRQs and softirqs can be preempted, so the window can be much longer. The commit message says that "a caller that passed the ICE_SERVICE_DIS test before a stop can still queue the work after it". This fix depends on ice_service_task_stop() keeping the task out of the teardown, though. Would a final stop be needed here to fully close the use-after-free on pf->vsi[]? For example, disable_work_sync() plus timer_shutdown_sync(), or rechecking DIS under a lock that ice_service_task_stop() also takes. [Severity: High] This is a pre-existing issue, not one introduced by this patch. The recovery mode branch earlier in ice_remove() seems to have the same timer use-after-free that the commit message describes: if (ice_is_recovery_mode(&pf->hw)) { ice_service_task_stop(pf); scoped_guard(devl, priv_to_devlink(pf)) { ice_deinit_devlink(pf); } return; } This branch calls ice_service_task_stop() once and returns. It never reaches the second stop in ice_deinit_dev(). The recovery mode work always arms the timer again, and it does not check ICE_SERVICE_DIS: static void ice_service_task_recovery_mode(struct work_struct *work) { ... ice_service_task_complete(pf); mod_timer(&pf->serv_tmr, jiffies + msecs_to_jiffies(100)); } ice_service_task_stop() deletes the timer before it waits for the work: if (pf->serv_tmr.function) timer_delete_sync(&pf->serv_tmr); if (pf->serv_task.func) cancel_work_sync(&pf->serv_task); If ice_service_task_recovery_mode() is running while cancel_work_sync() waits, it arms serv_tmr again after the delete. ice_service_timer() then arms itself again on every expiry. Its mod_timer() runs before the DIS check in ice_service_task_schedule(), and that check only blocks queue_work(). After ice_remove() returns, devres frees the devlink allocation that holds pf, because ice_allocate_pf() registers ice_devlink_free(). Can the timer then fire on freed memory, or in unloaded module text after rmmod? The recovery work arms the timer again every 100ms, so this looks easier to hit than the long last run that the commit message describes. The commit message mentions "a path that calls ice_service_task_stop() only once" in general terms. It does not mention this branch in ice_remove() itself. Would one of these fix it? - a second ice_service_task_stop() on this branch - making ice_service_task_stop() cancel the work before it deletes the timer - using timer_shutdown_sync() on the remove paths > if (!ice_is_safe_mode(pf)) > ice_remove_arfs(pf); > [ ... ] -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261130132107.1177185-1-poros%40redhat.com