[PATCH v8 7/7] arm: dma-mapping: limit IOMMU mapping size

Murali Karicheri m-karicheri2 at ti.com
Tue Mar 3 09:52:14 PST 2015


arm_iommu_create_mapping() has size parameter of size_t and
arm_setup_iommu_dma_ops() can take a value higher than that
when this is called from the OF code.  So limit the size to
SIZE_MAX.

Tested-by: Suravee Suthikulpanit <Suravee.Suthikulpanit at amd.com> (AMD Seattle)
Signed-off-by: Murali Karicheri <m-karicheri2 at ti.com>
Signed-off-by: Bjorn Helgaas <bhelgaas at google.com>
Reviewed-by: Catalin Marinas <catalin.marinas at arm.com>
Acked-by: Will Deacon <will.deacon at arm.com>
CC: Joerg Roedel <joro at 8bytes.org>
CC: Grant Likely <grant.likely at linaro.org>
CC: Rob Herring <robh+dt at kernel.org>
CC: Russell King <linux at arm.linux.org.uk>
CC: Arnd Bergmann <arnd at arndb.de>
---
 arch/arm/mm/dma-mapping.c |    7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c
index 170a116..fc81a38 100644
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -2027,6 +2027,13 @@ static bool arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size,
 	if (!iommu)
 		return false;
 
+	/*
+	 * currently arm_iommu_create_mapping() takes a max of size_t
+	 * for size param. So check this limit for now.
+	 */
+	if (size > SIZE_MAX)
+		return false;
+
 	mapping = arm_iommu_create_mapping(dev->bus, dma_base, size);
 	if (IS_ERR(mapping)) {
 		pr_warn("Failed to create %llu-byte IOMMU mapping for device %s\n",
-- 
1.7.9.5




More information about the linux-arm-kernel mailing list