Thread (13 messages) 13 messages, 5 authors, 2026-09-08

Re: [PATCH] mm/rmap: fix missing barrier between anon_vma init and vma->anon_vma publish

flat view

From: Rik van Riel <riel@surriel.com>
Date: 2026-09-05 13:24:07

On Sat, 2026-09-05 at 14:18 +0800, Jinjiang Tu wrote:
quoted hunk ↗ jump to hunk
diff --git a/mm/rmap.c b/mm/rmap.c
index d1819fd69938..a868e835eadb 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -209,7 +209,11 @@ int __anon_vma_prepare(struct vm_area_struct
*vma)
 	/* page_table_lock to protect against threads */
 	spin_lock(&mm->page_table_lock);
 	if (likely(!vma->anon_vma)) {
-		vma->anon_vma = anon_vma;
+		/*
+		 * The fields of anon_vma must be visible before
anon_vma
+		 * is published to vma->anon_vma.
+		 */
+		smp_store_release(&vma->anon_vma, anon_vma);
 		anon_vma_chain_assign(vma, avc, anon_vma);
 		anon_rmap_tree_insert(avc, anon_vma);
 		anon_vma->num_active_vmas++;
Nice catch on this bug!

This is perhaps a dumb question, but does this
write side barrier need to pair with a read
side barrier, to ensure the reads are also
correctly ordered?

-- 
All Rights Reversed.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help