Linux PCI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Pranjal Shrivastava" <praan@google.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v6 5/6] iommu/vt-d: Fail probe on ATS configuration failure
Date: Fri, 29 May 2026 14:30:48 +0000	[thread overview]
Message-ID: <20260529143048.ED8471F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260529111208.387412-6-praan@google.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Unconditional call to `device_rbtree_remove()` for an uninserted `rb_node` corrupts the IOMMU device rbtree.
--

commit 28c5be83fdd5509a29185b7292f784b77e8d22e7
Author: Pranjal Shrivastava <praan@google.com>

iommu/vt-d: Fail probe on ATS configuration failure

Update the Intel VT-d driver to handle ATS configuration strictly by failing
the device probe if pci_prepare_ats() returns an error. Also, add a WARN_ON
in iommu_enable_pci_ats() to catch enablement failures.

> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index 4d0e65bc131d7..22308e4911e1f 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
[ ... ]
> @@ -3288,7 +3294,10 @@ static struct iommu_device *intel_iommu_probe_device(struct device *dev)
>  
>  	dev_iommu_priv_set(dev, info);
>  	if (pdev && pci_ats_supported(pdev)) {
> -		pci_prepare_ats(pdev, VTD_PAGE_SHIFT);
> +		ret = pci_prepare_ats(pdev, VTD_PAGE_SHIFT);
> +		if (ret)
> +			goto free;
> +
>  		ret = device_rbtree_insert(iommu, info);
>  		if (ret)
>  			goto free;

[Severity: High]
This is a pre-existing issue, but I wanted to ask about the error handling
paths in this function. If a device does not support ATS or isn't a PCI
device, device_rbtree_insert() is skipped here.

However, if a subsequent initialization step fails, such as allocating the
PASID table:

intel_iommu_probe_device() {
	...
	if (sm_supported(iommu) && !dev_is_real_dma_subdevice(dev)) {
		ret = intel_pasid_alloc_table(dev);
		if (ret) {
			dev_err(dev, "PASID table allocation failed\n");
			goto clear_rbtree;
		}
	...
clear_rbtree:
	device_rbtree_remove(info);
free:
	kfree(info);
	...
}

Does this unconditionally call device_rbtree_remove() on a zero-initialized
and uninserted rb_node?

If rb_erase() is called on this uninserted node, could it treat the zeroed
node as the root and overwrite the actual rbtree root with NULL, corrupting
the IOMMU device tracking tree and dropping previously probed ATS devices?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260529111208.387412-1-praan@google.com?part=5

  reply	other threads:[~2026-05-29 14:30 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-29 11:12 [PATCH v6 0/6] iommu: Standardize ATS robustness and state tracking Pranjal Shrivastava
2026-05-29 11:12 ` [PATCH v6 1/6] PCI/ATS: Ensure pci_ats_supported() is PF-aware for VFs Pranjal Shrivastava
2026-05-29 11:12 ` [PATCH v6 2/6] PCI/ATS: Validate STU for VFs in pci_prepare_ats() Pranjal Shrivastava
2026-05-29 11:12 ` [PATCH v6 3/6] PCI/ATS: Mandate checking pci_ats_supported() before pci_prepare_ats() Pranjal Shrivastava
2026-05-29 13:07   ` sashiko-bot
2026-05-29 21:56   ` Nicolin Chen
2026-05-29 11:12 ` [PATCH v6 4/6] iommu/arm-smmu-v3: Standardize ATS enablement failure reporting Pranjal Shrivastava
2026-05-29 13:44   ` sashiko-bot
2026-05-29 21:51   ` Nicolin Chen
2026-05-31 17:13     ` Pranjal Shrivastava
2026-05-29 11:12 ` [PATCH v6 5/6] iommu/vt-d: Fail probe on ATS configuration failure Pranjal Shrivastava
2026-05-29 14:30   ` sashiko-bot [this message]
2026-05-29 11:12 ` [PATCH v6 6/6] iommu/amd: " Pranjal Shrivastava
2026-05-29 15:32   ` sashiko-bot
2026-06-01  6:00   ` Ankit Soni
2026-06-01  6:20     ` Pranjal Shrivastava
2026-06-01  8:17       ` Ankit Soni
2026-06-01 10:35         ` Pranjal Shrivastava
2026-06-01  9:28       ` Vasant Hegde
2026-06-01 10:41         ` Pranjal Shrivastava

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260529143048.ED8471F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=praan@google.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox