From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB03F4E4302; Tue, 13 Oct 2026 11:48:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791892109; cv=none; b=uxFoSttDURUZslQm2+oIdosvKxYH36bUCwadoyyTesXDrSOO6YODe1sWGatzHqiWIDhN70X/l4IcBmLgVLar5+tBOVSsoevfla86dMtQ23VFpUwZNH94qGs27vfj/+edywUdZGHeV0uWPEb1wLBsl5vpeAQc1bxxGwbwwacaQSw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791892109; c=relaxed/simple; bh=j61rn5uNNMnBS2Dc8vfHCvFup9nYNC1yD25a6Q8jXr8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cfePiVbRHvDuKEXdJgtsMNmTzaxAk6/asbENmvV0w89I4lZve8Hyv8ZX5BoBxbesT4yYwzak0Z+Wr1KUgPydGZw4NTIcWBl/45vk80RkyVwKmHH8Xn72KeMLN//hUpu1i8k9FXvbQXzb92mZ46Bw9/MThCy2se1J/oDuYHU1B2I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=HemthCJA; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="HemthCJA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C842B1F000FF; Tue, 13 Oct 2026 11:48:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1791892108; bh=m3ALDQ6N6zqcqteO//EILgnqkGYvl2aVM8WpOw+eio8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=HemthCJAbjMyRaHOJw51Iaj9y5Pi/A77Q2mpjCQq/hEAMc5Fo+2Q7aS8d++xEegaa 6dN/RigYMNU6Ra1MdnVrNWENonUz4WkKCSADNSfzmrp0kaPfCqATthGh2yOwSnQDHA zhmgCHC7dAkF0qGiSZGegA0ecf639MVAuvjxXa+I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Xuanqiang Luo , Marcin Szycik , Aleksandr Loktionov , Patryk Holda , Tony Nguyen , Jakub Kicinski Subject: [PATCH 7.2 062/281] ice: fix use-after-free in dynamic port cleanup Date: Tue, 13 Oct 2026 13:36:18 +0200 Message-ID: <20261013112856.632786586@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261013112855.045212108@linuxfoundation.org> References: <20261013112855.045212108@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Xuanqiang Luo commit 1402fc67d2f4e2e1fc7bf8ee0825b8ad994557ff upstream. ice_dealloc_dynamic_port() uses dyn_port->vsi->idx to erase the dynamic port from pf->dyn_ports. However, it frees the VSI before reading the index for the erase, resulting in a use-after-free. Follow the reverse of the allocation order in ice_alloc_dynamic_port() by erasing the xarray entry before freeing the VSI. Fixes: eda69d654c7e ("ice: add basic devlink subfunctions support") Cc: stable@vger.kernel.org Signed-off-by: Xuanqiang Luo Reviewed-by: Marcin Szycik Reviewed-by: Aleksandr Loktionov Tested-by: Patryk Holda Signed-off-by: Tony Nguyen Link: https://patch.msgid.link/20260928230429.495442-3-anthony.l.nguyen@intel.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/intel/ice/devlink/port.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/ethernet/intel/ice/devlink/port.c +++ b/drivers/net/ethernet/intel/ice/devlink/port.c @@ -590,8 +590,8 @@ static void ice_dealloc_dynamic_port(str xa_erase(&pf->sf_nums, devlink_port->attrs.pci_sf.sf); ice_eswitch_detach_sf(pf, dyn_port); - ice_vsi_free(dyn_port->vsi); xa_erase(&pf->dyn_ports, dyn_port->vsi->idx); + ice_vsi_free(dyn_port->vsi); kfree(dyn_port); }