All of lore.kernel.org
 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 v4 4/5] iommu/vt-d: Fail probe on ATS configuration failure
Date: Mon, 25 May 2026 20:56:28 +0000	[thread overview]
Message-ID: <20260525205628.CD4431F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260525184347.4059549-5-praan@google.com>

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

Pre-existing issues:
- [High] Unconditional RB-tree removal on error path causes tree corruption for non-ATS devices.
--

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

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

Updates the Intel vt-d driver to strictly handle ats configuration by failing
the device probe if pci_prepare_ats() returns an error. It also throws a
warning if pci_enable_ats() fails during enablement, treating it as a bug.

> 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 does unconditional removal of the rb-node
on the error path cause tree corruption for non-ats devices?

If a device does not support ats, the info structure skips the
device_rbtree_insert() call here, leaving info->node zero-initialized.

However, if a subsequent operation like intel_pasid_alloc_table() fails,
the error path jumps to clear_rbtree:

intel_iommu_probe_device()
    ...
    clear_rbtree:
            device_rbtree_remove(info);
    free:
            kfree(info);

Calling device_rbtree_remove() on this zero-initialized node causes the
rb-tree logic to treat it as a root node with no parent, ultimately
overwriting the actual tree root with null and corrupting the device_rbtree.

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

  reply	other threads:[~2026-05-25 20:56 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-25 18:43 [PATCH v4 0/5] iommu: Standardize ATS robustness and state tracking Pranjal Shrivastava
2026-05-25 18:43 ` [PATCH v4 1/5] PCI/ATS: Ensure pci_ats_supported() is PF-aware for VFs Pranjal Shrivastava
2026-05-25 19:42   ` Nicolin Chen
2026-05-25 18:43 ` [PATCH v4 2/5] PCI/ATS: Validate STU for VFs in pci_prepare_ats() Pranjal Shrivastava
2026-05-25 19:46   ` Nicolin Chen
2026-05-28 20:27     ` Pranjal Shrivastava
2026-05-25 18:43 ` [PATCH v4 3/5] iommu/arm-smmu-v3: Fix ATS state tracking Pranjal Shrivastava
2026-05-25 20:05   ` Nicolin Chen
2026-05-25 20:30     ` Pranjal Shrivastava
2026-05-25 20:40       ` Nicolin Chen
2026-05-25 20:24   ` sashiko-bot
2026-05-25 18:43 ` [PATCH v4 4/5] iommu/vt-d: Fail probe on ATS configuration failure Pranjal Shrivastava
2026-05-25 20:56   ` sashiko-bot [this message]
2026-05-28  5:19     ` Baolu Lu
2026-05-28 17:36       ` Pranjal Shrivastava
2026-05-25 18:43 ` [PATCH v4 5/5] iommu/amd: " Pranjal Shrivastava
2026-05-25 21:35   ` sashiko-bot

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=20260525205628.CD4431F000E9@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.