Skip to content

iommufd: Cache invalidation hardening and SMMUv3 batching rework

Nicolin Chen linux-arm-kernel linux-iommu linux-kselftest lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest4 patches 8 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4iommufd: Set upper bounds on cache invalidation entry_num and entry_lendrivers/iommu/iommufd/hw_pagetable.c+10 -11 reply
2/4iommufd/selftest: Add invalidation entry_num and entry_len boundary teststools/testing/selftests/iommu/iommufd.c+15 -01 reply
3/4iommu: Avoid copying the user array twice in the full-array copy helperinclude/linux/iommu.h+1 -01 reply
4/4iommu/arm-smmu-v3: Process vIOMMU invalidations in batchesdrivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-iommufd.c+55 -364 replies

Reviews trailers per patch

3 of 4 patches have a Reviewed-by or Acked-by.

PatchLu Baolu
1/4R-b
2/4R-b
3/4R-b
4/4

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

Read the v1 thread

Cover letter [PATCH v1 0/4] iommufd: Cache invalidation hardening and SMMUv3 batching rework

Sashiko pointed out several issues in the iommufd invalidation path, which also prompted a rework of the ARM SMMUv3 vIOMMU invalidation handler:

- entry_len is user-controlled and unbounded, so the trailing-zero check for its forward-compat fields can scan gigabytes of user memory without yielding, long enough to trip the soft-lockup watchdog.

- A large entry_num drives a backend's per-entry invalidation loop with no reschedule, e.g. the VT-d nested path, pinning the CPU.

- The full-array copy helper copies the array twice on the equal-size fast
path: once in bulk, then again entry by entry.

- arm_vsmmu_cache_invalidate() reports converted-but-unsubmitted commands as handled on its error paths.

- It sizes a single kernel allocation from the user-controlled entry_num.

- It rejects an empty-array data_type probe that the uAPI allows.

Fix them properly.

This is on Github:
https://github.com/nicolinc/iommufd/commits/smmuv3_fix_iommufd-v1

Nicolin Chen (4):
iommufd: Set upper bounds on cache invalidation entry_num and
entry_len
iommufd/selftest: Add invalidation entry_num and entry_len boundary
tests
iommu: Avoid copying the user array twice in the full-array copy
helper
iommu/arm-smmu-v3: Process vIOMMU invalidations in batches

 include/linux/iommu.h                         |  1 +
 .../arm/arm-smmu-v3/arm-smmu-v3-iommufd.c     | 91 +++++++++++--------
 drivers/iommu/iommufd/hw_pagetable.c          | 11 ++-
 tools/testing/selftests/iommu/iommufd.c       | 15 +++
 4 files changed, 81 insertions(+), 37 deletions(-)
Signature · 1 line
2.43.0