linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: fix potential anon_vma locking issue in mprotect()
@ 2012-09-04 23:39 Michel Lespinasse
  2012-09-04 23:45 ` Andrea Arcangeli
  2012-09-04 23:46 ` Andrew Morton
  0 siblings, 2 replies; 6+ messages in thread
From: Michel Lespinasse @ 2012-09-04 23:39 UTC (permalink / raw)
  To: linux-mm, akpm; +Cc: aarcange

This change fixes an anon_vma locking issue in the following situation:
- vma has no anon_vma
- next has an anon_vma
- vma is being shrunk / next is being expanded, due to an mprotect call

We need to take next's anon_vma lock to avoid races with rmap users
(such as page migration) while next is being expanded.

Signed-off-by: Michel Lespinasse <walken@google.com>
---
 mm/mmap.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/mm/mmap.c b/mm/mmap.c
index 3edfcdfa42d9..6fd7afa0e651 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -578,8 +578,12 @@ again:			remove_next = 1 + (end > next->vm_end);
 	 */
 	if (vma->anon_vma && (importer || start != vma->vm_start)) {
 		anon_vma = vma->anon_vma;
+		VM_BUG_ON(adjust_next && next->anon_vma &&
+			  anon_vma != next->anon_vma);
+	} else if (adjust_next && next->anon_vma)
+		anon_vma = next->anon_vma;
+	if (anon_vma)
 		anon_vma_lock(anon_vma);
-	}
 
 	if (root) {
 		flush_dcache_mmap_lock(mapping);
-- 
1.7.7.3

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-09-05 19:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-04 23:39 [PATCH] mm: fix potential anon_vma locking issue in mprotect() Michel Lespinasse
2012-09-04 23:45 ` Andrea Arcangeli
2012-09-04 23:46 ` Andrew Morton
2012-09-05  0:02   ` Michel Lespinasse
2012-09-05 10:11     ` Andrea Arcangeli
2012-09-05 19:24       ` Hugh Dickins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).