From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796044892; b=ej50EE15eq3bd83oEgEFU8SRbQEQml/ND8XLYYlWsAP9BSWdtU63kh4cafovvKx5ej2b XLfcl9ppcJ1fi78QJXcDZKfhgRDqKXd9wohQHFUpzhs1ysTG7QatOpDLiKBsRHXw4Irc7 L1BxwUCrzDWy+y1CYRkc79U8FoNjw0UxdXwlPNuzBXvt5fGum4K9sWuNGWWB756Q7Bt4r cl6yTBsVh8fDeYetuA0PWlSVDB5+n0Z+Ut+yE4+iAl2XpTswRCh5rfOGCjVgpRB4BFGee UREkoJZijNNk6cRvu8XO7MujlDoMUKCQrQRh5wh54X0/NfxcEnb7rQGEtQKM23loRYg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796044892; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:From:To:Cc:Subject:Date: Message-ID:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Scanned-By; bh=ZUTm7t0mqs4Ta+3bGS7XTYLiB57R1H06lSbvvLvtd24=; b=M6Q4rN/cpGUiMFqzGz6dXggvCtny4hr5OQmPuOulyu0h/5m7YbEfxznO0mTvFNv0AJqi 7Dd4BznP12N3UPlp/6phNqC3+FVn3AeqDIb/35CWa0rZYsFqzb2aP7MKCfJYZTyd5Wkvy WfOjiDyKEaE5xwGppXbdgtDHj06IsPDkEOgwk6ka7F9VyNwpEnxloEsZVRC5az/o3JsMR TdkpzeuC4hcW80nHn1GiFZ542SzYBfjHd+Om2GBZjCC5ahXkscZYuWe9dPMohd+XhsOKz jNtAyTT6f/1QB9souZf4moHDKXmXN5FWDMK9X857opE4/2HT7yDurnQXLi7gVEnZuaw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HtC90K+I; arc=none smtp.remote-ip=170.10.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B550606A320 for ; Mon, 30 Nov 2026 13:21:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2B550606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HtC90K+I DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796044892; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZUTm7t0mqs4Ta+3bGS7XTYLiB57R1H06lSbvvLvtd24=; b=HtC90K+IAVWUVnx7xF2VZC68XEZnq3Q+9La4qjVk9u0xEDMsqKyW7f8y1xH07ZNQ7kjnl0 z9RPvbssIeQFRDq2suJzNPXv5I+X3AjB2M/tsBhriuN2IObuL1KZVZaIAHf/ecSGuLwnbs kYKVOmQJT8I+VhIVOWz2gg2XGB4qwSw= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-158-mnCm5py-PEKGYP42K1nGEA-1; Mon, 30 Nov 2026 13:21:26 +0000 X-MC-Unique: mnCm5py-PEKGYP42K1nGEA-1 X-Mimecast-MFC-AGG-ID: mnCm5py-PEKGYP42K1nGEA_1796044883 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 30CB7195DE35; Mon, 30 Nov 2026 13:21:23 +0000 (UTC) Received: from poros-thinkpadp16vgen1.redhat.corp (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C810C1800543; Mon, 30 Nov 2026 13:21:16 +0000 (UTC) From: Petr Oros To: netdev@vger.kernel.org Cc: Petr Oros , Tony Nguyen , Przemek Kitszel , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Aleksandr Loktionov , Simon Horman , Michal Swiatkowski , Grzegorz Nitka , Paul Menzel , Wojciech Drewek , Marcin Szycik , Martyna Szapar-Mudlaw , Ivan Vecera , Alice Michael , Jacob Keller , Jesse Brandeburg , Patryk Holda , Rinitha S , Aaron Ma , intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH net v6 1/4] ice: stop the service task before the PF is unloaded Date: Mon, 30 Nov 2026 14:21:03 +0100 Message-ID: <20261130132107.1177185-2-poros@redhat.com> In-Reply-To: <20261130132107.1177185-1-poros@redhat.com> References: <20261130132107.1177185-1-poros@redhat.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 Commit 8a37f9e2ff40 ("ice: move ice_deinit_dev() to the end of deinit 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. The stop in ice_deinit_dev() stays and deletes a timer armed by the last run. 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 puts the stop and the cancel back where ice_remove() had them. ice_devlink_reinit_down() and the error path of ice_probe() also tear the PF down before they stop the service task, a path that calls ice_service_task_stop() only once can be left with a timer that a run in progress armed again, and a caller that passed the ICE_SERVICE_DIS test before a stop can still queue the work after it. 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") Reviewed-by: Ivan Vecera Reviewed-by: Przemek Kitszel Signed-off-by: Petr Oros --- v6: - No code changes. The message says which older problems on the other teardown paths are not changed here (Sashiko review of v5). v5: https://lore.kernel.org/all/20261127085714.1207361-2-poros@redhat.com/ --- drivers/net/ethernet/intel/ice/ice_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index 47c6798c97e8f1..6dede87b78944f 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); + if (!ice_is_safe_mode(pf)) ice_remove_arfs(pf); @@ -5407,7 +5410,6 @@ static void ice_remove(struct pci_dev *pdev) ice_deinit_hw(&pf->hw); ice_deinit_dev(pf); - ice_aq_cancel_waiting_tasks(pf); set_bit(ICE_DOWN, pf->state); } -- 2.56.1