From: Lai Jiangshan <[email protected]> When PTI_CLONE_PTE, the caller doesn't want to expose pages beyond specifid range and it worths a warning.
Signed-off-by: Lai Jiangshan <[email protected]> --- arch/x86/mm/pti.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c index 7ee99ef13a99..cd6da1d42ba9 100644 --- a/arch/x86/mm/pti.c +++ b/arch/x86/mm/pti.c @@ -356,6 +356,13 @@ pti_clone_pgtable(unsigned long start, unsigned long end, * caller, so we just simply align it here. */ addr = round_down(addr, PMD_SIZE); + /* + * Mapping large pmd beyond [start, end) may expose + * secrets to user-space when it wants to clone ptes + * only. + */ + WARN_ON_ONCE(level == PTI_CLONE_PTE && + (addr < start || end < addr + PMD_SIZE)); target_pmd = pti_user_pagetable_walk_pmd(addr); if (WARN_ON(!target_pmd)) -- 2.19.1.6.gb485710b

