diff options
| author | Madhusudanan Kandasamy <kmadhu@linux.vnet.ibm.com> | 2014-07-10 11:15:13 -0400 |
|---|---|---|
| committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2014-08-05 02:34:06 -0400 |
| commit | eeb03a6eaa02e9171f91e385c52a69b159fc6117 (patch) | |
| tree | 8325d4ab23b055571595fb2b1434d7378201dfca | |
| parent | db97efffb80652f7f879bc1d4837cbc84dc32557 (diff) | |
powerpc: Fail remap_4k_pfn() if PFN doesn't fit inside PTE
remap_4k_pfn() silently truncates upper bits of input 4K PFN
if it cannot be contained in PTE. This leads invalid memory mapping and could
result in a system crash when the memory is accessed. This patch fails
remap_4k_pfn() and returns -EINVAL if the input 4K PFN cannot be contained in
PTE.
V3 : Added parentheses to protect 'pfn' and entire macro as suggested by Brian.
V2 : Rewritten to avoid helper function as suggested by Stephen Rothwell.
Signed-off-by: Madhusudanan Kandasamy <kmadhu@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
| -rw-r--r-- | arch/powerpc/include/asm/pte-hash64-64k.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/arch/powerpc/include/asm/pte-hash64-64k.h b/arch/powerpc/include/asm/pte-hash64-64k.h index d836d945068d..b6d2d42f84b5 100644 --- a/arch/powerpc/include/asm/pte-hash64-64k.h +++ b/arch/powerpc/include/asm/pte-hash64-64k.h | |||
| @@ -75,7 +75,8 @@ | |||
| 75 | (((pte) & _PAGE_COMBO)? MMU_PAGE_4K: MMU_PAGE_64K) | 75 | (((pte) & _PAGE_COMBO)? MMU_PAGE_4K: MMU_PAGE_64K) |
| 76 | 76 | ||
| 77 | #define remap_4k_pfn(vma, addr, pfn, prot) \ | 77 | #define remap_4k_pfn(vma, addr, pfn, prot) \ |
| 78 | remap_pfn_range((vma), (addr), (pfn), PAGE_SIZE, \ | 78 | (WARN_ON(((pfn) >= (1UL << (64 - PTE_RPN_SHIFT)))) ? -EINVAL : \ |
| 79 | __pgprot(pgprot_val((prot)) | _PAGE_4K_PFN)) | 79 | remap_pfn_range((vma), (addr), (pfn), PAGE_SIZE, \ |
| 80 | __pgprot(pgprot_val((prot)) | _PAGE_4K_PFN))) | ||
| 80 | 81 | ||
| 81 | #endif /* __ASSEMBLY__ */ | 82 | #endif /* __ASSEMBLY__ */ |
