linux/drivers/iommu/iommufd
Nicolin Chen 4d70986002 iommufd: Set upper bounds on cache invalidation entry_num and entry_len
iommufd_hwpt_invalidate() takes a user-controlled entry_num and entry_len,
each bounded only by U32_MAX. An entry_len beyond the kernel's struct size
makes the copy helper verify the extra bytes are zero, scanning that excess
in one uninterruptible pass; a multi-gigabyte value over zeroed user memory
trips the soft-lockup watchdog.

A large entry_num is the other half, driving the backend invalidation loop
with no reschedule. The VT-d nested handler, for one, copies each entry and
flushes caches per iteration, pinning the CPU on a non-preemptible kernel.

Cap both in the ioctl. entry_len is held under PAGE_SIZE, above any request
struct, and entry_num under 1 << 19, the order of a hardware invalidation
queue and well beyond any real batch, bounding the per-call loop length.

Fixes: 8c6eabae38 ("iommufd: Add IOMMU_HWPT_INVALIDATE")
Link: https://patch.msgid.link/r/447fa93663f7526eb361719e83fa8b649464483d.1780521606.git.nicolinc@nvidia.com
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
2026-06-12 10:44:43 -03:00
..
device.c iommufd v7.1 merge window pull request 2026-04-16 21:21:55 -07:00
double_span.h iommufd: PFN handling for iopt_pages 2022-11-30 20:16:49 -04:00
driver.c iommufd: Move vevent memory allocation outside spinlock 2026-06-01 14:54:18 -03:00
eventq.c iommufd: Avoid partial fault group delivery in iommufd_fault_fops_read() 2026-06-05 11:07:12 -03:00
hw_pagetable.c iommufd: Set upper bounds on cache invalidation entry_num and entry_len 2026-06-12 10:44:43 -03:00
io_pagetable.c iommufd: Fix a race with concurrent allocation and unmap 2026-04-11 09:57:02 -03:00
io_pagetable.h types: reuse common phys_vec type instead of DMABUF open‑coded variant 2026-01-19 10:13:29 -07:00
ioas.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
iommufd_private.h iommufd: Fix data_len byte-count vs element-count mismatch 2026-06-01 14:54:18 -03:00
iommufd_test.h iommufd/selftest: Remove MOCK_IOMMUPT_AMDV1 format 2026-03-31 13:13:08 -03:00
iova_bitmap.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
Kconfig iommufd/selftest: Prevent module/builtin conflicts in kconfig 2026-01-10 10:40:58 +01:00
main.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
Makefile iommufd: Rename fault.c to eventq.c 2025-03-17 14:51:19 -03:00
pages.c iommufd: Destroy the pages content after detaching from dmabuf 2026-06-08 21:20:25 -03:00
selftest.c iommufd v7.1 merge window pull request 2026-04-16 21:21:55 -07:00
vfio_compat.c iommufd: vfio compatibility extension check for noiommu mode 2026-03-02 20:29:01 -04:00
viommu.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00