This is a note to let you know that I've just added the patch titled mm: add !pte_present() check on existing hugetlb_entry callbacks to the 3.14-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: mm-add-pte_present-check-on-existing-hugetlb_entry-callbacks.patch and it can be found in the queue-3.14 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From d4c54919ed86302094c0ca7d48a8cbd4ee753e92 Mon Sep 17 00:00:00 2001 From: Naoya Horiguchi <n-horiguchi@xxxxxxxxxxxxx> Date: Fri, 6 Jun 2014 10:00:01 -0400 Subject: mm: add !pte_present() check on existing hugetlb_entry callbacks From: Naoya Horiguchi <n-horiguchi@xxxxxxxxxxxxx> commit d4c54919ed86302094c0ca7d48a8cbd4ee753e92 upstream. 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@xxxxxxxxxx> Signed-off-by: Naoya Horiguchi <n-horiguchi@xxxxxxxxxxxxx> Cc: Rik van Riel <riel@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> [ Backported to 3.15. Signed-off-by: Josh Boyer <jwboyer@xxxxxxxxxxxxxxxxx> ] Signed-off-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/proc/task_mmu.c | 2 +- mm/mempolicy.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1350,7 +1350,7 @@ static int gather_hugetbl_stats(pte_t *p struct numa_maps *md; struct page *page; - if (pte_none(*pte)) + if (!pte_present(*pte)) return 0; page = pte_page(*pte); --- a/mm/mempolicy.c +++ b/mm/mempolicy.c @@ -526,9 +526,13 @@ static void queue_pages_hugetlb_pmd_rang int nid; struct page *page; spinlock_t *ptl; + pte_t entry; ptl = huge_pte_lock(hstate_vma(vma), vma->vm_mm, (pte_t *)pmd); - page = pte_page(huge_ptep_get((pte_t *)pmd)); + entry = huge_ptep_get((pte_t *)pmd); + if (!pte_present(entry)) + goto unlock; + page = pte_page(entry); nid = page_to_nid(page); if (node_isset(nid, *nodes) == !!(flags & MPOL_MF_INVERT)) goto unlock; Patches currently in stable-queue which might be from n-horiguchi@xxxxxxxxxxxxx are queue-3.14/mm-add-pte_present-check-on-existing-hugetlb_entry-callbacks.patch queue-3.14/mm-memory-failure.c-fix-memory-leak-by-race-between-poison-and-unpoison.patch -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html