From: sashiko-bot@kernel.org
To: "Pranjal Shrivastava" <praan@google.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH 1/6] iommu/amd: Clear aliases before setting the rlookup_table to NULL
Date: Mon, 01 Jun 2026 13:57:53 +0000 [thread overview]
Message-ID: <20260601135753.907831F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260601134204.2150602-2-praan@google.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Moving setup_aliases() before clearing the primary DTE incorrectly copies the active (uncleared) DTE to DMA aliases, failing to clear them.
- [Medium] Reordering setup_aliases() before clearing rlookup_table exposes a missing dev_data error path, causing log spam and aborting alias iteration.
--
commit 3c05610e625a1605bf16151c884edcdce09fdf2d
Author: Pranjal Shrivastava <praan@google.com>
iommu/amd: Clear aliases before setting the rlookup_table to NULL
In iommu_ignore_device(), clearing the primary devid in the lookup table
before calling setup_aliases() causes rlookup_amd_iommu() to fail for
aliases. This commit moves the setup_aliases() call before clearing the
rlookup_table entry.
Fixes: 99fc4ac3d297 ("iommu/amd: Introduce per PCI segment alias_table")
Reported-by: sashiko-bot@kernel.org
Closes: https://lore.kernel.org/all/20260529153216.2AD1E1F00899@smtp.kernel.org/
Signed-off-by: Pranjal Shrivastava <praan@google.com>
> diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c
> index f1333071da103..a94de66a885e7 100644
> --- a/drivers/iommu/amd/iommu.c
> +++ b/drivers/iommu/amd/iommu.c
> @@ -745,10 +745,12 @@ static void iommu_ignore_device(struct amd_iommu *iommu, struct device *dev)
> return;
>
> devid = PCI_SBDF_TO_DEVID(sbdf);
> - pci_seg->rlookup_table[devid] = NULL;
> - memset(&dev_table[devid], 0, sizeof(struct dev_table_entry));
>
> + /* Clear aliases while rlookup is still valid */
> setup_aliases(iommu, dev);
[Severity: High]
Does this copy the active DTE instead of the cleared DTE to the DMA aliases?
By moving the call to setup_aliases() before the memset() that clears the
primary Device Table Entry (DTE), setup_aliases() will read the primary
device's uncleared DTE and write this active DTE to the aliases.
Then memset() clears only the primary DTE, leaving the aliases retaining
their old active translations. Could this lead to unauthorized DMA or hardware
use-after-free if the domain's page tables are subsequently freed?
[Severity: Medium]
Does this reordering also expose a missing dev_data error path when
iommu_ignore_device() is called during early initialization?
If this is called from an early initialization error path before dev_data is
set, dev_data will be NULL. Previously, because rlookup_table[devid] was set
to NULL first, rlookup_amd_iommu() inside clone_alias() would return NULL and
safely exit without further processing.
With this patch, rlookup_table is still valid when setup_aliases() is called,
so clone_alias() proceeds and hits the check:
drivers/iommu/amd/iommu.c:clone_alias() {
...
dev_data = dev_iommu_priv_get(&pdev->dev);
if (!dev_data) {
pr_err("%s : Failed to get dev_data for 0x%x\n", __func__, devid);
ret = -EINVAL;
goto out;
}
...
}
Returning -EINVAL causes pci_for_each_dma_alias() to immediately abort its
iteration. Can this cause unintended log spam and prevent the remaining
aliases from being processed?
> +
> + pci_seg->rlookup_table[devid] = NULL;
> + memset(&dev_table[devid], 0, sizeof(struct dev_table_entry));
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260601134204.2150602-1-praan@google.com?part=1
next prev parent reply other threads:[~2026-06-01 13:57 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-01 13:41 [PATCH 0/6] iommu/amd: Refactors for ATS updates Pranjal Shrivastava
2026-06-01 13:41 ` [PATCH 1/6] iommu/amd: Clear aliases before setting the rlookup_table to NULL Pranjal Shrivastava
2026-06-01 13:57 ` sashiko-bot [this message]
2026-06-01 13:42 ` [PATCH 2/6] iommu/amd: Clear DTE with update_dte256 in iommu_ignore_device() Pranjal Shrivastava
2026-06-01 14:09 ` sashiko-bot
2026-06-01 14:19 ` Jason Gunthorpe
2026-06-02 4:01 ` Pranjal Shrivastava
2026-06-02 8:55 ` Vasant Hegde
2026-06-01 13:42 ` [PATCH 3/6] iommu/amd: Split probe error paths to preserve IRQ remapping Pranjal Shrivastava
2026-06-01 14:30 ` sashiko-bot
2026-06-01 13:42 ` [PATCH 4/6] iommu/amd: Fix Use-After-Free in non-fatal probe error path Pranjal Shrivastava
2026-06-01 14:44 ` sashiko-bot
2026-06-01 13:42 ` [PATCH 5/6] iommu/amd: Fail probe on ATS configuration failure Pranjal Shrivastava
2026-06-01 15:01 ` sashiko-bot
2026-06-01 15:05 ` Pranjal Shrivastava
2026-06-01 13:42 ` [PATCH 6/6] PCI/ATS: Mandate checking pci_ats_supported() before pci_prepare_ats() Pranjal Shrivastava
2026-06-01 19:06 ` sashiko-bot
2026-06-02 8:49 ` [PATCH 0/6] iommu/amd: Refactors for ATS updates Vasant Hegde
2026-06-02 12:08 ` Jason Gunthorpe
2026-06-04 8:23 ` Vasant Hegde
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=20260601135753.907831F00893@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