Commit ab92661d5d9514647346047f30f67a7f35ffea67
Committed by
Linus Torvalds
1 parent
777c6c5f1f
Exists in
master
and in
20 other branches
do_wp_page: fix regression with execute in place
Fix do_wp_page for VM_MIXEDMAP mappings. In the case where pfn_valid returns 0 for a pfn at the beginning of do_wp_page and the mapping is not shared writable, the code branches to label `gotten:' with old_page == NULL. In case the vma is locked (vma->vm_flags & VM_LOCKED), lock_page, clear_page_mlock, and unlock_page try to access the old_page. This patch checks whether old_page is valid before it is dereferenced. The regression was introduced by "mlock: mlocked pages are unevictable" (commit b291f000393f5a0b679012b39d79fbc85c018233). Signed-off-by: Carsten Otte <cotte@de.ibm.com> Cc: Nick Piggin <npiggin@suse.de> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: <stable@kernel.org> [2.6.28.x] Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff
mm/memory.c
... | ... | @@ -1999,7 +1999,7 @@ |
1999 | 1999 | * Don't let another task, with possibly unlocked vma, |
2000 | 2000 | * keep the mlocked page. |
2001 | 2001 | */ |
2002 | - if (vma->vm_flags & VM_LOCKED) { | |
2002 | + if ((vma->vm_flags & VM_LOCKED) && old_page) { | |
2003 | 2003 | lock_page(old_page); /* for LRU manipulation */ |
2004 | 2004 | clear_page_mlock(old_page); |
2005 | 2005 | unlock_page(old_page); |