thp: change_huge_pmd(): make sure we don't try to make a page writable
Kirill A. Shutemov [Wed, 12 Dec 2012 21:50:57 +0000 (13:50 -0800)]
mprotect core never tries to make page writable using change_huge_pmd().
Let's add an assert that the assumption is true.  It's important to be
sure we will not make huge zero page writable.

Signed-off-by: Kirill A. Shutemov <>
Cc: Andrea Arcangeli <>
Cc: Andi Kleen <>
Cc: "H. Peter Anvin" <>
Cc: Mel Gorman <>
Cc: David Rientjes <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Linus Torvalds <>


index a959b3a..7742fb3 100644 (file)
@@ -1273,6 +1273,7 @@ int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
                pmd_t entry;
                entry = pmdp_get_and_clear(mm, addr, pmd);
                entry = pmd_modify(entry, newprot);
+               BUG_ON(pmd_write(entry));
                set_pmd_at(mm, addr, pmd, entry);
                ret = 1;