From: "Matthew Wilcox (Oracle)" <willy@xxxxxxxxxxxxx> Subject: mm/memory: remove page fault assumption of compound page size A compound page in the page cache will not necessarily be of PMD size, so check explicitly. [willy@xxxxxxxxxxxxx: fix remove page fault assumption of compound page size] Link: https://lkml.kernel.org/r/20201001152259.14932-1-willy@xxxxxxxxxxxxx Link: https://lkml.kernel.org/r/20200908195539.25896-3-willy@xxxxxxxxxxxxx Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> Cc: Huang Ying <ying.huang@xxxxxxxxx> Cc: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/memory.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/mm/memory.c~mm-memory-remove-page-fault-assumption-of-compound-page-size +++ a/mm/memory.c @@ -3709,13 +3709,14 @@ static vm_fault_t do_set_pmd(struct vm_f unsigned long haddr = vmf->address & HPAGE_PMD_MASK; pmd_t entry; int i; - vm_fault_t ret; + vm_fault_t ret = VM_FAULT_FALLBACK; if (!transhuge_vma_suitable(vma, haddr)) - return VM_FAULT_FALLBACK; + return ret; - ret = VM_FAULT_FALLBACK; page = compound_head(page); + if (compound_order(page) != HPAGE_PMD_ORDER) + return ret; /* * Archs like ppc64 need additonal space to store information _