Skip to content

iommu/arm-smmu-v3: Fix Tegra241 CMDQV CMD_SYNC use-after-free

Shameer Kolothum linux-arm-kernel linux-iommu lkml 2 versions – Applied

Status from this message: Applied to iommu (arm/smmu/updates), thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 3 repliesApplied
  2. v22 patches 2 repliesSuperseded

Changes in v3 from the cover letter

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/2iommu/arm-smmu-v3: Manage teardown with devmdrivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c+40 -161 reply
2/2iommu/tegra241-cmdqv: Fix CMD_SYNC use-after-free on teardowndrivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h drivers/iommu/arm/arm-smmu-v3/tegra241-cmdqv.c+16 -21 reply

Reviews trailers per patch

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

PatchNicolin ChenJason Gunthorpe
1/2R-b R-b
2/2R-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 v3 0/2] iommu/arm-smmu-v3: Fix Tegra241 CMDQV CMD_SYNC use-after-free

Hi,

Changes from v2:
https://lore.kernel.org/linux-iommu/[email protected]/

-Addressed feedback and picked up R-by tags(Thanks!). -Use explicit type casts in devm action callbacks(patch #1) -Add Cc: stable to patch #1 as it is a pre requisite for patch #2.

Please take a look and let me know.

Thanks,
Shameer

From v2:

The arm-smmu-v3 probe teardown mixes devm and manual cleanup, so resources unwind in the wrong order. The IOPF queue is freed before the event-queue IRQ whose handler uses it. On Tegra241 this is worse: devres frees smmu->cmdq.q.base before arm_smmu_impl_remove() runs, and the CMDQV teardown then issues a CMD_SYNC on the freed queue, a use-after-free.

Patch 1 moves the remaining manual teardown (IOPF queue, vmid_map, device disable) onto devm so the unwind order is correct. Patch 2 adds a device_disable() impl op and uses it to quiesce the Tegra241 VINTFs while the CMDQ is still up, fixing the UAF.

Shameer Kolothum (2):
iommu/arm-smmu-v3: Manage teardown with devm iommu/tegra241-cmdqv: Fix CMD_SYNC use-after-free on teardown

 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h   |  1 +
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c   | 58 ++++++++++++++-----
 .../iommu/arm/arm-smmu-v3/tegra241-cmdqv.c    | 15 ++++-
 3 files changed, 56 insertions(+), 18 deletions(-)
Signature · 1 line
2.43.0