]> asedeno.scripts.mit.edu Git - linux.git/commit
iommu/io-pgtable-arm-v7s: Abort allocation when table address overflows the PTE
authorJean-Philippe Brucker <jean-philippe.brucker@arm.com>
Tue, 19 Jun 2018 12:52:24 +0000 (13:52 +0100)
committerWill Deacon <will.deacon@arm.com>
Thu, 26 Jul 2018 10:34:58 +0000 (11:34 +0100)
commit29859aeb8a6ea17ba207933a81b6b77b4d4df81a
treea2a556c2138d72570abb71760f9385464943e201
parentfac83d29d95471ad6a104f8c0d21669a3d59097b
iommu/io-pgtable-arm-v7s: Abort allocation when table address overflows the PTE

When run on a 64-bit system in selftest, the v7s driver may obtain page
table with physical addresses larger than 32-bit. Level-2 tables are 1KB
and are are allocated with slab, which doesn't accept the GFP_DMA32
flag. Currently map() truncates the address written in the PTE, causing
iova_to_phys() or unmap() to access invalid memory. Kasan reports it as
a use-after-free. To avoid any nasty surprise, test if the physical
address fits in a PTE before returning a new table. 32-bit systems,
which are the main users of this page table format, shouldn't see any
difference.

Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
drivers/iommu/io-pgtable-arm-v7s.c