summaryrefslogtreecommitdiffstats
path: root/mm/hugetlb.c
diff options
context:
space:
mode:
authorNaoya Horiguchi2010-09-08 03:19:32 +0200
committerAndi Kleen2010-10-08 09:32:44 +0200
commit998b4382c1d75a6fd3b0e334dae3ab33bd074d99 (patch)
tree666c8eaad844df0447870f1e6fada4f0fb8007cd /mm/hugetlb.c
parentMerge branch 'hwpoison-fixes' of git://git.kernel.org/pub/scm/linux/kernel/gi... (diff)
downloadkernel-qcow2-linux-998b4382c1d75a6fd3b0e334dae3ab33bd074d99.tar.gz
kernel-qcow2-linux-998b4382c1d75a6fd3b0e334dae3ab33bd074d99.tar.xz
kernel-qcow2-linux-998b4382c1d75a6fd3b0e334dae3ab33bd074d99.zip
hugetlb: fix metadata corruption in hugetlb_fault()
Since the PageHWPoison() check is for avoiding hwpoisoned page remained in pagecache mapping to the process, it should be done in "found in pagecache" branch, not in the common path. Otherwise, metadata corruption occurs if memory failure happens between alloc_huge_page() and lock_page() because page fault fails with metadata changes remained (such as refcount, mapcount, etc.) This patch moves the check to "found in pagecache" branch and fix the problem. ChangeLog since v2: - remove retry check in "new allocation" path. - make description more detailed - change patch name from "HWPOISON, hugetlb: move PG_HWPoison bit check" Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> Signed-off-by: Jun'ichi Nomura <j-nomura@ce.jp.nec.com> Acked-by: Mel Gorman <mel@csn.ul.ie> Reviewed-by: Wu Fengguang <fengguang.wu@intel.com> Reviewed-by: Christoph Lameter <cl@linux.com> Signed-off-by: Andi Kleen <ak@linux.intel.com>
Diffstat (limited to 'mm/hugetlb.c')
-rw-r--r--mm/hugetlb.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index c03273807182..bd031a4c738e 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -2515,22 +2515,19 @@ retry:
hugepage_add_new_anon_rmap(page, vma, address);
}
} else {
+ /*
+ * If memory error occurs between mmap() and fault, some process
+ * don't have hwpoisoned swap entry for errored virtual address.
+ * So we need to block hugepage fault by PG_hwpoison bit check.
+ */
+ if (unlikely(PageHWPoison(page))) {
+ ret = VM_FAULT_HWPOISON;
+ goto backout_unlocked;
+ }
page_dup_rmap(page);
}
/*
- * Since memory error handler replaces pte into hwpoison swap entry
- * at the time of error handling, a process which reserved but not have
- * the mapping to the error hugepage does not have hwpoison swap entry.
- * So we need to block accesses from such a process by checking
- * PG_hwpoison bit here.
- */
- if (unlikely(PageHWPoison(page))) {
- ret = VM_FAULT_HWPOISON;
- goto backout_unlocked;
- }
-
- /*
* If we are going to COW a private mapping later, we examine the
* pending reservations for this page now. This will ensure that
* any allocations necessary to record that reservation occur outside