aboutsummaryrefslogtreecommitdiffstats
path: root/mm/hugetlb.c
diff options
context:
space:
mode:
authorNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>2015-02-11 18:25:28 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-11 20:06:01 -0500
commita8bda28d87c38c6aa93de28ba5d30cc18e865a11 (patch)
tree1c9f477663c6dd1f0caded7d633cbaf8e43fa377 /mm/hugetlb.c
parent0f792cf949a0be506c2aa8bfac0605746b146dda (diff)
mm/hugetlb: add migration/hwpoisoned entry check in hugetlb_change_protection
There is a race condition between hugepage migration and change_protection(), where hugetlb_change_protection() doesn't care about migration entries and wrongly overwrites them. That causes unexpected results like kernel crash. HWPoison entries also can cause the same problem. This patch adds is_hugetlb_entry_(migration|hwpoisoned) check in this function to do proper actions. Fixes: 290408d4a2 ("hugetlb: hugepage migration core") Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> Cc: Hugh Dickins <hughd@google.com> Cc: James Hogan <james.hogan@imgtec.com> Cc: David Rientjes <rientjes@google.com> Cc: Mel Gorman <mel@csn.ul.ie> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Michal Hocko <mhocko@suse.cz> Cc: Rik van Riel <riel@redhat.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Luiz Capitulino <lcapitulino@redhat.com> Cc: Nishanth Aravamudan <nacc@linux.vnet.ibm.com> Cc: Lee Schermerhorn <lee.schermerhorn@hp.com> Cc: Steve Capper <steve.capper@linaro.org> Cc: <stable@vger.kernel.org> [2.6.36+] Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/hugetlb.c')
-rw-r--r--mm/hugetlb.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 385c3a1aced7..c2970e7eb527 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3384,7 +3384,26 @@ unsigned long hugetlb_change_protection(struct vm_area_struct *vma,
3384 spin_unlock(ptl); 3384 spin_unlock(ptl);
3385 continue; 3385 continue;
3386 } 3386 }
3387 if (!huge_pte_none(huge_ptep_get(ptep))) { 3387 pte = huge_ptep_get(ptep);
3388 if (unlikely(is_hugetlb_entry_hwpoisoned(pte))) {
3389 spin_unlock(ptl);
3390 continue;
3391 }
3392 if (unlikely(is_hugetlb_entry_migration(pte))) {
3393 swp_entry_t entry = pte_to_swp_entry(pte);
3394
3395 if (is_write_migration_entry(entry)) {
3396 pte_t newpte;
3397
3398 make_migration_entry_read(&entry);
3399 newpte = swp_entry_to_pte(entry);
3400 set_huge_pte_at(mm, address, ptep, newpte);
3401 pages++;
3402 }
3403 spin_unlock(ptl);
3404 continue;
3405 }
3406 if (!huge_pte_none(pte)) {
3388 pte = huge_ptep_get_and_clear(mm, address, ptep); 3407 pte = huge_ptep_get_and_clear(mm, address, ptep);
3389 pte = pte_mkhuge(huge_pte_modify(pte, newprot)); 3408 pte = pte_mkhuge(huge_pte_modify(pte, newprot));
3390 pte = arch_make_huge_pte(pte, vma, NULL, 0); 3409 pte = arch_make_huge_pte(pte, vma, NULL, 0);