From: sashiko-bot@kernel.org
To: "Nicolin Chen" <nicolinc@nvidia.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v2 06/11] iommu/arm-smmu-v3: Support PRI Page Request in arm_smmu_handle_ppr()
Date: Sat, 30 May 2026 04:59:10 +0000 [thread overview]
Message-ID: <20260530045910.73C781F00893@smtp.kernel.org> (raw)
In-Reply-To: <bfb23bc455b4f3d8c39663fb2316dbede8f5e7d9.1779944354.git.nicolinc@nvidia.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [High] Unbounded memory allocation in report_partial_fault() allows a malicious PCIe endpoint to exhaust kernel memory (OOM).
- [High] Unratelimited logging of unexpected PRI requests allows a malicious endpoint to flood the kernel log.
--
commit 9904fc0d39f6cc48ddad4141a58759c0d2ae2811
Author: Nicolin Chen <nicolinc@nvidia.com>
iommu/arm-smmu-v3: Support PRI Page Request in arm_smmu_handle_ppr()
Now, arm_smmu_page_response() can issue CMDQ_OP_PRI_RESP for page requests
from the IOPF infrastructure. Forward PRI requests from the priq into the
IOPF infrastructure for PRI-enabled masters by building an iopf_fault from
the priq entry and calling iommu_report_device_fault().
> diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> index 061f1d46fda0d..371a8bbdf6756 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> @@ -2252,6 +2253,37 @@ static void arm_smmu_handle_ppr(struct arm_smmu_device *smmu, u64 *evt)
> last = FIELD_GET(PRIQ_0_PRG_LAST, evt[0]);
> grpid = FIELD_GET(PRIQ_1_PRG_IDX, evt[1]);
>
> + mutex_lock(&smmu->streams_mutex);
> + master = arm_smmu_find_master(smmu, sid);
> + if (master && master->pri_enabled) {
> + struct iopf_fault iopf_fault = {0};
> + struct iommu_fault *fault = &iopf_fault.fault;
> +
> + fault->type = IOMMU_FAULT_PAGE_REQ;
> + if (last)
> + fault->prm.flags |= IOMMU_FAULT_PAGE_REQUEST_LAST_PAGE;
[ ... ]
> + fault->prm.addr = FIELD_GET(PRIQ_1_ADDR_MASK, evt[1]) << 12;
> +
> + iommu_report_device_fault(master->dev, &iopf_fault);
[Severity: High]
This isn't a bug introduced by this patch, but does the path handling partial
faults lack bounds checking?
When a PRI request lacks the LAST_PAGE flag, the fault is processed via
report_partial_fault() in drivers/iommu/io-pgfault.c, which dynamically
allocates memory for it:
drivers/iommu/io-pgfault.c:report_partial_fault() {
...
iopf = kzalloc_obj(*iopf);
if (!iopf)
return -ENOMEM;
iopf->fault = *fault;
mutex_lock(&fault_param->lock);
list_add(&iopf->list, &fault_param->partial);
mutex_unlock(&fault_param->lock);
...
}
Is it possible for a compromised PCIe endpoint to exhaust kernel memory by
spamming partial page requests with the PRG_LAST bit cleared, completely
bypassing IOMMU queue limits and triggering an OOM condition?
> + mutex_unlock(&smmu->streams_mutex);
> + return;
> + }
> + mutex_unlock(&smmu->streams_mutex);
> +
> dev_info(smmu->dev, "unexpected PRI request received:\n");
> dev_info(smmu->dev,
> "\tsid 0x%08x.0x%05x: [%u%s] %sprivileged %s%s%s access at iova 0x%016llx\n",
[Severity: High]
This is a pre-existing issue, but could this logging lead to log flooding or a
soft lockup?
Since this message is unratelimited and can be triggered by external device
events in arm_smmu_handle_ppr(), an endpoint sending millions of invalid PRI
requests for disabled or unrecognized Stream IDs could force the kernel to
synchronously print to the log buffer.
Would it make sense to use dev_info_ratelimited() here to prevent CPU
starvation and disk space exhaustion?
> sid, ssid, grpid, last ? "L" : "",
--
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1779944354.git.nicolinc@nvidia.com?part=6
next prev parent reply other threads:[~2026-05-30 4:59 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 7:59 [PATCH v2 00/11] iommu/arm-smmu-v3: Add PRI support Nicolin Chen
2026-05-28 7:59 ` [PATCH v2 01/11] iommu/arm-smmu-v3: Add arm_smmu_attach_release() Nicolin Chen
2026-05-28 7:59 ` [PATCH v2 02/11] iommu/arm-smmu-v3: Factor out __queue_empty() and __queue_consumed() Nicolin Chen
2026-05-28 7:59 ` [PATCH v2 03/11] iommu/arm-smmu-v3: Add arm_smmu_drain_queue_for_iopf() helper Nicolin Chen
2026-05-28 8:43 ` sashiko-bot
2026-05-28 7:59 ` [PATCH v2 04/11] iommu/arm-smmu-v3: Drain in-flight fault handlers Nicolin Chen
2026-05-28 11:45 ` sashiko-bot
2026-05-28 7:59 ` [PATCH v2 05/11] iommu/arm-smmu-v3: Submit CMDQ_OP_PRI_RESP for IOPF event Nicolin Chen
2026-05-28 7:59 ` [PATCH v2 06/11] iommu/arm-smmu-v3: Support PRI Page Request in arm_smmu_handle_ppr() Nicolin Chen
2026-05-30 4:59 ` sashiko-bot [this message]
2026-05-28 7:59 ` [PATCH v2 07/11] iommu/arm-smmu-v3: Disable PRI when no IRQ handler is registered Nicolin Chen
2026-05-28 9:13 ` sashiko-bot
2026-05-28 7:59 ` [PATCH v2 08/11] iommu/arm-smmu-v3: Allocate IOPF queue for ARM_SMMU_FEAT_PRI Nicolin Chen
2026-05-28 8:59 ` sashiko-bot
2026-05-28 7:59 ` [PATCH v2 09/11] PCI/ATS: Add PRI stubs Nicolin Chen
2026-05-28 7:59 ` [PATCH v2 10/11] PCI/ATS: Export pci_enable_pri() and pci_reset_pri() Nicolin Chen
2026-05-28 7:59 ` [PATCH v2 11/11] iommu/arm-smmu-v3: Enable PRI for PCI device in arm_smmu_probe_device() Nicolin Chen
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=20260530045910.73C781F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=nicolinc@nvidia.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