Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mm: add !pte_present() check on existing hugetlb_entry callbacks

The age table walker doesn't check non-present hugetlb entry in common
path, so hugetlb_entry() callbacks must check it. The reason for this
behavior is that some callers want to handle it in its own way.

[ I think that reason is bogus, btw - it should just do what the regular
code does, which is to call the "pte_hole()" function for such hugetlb
entries - Linus]

However, some callers don't check it now, which causes unpredictable
result, for example when we have a race between migrating hugepage and
reading /proc/pid/numa_maps. This patch fixes it by adding !pte_present
checks on buggy callbacks.

This bug exists for years and got visible by introducing hugepage
migration.

ChangeLog v2:
- fix if condition (check !pte_present() instead of pte_present())

Reported-by: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: <stable@vger.kernel.org> [3.12+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
[ Backported to 3.15. Signed-off-by: Josh Boyer <jwboyer@fedoraproject.org> ]
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Naoya Horiguchi and committed by
Linus Torvalds
d4c54919 d54d14bf

+6 -2
+1 -1
fs/proc/task_mmu.c
··· 1351 1351 struct numa_maps *md; 1352 1352 struct page *page; 1353 1353 1354 - if (pte_none(*pte)) 1354 + if (!pte_present(*pte)) 1355 1355 return 0; 1356 1356 1357 1357 page = pte_page(*pte);
+5 -1
mm/mempolicy.c
··· 526 526 int nid; 527 527 struct page *page; 528 528 spinlock_t *ptl; 529 + pte_t entry; 529 530 530 531 ptl = huge_pte_lock(hstate_vma(vma), vma->vm_mm, (pte_t *)pmd); 531 - page = pte_page(huge_ptep_get((pte_t *)pmd)); 532 + entry = huge_ptep_get((pte_t *)pmd); 533 + if (!pte_present(entry)) 534 + goto unlock; 535 + page = pte_page(entry); 532 536 nid = page_to_nid(page); 533 537 if (node_isset(nid, *nodes) == !!(flags & MPOL_MF_INVERT)) 534 538 goto unlock;