Skip to content

Commit 3165717

Browse files
jueatgithubtorvalds
authored andcommitted
mm/thp: fix page_address_in_vma() on file THP tails
Anon THP tails were already supported, but memory-failure may need to use page_address_in_vma() on file THP tails, which its page->mapping check did not permit: fix it. hughd adds: no current usage is known to hit the issue, but this does fix a subtle trap in a general helper: best fixed in stable sooner than later. Link: https://lkml.kernel.org/r/[email protected] Fixes: 800d8c6 ("shmem: add huge pages support") Signed-off-by: Jue Wang <[email protected]> Signed-off-by: Hugh Dickins <[email protected]> Reviewed-by: Matthew Wilcox (Oracle) <[email protected]> Reviewed-by: Yang Shi <[email protected]> Acked-by: Kirill A. Shutemov <[email protected]> Cc: Alistair Popple <[email protected]> Cc: Jan Kara <[email protected]> Cc: Miaohe Lin <[email protected]> Cc: Minchan Kim <[email protected]> Cc: Naoya Horiguchi <[email protected]> Cc: Oscar Salvador <[email protected]> Cc: Peter Xu <[email protected]> Cc: Ralph Campbell <[email protected]> Cc: Shakeel Butt <[email protected]> Cc: Wang Yugui <[email protected]> Cc: Zi Yan <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 494334e commit 3165717

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mm/rmap.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -716,11 +716,11 @@ unsigned long page_address_in_vma(struct page *page, struct vm_area_struct *vma)
716716
if (!vma->anon_vma || !page__anon_vma ||
717717
vma->anon_vma->root != page__anon_vma->root)
718718
return -EFAULT;
719-
} else if (page->mapping) {
720-
if (!vma->vm_file || vma->vm_file->f_mapping != page->mapping)
721-
return -EFAULT;
722-
} else
719+
} else if (!vma->vm_file) {
720+
return -EFAULT;
721+
} else if (vma->vm_file->f_mapping != compound_head(page)->mapping) {
723722
return -EFAULT;
723+
}
724724

725725
return vma_address(page, vma);
726726
}

0 commit comments

Comments
 (0)