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/a0d9b53-bf5d-8bab-ac5-759dc61819c1@google.com
Fixes: 800d8c63b2
("shmem: add huge pages support")
Signed-off-by: Jue Wang <juew@google.com>
Signed-off-by: Hugh Dickins <hughd@google.com>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Yang Shi <shy828301@gmail.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Alistair Popple <apopple@nvidia.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Miaohe Lin <linmiaohe@huawei.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Naoya Horiguchi <naoya.horiguchi@nec.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Peter Xu <peterx@redhat.com>
Cc: Ralph Campbell <rcampbell@nvidia.com>
Cc: Shakeel Butt <shakeelb@google.com>
Cc: Wang Yugui <wangyugui@e16-tech.com>
Cc: Zi Yan <ziy@nvidia.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
494334e43c
commit
31657170de
|
@ -716,11 +716,11 @@ unsigned long page_address_in_vma(struct page *page, struct vm_area_struct *vma)
|
||||||
if (!vma->anon_vma || !page__anon_vma ||
|
if (!vma->anon_vma || !page__anon_vma ||
|
||||||
vma->anon_vma->root != page__anon_vma->root)
|
vma->anon_vma->root != page__anon_vma->root)
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
} else if (page->mapping) {
|
} else if (!vma->vm_file) {
|
||||||
if (!vma->vm_file || vma->vm_file->f_mapping != page->mapping)
|
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
} else
|
} else if (vma->vm_file->f_mapping != compound_head(page)->mapping) {
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
return vma_address(page, vma);
|
return vma_address(page, vma);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue