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 188D547A857; Tue, 21 Jul 2026 17:53:36 +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=1784656417; cv=none; b=f7yALEj6WZVKj0kJTuJkZCyB+ztOTLWolI55KMV705gHA4eG4W2oZOU2m05qxKvtutOZehJ1E6x8f+3k9QHOvuSsMwwjC7evDGuX4PYYzzoKA/fLgc5bVYhXJ8auo+LZ/B7ntiNFe+HFYc6ZTnzo3rBxH+tLizuo/hq1MtFmwHc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784656417; c=relaxed/simple; bh=fEBmjJYDlHt/nQGfh8TcRSjf+9dIbXprkFoTIzpQJ2I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LCttkN50B57klWKZVyX7xwZl+wtfD2uCRZVp2eMvSvIfIBkZTy3RVPfa5VVaUgmP9qlQRC+JUNxMoFS6QOkIenlRaHOCTYTXMqkf8R7ewP/ZBQLo2pWFipmHqanp7EWv6MXSMQegVh8OtjXoLeGGjG7Xol6fKcP+ZdUwbdAANhw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=1IxKvGcs; 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="1IxKvGcs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E5361F000E9; Tue, 21 Jul 2026 17:53:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784656416; bh=OwGjn24Yl5f5VnUGWDV8VAvuQi/+pM3wJh+oLKJXZJ0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=1IxKvGcshmJH2DAGUiDNNB6W0/hE2tvzFtRNXnsU24DD24AvcJQNJ8viYEmLKPt3w Je0WO2hjK8Peg9NPB6fX5jlXssQNX3splhTulCYMxnmZaDOdaRIPNJJWK/DPZBzWBn ZGajz+tVPMVn+hgFJyHZhvpyzNmQD/KFkx10eTjA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, sashiko-bot@kernel.org, Baolu Lu , Pranjal Shrivastava , Joerg Roedel , Sasha Levin Subject: [PATCH 6.18 0326/1611] iommu/vt-d: Fix RB-tree corruption in probe error path Date: Tue, 21 Jul 2026 17:07:22 +0200 Message-ID: <20260721152522.424686367@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152514.750365251@linuxfoundation.org> References: <20260721152514.750365251@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 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Pranjal Shrivastava [ Upstream commit 43bd9e6d5513cb1edbafdeef146a1edc3aaced56 ] The info->node RB-tree member is zero-initialized via kzalloc. If a device does not support ATS, the device_rbtree_insert() call is skipped. If a subsequent probe step fails, the error path jumps to device_rbtree_remove(), which misinterprets the zeroed node as a tree root and corrupts the device RB-tree. Fix this by explicitly initializing the RB-node as empty using RB_CLEAR_NODE() during initialization and guarding the removal with RB_EMPTY_NODE(). Fixes: 4f1492efb495 ("iommu/vt-d: Revert ATS timing change to fix boot failure") Reported-by: sashiko-bot@kernel.org Closes: https://lore.kernel.org/all/20260525205628.CD4431F000E9@smtp.kernel.org/ Suggested-by: Baolu Lu Signed-off-by: Pranjal Shrivastava Link: https://lore.kernel.org/r/20260531170254.60493-2-praan@google.com Signed-off-by: Lu Baolu Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/intel/iommu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index db0cf436c83954..cee1851b692452 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -164,7 +164,10 @@ static void device_rbtree_remove(struct device_domain_info *info) unsigned long flags; spin_lock_irqsave(&iommu->device_rbtree_lock, flags); - rb_erase(&info->node, &iommu->device_rbtree); + if (!RB_EMPTY_NODE(&info->node)) { + rb_erase(&info->node, &iommu->device_rbtree); + RB_CLEAR_NODE(&info->node); + } spin_unlock_irqrestore(&iommu->device_rbtree_lock, flags); } @@ -3787,6 +3790,7 @@ static struct iommu_device *intel_iommu_probe_device(struct device *dev) info->dev = dev; info->iommu = iommu; + RB_CLEAR_NODE(&info->node); if (dev_is_pci(dev)) { if (ecap_dev_iotlb_support(iommu->ecap) && pci_ats_supported(pdev) && -- 2.53.0