Skip to content

iommufd: Fix veventq_depth boundary

Nicolin Chen linux-iommu linux-kselftest lkml 3 versions – Applied

Status from this message: Applied to for-next

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest4 patches 2 repliesApplied
  2. v24 patches 6 repliesSuperseded
  3. v14 patches 4 repliesSuperseded

Changelog from the cover letter

v3
* Add Reviewed-by from Kevin
* Update the uAPI header about @veventq_depth limit
v2
https://lore.kernel.org/all/[email protected]/
* Add Reviewed-by from Jason
* Rebase on Jason's for-rc tree
* Update commit message for clarification
* Move "data_len byte-count" to the first
* Drop optimistic read in the allocation path
v1
https://lore.kernel.org/all/[email protected]/

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/4iommufd: Fix data_len byte-count vs element-count mismatchdrivers/iommu/iommufd/iommufd_private.h+1 -10 replies
2/4iommufd: Move vevent memory allocation outside spinlockdrivers/iommu/iommufd/driver.c+8 -50 replies
3/4iommufd: Set veventq_depth upper bounddrivers/iommu/iommufd/eventq.c include/uapi/linux/iommufd.h+7 -20 replies
4/4iommufd/selftest: Add boundary tests for veventq_depthtools/testing/selftests/iommu/iommufd.c tools/testing/selftests/iommu/iommufd_fail_nth.c tools/testing/selftests/iommu/iommufd_utils.h+27 -110 replies

Reviews trailers per patch

All 4 patches have a Reviewed-by or Acked-by.

PatchJason GunthorpeKevin Tian
1/4R-b R-b
2/4R-b R-b
3/4R-b R-b
4/4R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH rc v3 0/4] iommufd: Fix veventq_depth boundary

The upper bound of veventq_depth has been missing for veventq allocation, leaving a vulnerability where userspace could exhaust atomic memory pool.

Fix it properly:
- Allocate outside the spinlock to avoid GFP_ATOMIC
- Cap the veventq_depth upper bound
- Fix event_data byte-count
- Add selftest coverage

Note that QEMU's SMMU has been already allocating veventq using a "HW" EVTQ entry number. So, picking 19 as the known use case, for a minimal level of ABI consistency.

This is on github:
https://github.com/nicolinc/iommufd/commits/fix_veventq_depth-v3

Changelog:
v3
* Add Reviewed-by from Kevin
* Update the uAPI header about @veventq_depth limit
v2
https://lore.kernel.org/all/[email protected]/
* Add Reviewed-by from Jason
* Rebase on Jason's for-rc tree
* Update commit message for clarification
* Move "data_len byte-count" to the first
* Drop optimistic read in the allocation path
v1
https://lore.kernel.org/all/[email protected]/

Nicolin Chen (4):
iommufd: Fix data_len byte-count vs element-count mismatch
iommufd: Move vevent memory allocation outside spinlock
iommufd: Set veventq_depth upper bound iommufd/selftest: Add boundary tests for veventq_depth

 drivers/iommu/iommufd/iommufd_private.h       |  2 +-
 include/uapi/linux/iommufd.h                  |  4 +++-
 tools/testing/selftests/iommu/iommufd_utils.h | 17 +++++++++--------
 drivers/iommu/iommufd/driver.c                | 13 ++++++++-----
 drivers/iommu/iommufd/eventq.c                |  5 ++++-
 tools/testing/selftests/iommu/iommufd.c       | 19 +++++++++++++++++--
 .../selftests/iommu/iommufd_fail_nth.c        |  2 +-
 7 files changed, 43 insertions(+), 19 deletions(-)

base-commit: be93d186ae88a92e7aa77e122d4e661fa57b1e39

Signature · 1 line
2.43.0