Skip to content

Commit 0809074

Browse files
rmurphy-armjoergroedel
authored andcommitted
iommu/io-pgtable-arm: Fix IOVA validation for 32-bit
Since we ony support the TTB1 quirk for AArch64 contexts, and consequently only for 64-bit builds, the sign-extension aspect of the "are all bits above IAS consistent?" check should implicitly only apply to 64-bit IOVAs. Change the type of the cast to ensure that 32-bit longs don't inadvertently get sign-extended, and thus considered invalid, if they happen to be above 2GB in the TTB0 region. Reported-by: Stephan Gerhold <[email protected]> Signed-off-by: Robin Murphy <[email protected]> Acked-by: Acked-by: Will Deacon <[email protected]> Fixes: db69030 ("iommu/io-pgtable-arm: Prepare for TTBR1 usage") Signed-off-by: Joerg Roedel <[email protected]>
1 parent 77a1bce commit 0809074

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/iommu/io-pgtable-arm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ static int arm_lpae_map(struct io_pgtable_ops *ops, unsigned long iova,
468468
arm_lpae_iopte *ptep = data->pgd;
469469
int ret, lvl = data->start_level;
470470
arm_lpae_iopte prot;
471-
long iaext = (long)iova >> cfg->ias;
471+
long iaext = (s64)iova >> cfg->ias;
472472

473473
/* If no access, then nothing to do */
474474
if (!(iommu_prot & (IOMMU_READ | IOMMU_WRITE)))
@@ -645,7 +645,7 @@ static size_t arm_lpae_unmap(struct io_pgtable_ops *ops, unsigned long iova,
645645
struct arm_lpae_io_pgtable *data = io_pgtable_ops_to_data(ops);
646646
struct io_pgtable_cfg *cfg = &data->iop.cfg;
647647
arm_lpae_iopte *ptep = data->pgd;
648-
long iaext = (long)iova >> cfg->ias;
648+
long iaext = (s64)iova >> cfg->ias;
649649

650650
if (WARN_ON(!size || (size & cfg->pgsize_bitmap) != size))
651651
return 0;

0 commit comments

Comments
 (0)