Skip to content

Commit cad7f61

Browse files
kiryltorvalds
authored andcommitted
thp: change_huge_pmd(): make sure we don't try to make a page writable
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 <kirill.shutemov@linux.intel.com> Cc: Andrea Arcangeli <aarcange@redhat.com> Cc: Andi Kleen <ak@linux.intel.com> Cc: "H. Peter Anvin" <hpa@linux.intel.com> Cc: Mel Gorman <mel@csn.ul.ie> Cc: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 93b4796 commit cad7f61

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

mm/huge_memory.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,7 @@ int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
12731273
pmd_t entry;
12741274
entry = pmdp_get_and_clear(mm, addr, pmd);
12751275
entry = pmd_modify(entry, newprot);
1276+
BUG_ON(pmd_write(entry));
12761277
set_pmd_at(mm, addr, pmd, entry);
12771278
spin_unlock(&vma->vm_mm->page_table_lock);
12781279
ret = 1;

0 commit comments

Comments
 (0)