提交 cc81717e 编写于 作者: M Michal Hocko 提交者: Linus Torvalds

mm: new_vma_page() cannot see NULL vma for hugetlb pages

Commit 11c731e8 ("mm/mempolicy: fix !vma in new_vma_page()") has
removed BUG_ON(!vma) from new_vma_page which is partially correct
because page_address_in_vma will return EFAULT for non-linear mappings
and at least shared shmem might be mapped this way.

The patch also tried to prevent NULL ptr for hugetlb pages which is not
correct AFAICS because hugetlb pages cannot be mapped as VM_NONLINEAR
and other conditions in page_address_in_vma seem to be legit and catch
real bugs.

This patch restores BUG_ON for PageHuge to catch potential issues when
the to-be-migrated page is not setup properly.
Signed-off-by: NMichal Hocko <mhocko@suse.cz>
Reviewed-by: NBob Liu <bob.liu@oracle.com>
Cc: Sasha Levin <sasha.levin@oracle.com>
Cc: Wanpeng Li <liwanp@linux.vnet.ibm.com>
Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 54b9dd14
...@@ -1199,10 +1199,8 @@ static struct page *new_vma_page(struct page *page, unsigned long private, int * ...@@ -1199,10 +1199,8 @@ static struct page *new_vma_page(struct page *page, unsigned long private, int *
} }
if (PageHuge(page)) { if (PageHuge(page)) {
if (vma) BUG_ON(!vma);
return alloc_huge_page_noerr(vma, address, 1); return alloc_huge_page_noerr(vma, address, 1);
else
return NULL;
} }
/* /*
* if !vma, alloc_page_vma() will use task or system default policy * if !vma, alloc_page_vma() will use task or system default policy
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册