Skip to contentSkip to conversation

Patch "mm/hugetlb: add migration/hwpoisoned entry check in" has been added to the 3.10-stable tree

PATCH [email protected] 1 participant 1 message Apr 26, 2015

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

mm/hugetlb: add migration/hwpoisoned entry check in

to the 3.10-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-hugetlb-add-migration-hwpoisoned-entry-check-in.patch
and it can be found in the queue-3.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From a8bda28d87c38c6aa93de28ba5d30cc18e865a11 Mon Sep 17 00:00:00 2001

From: Naoya Horiguchi <[email protected]>
Date: Wed, 11 Feb 2015 15:25:28 -0800
Subject: mm/hugetlb: add migration/hwpoisoned entry check in
hugetlb_change_protection

From: Naoya Horiguchi <[email protected]>

commit a8bda28d87c38c6aa93de28ba5d30cc18e865a11 upstream.

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.

[[email protected]: resolve conflict to apply to v3.10.71]
Fixes 290408d4a2 ("hugetlb: hugepage migration core")
Cc Hugh Dickins <[email protected]>
Cc James Hogan <[email protected]>
Cc David Rientjes <[email protected]>
Cc Mel Gorman <[email protected]>
Cc Johannes Weiner <[email protected]>
Cc Michal Hocko <[email protected]>
Cc Rik van Riel <[email protected]>
Cc Andrea Arcangeli <[email protected]>
Cc Luiz Capitulino <[email protected]>
Cc Nishanth Aravamudan <[email protected]>
Cc Lee Schermerhorn <[email protected]>
Cc Steve Capper <[email protected]>
---
 mm/hugetlb.c |   21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
mm/hugetlb.c +20 -1
@@ -3117,7 +3117,26 @@ unsigned long hugetlb_change_protection(
 			pages++;
 			continue;
 		}
-		if (!huge_pte_none(huge_ptep_get(ptep))) {
+		pte = huge_ptep_get(ptep);
+		if (unlikely(is_hugetlb_entry_hwpoisoned(pte))) {
+			spin_unlock(ptl);
+			continue;
+		}
+		if (unlikely(is_hugetlb_entry_migration(pte))) {
+			swp_entry_t entry = pte_to_swp_entry(pte);
+
+			if (is_write_migration_entry(entry)) {
+				pte_t newpte;
+
+				make_migration_entry_read(&entry);
+				newpte = swp_entry_to_pte(entry);
+				set_huge_pte_at(mm, address, ptep, newpte);
+				pages++;
+			}
+			spin_unlock(ptl);
+			continue;
+		}
+		if (!huge_pte_none(pte)) {
 			pte = huge_ptep_get_and_clear(mm, address, ptep);
 			pte = pte_mkhuge(huge_pte_modify(pte, newprot));
 			pte = arch_make_huge_pte(pte, vma, NULL, 0);

Patches currently in stable-queue which might be from [email protected] are

queue-3.10/mm-hugetlb-add-migration-hwpoisoned-entry-check-in.patch