diff options
author | Mel Gorman <mgorman@suse.de> | 2015-02-12 17:58:41 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-12 21:54:08 -0500 |
commit | c0e7cad9f2390087b53e26e7b98958d8793ee02d (patch) | |
tree | 76b69e566d2106fc4a28c17654928cdfafc2c7e4 | |
parent | c819f37e7e174d68cd013abf33725b4e07ced023 (diff) |
mm: numa: add paranoid check around pte_protnone_numa
pte_protnone_numa is only safe to use after VMA checks for PROT_NONE are
complete. Treating a real PROT_NONE PTE as a NUMA hinting fault is going
to result in strangeness so add a check for it. BUG_ON looks like
overkill but if this is hit then it's a serious bug that could result in
corruption so do not even try recovering. It would have been more
comprehensive to check VMA flags in pte_protnone_numa but it would have
made the API ugly just for a debugging check.
Signed-off-by: Mel Gorman <mgorman@suse.de>
Cc: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Dave Jones <davej@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Kirill Shutemov <kirill.shutemov@linux.intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Rik van Riel <riel@redhat.com>
Cc: Sasha Levin <sasha.levin@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | mm/huge_memory.c | 3 | ||||
-rw-r--r-- | mm/memory.c | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 8e791a3db6b6..8e07342b52c0 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c | |||
@@ -1262,6 +1262,9 @@ int do_huge_pmd_numa_page(struct mm_struct *mm, struct vm_area_struct *vma, | |||
1262 | bool migrated = false; | 1262 | bool migrated = false; |
1263 | int flags = 0; | 1263 | int flags = 0; |
1264 | 1264 | ||
1265 | /* A PROT_NONE fault should not end up here */ | ||
1266 | BUG_ON(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))); | ||
1267 | |||
1265 | ptl = pmd_lock(mm, pmdp); | 1268 | ptl = pmd_lock(mm, pmdp); |
1266 | if (unlikely(!pmd_same(pmd, *pmdp))) | 1269 | if (unlikely(!pmd_same(pmd, *pmdp))) |
1267 | goto out_unlock; | 1270 | goto out_unlock; |
diff --git a/mm/memory.c b/mm/memory.c index bf244f56b05a..f7886ab036e7 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
@@ -3013,6 +3013,9 @@ static int do_numa_page(struct mm_struct *mm, struct vm_area_struct *vma, | |||
3013 | bool migrated = false; | 3013 | bool migrated = false; |
3014 | int flags = 0; | 3014 | int flags = 0; |
3015 | 3015 | ||
3016 | /* A PROT_NONE fault should not end up here */ | ||
3017 | BUG_ON(!(vma->vm_flags & (VM_READ | VM_EXEC | VM_WRITE))); | ||
3018 | |||
3016 | /* | 3019 | /* |
3017 | * The "pte" at this point cannot be used safely without | 3020 | * The "pte" at this point cannot be used safely without |
3018 | * validation through pte_unmap_same(). It's of NUMA type but | 3021 | * validation through pte_unmap_same(). It's of NUMA type but |