From: sashiko-bot@kernel.org
To: "Guanghui Feng" <guanghuifeng@linux.alibaba.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH v6 3/3] iommufd: Add IOMMU_IOAS_RESERVE_IOVAS ioctl
Date: Wed, 28 Oct 2026 09:14:26 +0000 [thread overview]
Message-ID: <sashiko-outbox-187660@kernel.org> (raw)
In-Reply-To: <20261028090453.2392991-4-guanghuifeng@linux.alibaba.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] iommufd: off-by-one ULONG_MAX check in iommufd_ioas_reserve_iovas()
--
commit 0ed118205dea2d86a2a0d60398112fcc9b0dd85e
Author: Guanghui Feng <guanghuifeng@linux.alibaba.com>
iommufd: Add IOMMU_IOAS_RESERVE_IOVAS ioctl
This commit adds the IOMMU_IOAS_RESERVE_IOVAS ioctl to allow userspace to
reserve IOVA ranges in an IOAS so that they are excluded from
IOMMU_IOAS_IOVA_RANGES and rejected by mapping operations.
> diff --git a/drivers/iommu/iommufd/ioas.c b/drivers/iommu/iommufd/ioas.c
> index 8fb5271a95060..1a2361850bd2c 100644
> --- a/drivers/iommu/iommufd/ioas.c
> +++ b/drivers/iommu/iommufd/ioas.c
> @@ -183,6 +183,57 @@ int iommufd_ioas_allow_iovas(struct iommufd_ucmd *ucmd)
> return rc;
> }
>
> +int iommufd_ioas_reserve_iovas(struct iommufd_ucmd *ucmd)
> +{
> + struct iommu_ioas_reserve_iovas *cmd = ucmd->cmd;
> + struct iommu_iova_range __user *ranges;
> + struct iommufd_ioas *ioas;
> + u32 i;
> + int rc;
> +
> + if (cmd->flags)
> + return -EOPNOTSUPP;
> +
> + ioas = iommufd_get_ioas(ucmd->ictx, cmd->ioas_id);
> + if (IS_ERR(ioas))
> + return PTR_ERR(ioas);
> +
> + ranges = u64_to_user_ptr(cmd->ranges);
> +
> + down_write(&ioas->iopt.iova_rwsem);
> + for (i = 0; i < cmd->num_ranges; i++) {
> + struct iommu_iova_range range;
> +
> + rc = copy_from_user(&range, &ranges[i], sizeof(range));
> + if (rc) {
> + rc = -EFAULT;
> + goto out_unlock;
> + }
> + if (range.last < range.start) {
> + rc = -EINVAL;
> + goto out_unlock;
> + }
> + if (range.start >= ULONG_MAX || range.last >= ULONG_MAX) {
> + rc = -EOVERFLOW;
> + goto out_unlock;
> + }
[Severity: Medium]
Should the check in iommufd_ioas_reserve_iovas() in
drivers/iommu/iommufd/ioas.c use > ULONG_MAX instead of >= ULONG_MAX?
struct iommu_iova_range represents an inclusive [start, last] interval, and
iopt_reserve_iova() supports inclusive bounds up to ULONG_MAX, as seen in
drivers/iommu/iommufd/io_pagetable.c:iopt_table_add_domain():
if (geometry->aperture_end != ULONG_MAX) {
rc = iopt_reserve_iova(iopt, geometry->aperture_end + 1,
ULONG_MAX, domain);
The UAPI comment for struct iommu_ioas_reserve_iovas in
include/uapi/linux/iommufd.h also notes:
* A range with last < start fails with -EINVAL. On 32-bit kernels
* a range exceeding the native address width fails with -EOVERFLOW.
With >= ULONG_MAX, any range starting or ending at ULONG_MAX (such as a
32-bit PCI host bridge MMIO window ending at 0xffffffff on a 32-bit kernel,
or a reservation reaching U64_MAX on a 64-bit kernel) is rejected with
-EOVERFLOW.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261028090453.2392991-1-guanghuifeng@linux.alibaba.com?part=3
prev parent reply other threads:[~2026-10-28 9:14 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-21 7:02 [PATCH] iommu: Reserve PCI host bridge MMIO windows in group reserved regions Guanghui Feng
2026-09-21 7:15 ` sashiko-bot
2026-09-21 10:39 ` [PATCH v2 0/2] iommu: Reserve PCI host bridge MMIO windows for IOVA Guanghui Feng
2026-09-21 10:39 ` [PATCH v2 1/2] iommu: Reserve PCI host bridge MMIO windows in group reserved regions Guanghui Feng
2026-09-21 10:50 ` sashiko-bot
2026-09-21 10:39 ` [PATCH v2 2/2] iommufd: Reserve PCI host bridge MMIO windows in IOAS " Guanghui Feng
2026-09-21 11:24 ` [PATCH v2 0/2] iommu: Reserve PCI host bridge MMIO windows for IOVA Robin Murphy
2026-09-21 11:55 ` Jason Gunthorpe
2026-10-04 16:22 ` [PATCH v3 0/2] iommu/iommufd: Expose PCI host bridge MMIO windows for opt-in IOVA avoidance Guanghui Feng
2026-10-04 16:22 ` [PATCH v3 1/2] iommu: Add iommu_get_pci_resv_windows() helper Guanghui Feng
2026-10-04 16:31 ` sashiko-bot
2026-10-22 19:35 ` Jason Gunthorpe
2026-10-04 16:22 ` [PATCH v3 2/2] iommufd: Add IOMMU_GET_PCI_MMIO_WINDOWS ioctl Guanghui Feng
2026-10-22 19:33 ` Jason Gunthorpe
2026-10-25 13:29 ` [PATCH v4 0/2] iommu/iommufd: Expose PCI host bridge MMIO windows for opt-in IOVA avoidance Guanghui Feng
2026-10-25 13:29 ` [PATCH v4 1/2] iommu: Add iommu_for_each_pci_mmio_window() iterator Guanghui Feng
2026-10-27 18:29 ` Jason Gunthorpe
2026-10-25 13:30 ` [PATCH v4 2/2] iommufd: Add IOMMU_GET_PCI_MMIO_WINDOWS ioctl Guanghui Feng
2026-10-27 18:34 ` Jason Gunthorpe
2026-10-28 7:19 ` [PATCH v5 0/3] iommufd: Recommended reservations query and opt-in IOAS reservation Guanghui Feng
2026-10-28 7:19 ` [PATCH v5 1/3] iommu: Add iommu_for_each_pci_mmio_window() iterator Guanghui Feng
2026-10-28 7:19 ` [PATCH v5 2/3] iommufd: Add IOMMU_GET_RECOMMENDED_RESERVATIONS ioctl Guanghui Feng
2026-10-28 7:19 ` [PATCH v5 3/3] iommufd: Add IOMMU_IOAS_RESERVE_IOVAS ioctl Guanghui Feng
2026-10-28 7:33 ` sashiko-bot
2026-10-28 9:04 ` [PATCH v6 0/3] iommufd: Recommended reservations query and opt-in IOAS reservation Guanghui Feng
2026-10-28 9:04 ` [PATCH v6 1/3] iommu: Add iommu_for_each_pci_mmio_window() iterator Guanghui Feng
2026-10-28 9:04 ` [PATCH v6 2/3] iommufd: Add IOMMU_GET_RECOMMENDED_RESERVATIONS ioctl Guanghui Feng
2026-10-28 9:04 ` [PATCH v6 3/3] iommufd: Add IOMMU_IOAS_RESERVE_IOVAS ioctl Guanghui Feng
2026-10-28 9:14 ` sashiko-bot [this message]
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=sashiko-outbox-187660@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=guanghuifeng@linux.alibaba.com \
--cc=kvm@vger.kernel.org \
--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