[Devel] [PATCH hci-8.1 1/8] oracle/mm: fix VM_BUG_ON hit when preserving memory

Konstantin Khorenko khorenko at virtuozzo.com
Wed Oct 14 20:11:04 MSK 2026


From: Anthony Yznaga <anthony.yznaga at oracle.com>

copy_page_range_mt() is a stripped down version of copy_page_range().
Unlike copy_page_range(), it is called during exec with the mmap read
lock held on the outgoing mm. Assert that the mmap lock is held, and
hold the write on the write_protect_seq seqcount_t section. The latter
is needed to avoid a VM_BUG_ON in folio_needs_cow_for_dma().

Orabug: 37588319
Signed-off-by: Anthony Yznaga <anthony.yznaga at oracle.com>
Reviewed-by: Liam R. Howlett <liam.howlett at oracle.com>
(cherry picked from commit b4c299d320c22ed30b03c7e665389c9870dd9bab)

Taken from Oracle linux-uek branch uek8/u2. Applied cleanly. Same
Orabug as 90339648df65 ("oracle/mm: fix vma iterator misconfiguration
that triggers VM_WARN_ONs"), which we already have; this is the second
half of that pair.

Fixes: d674aa9506ea ("oracle/mm: use padata for copying page ranges in vma_dup()")
https://virtuozzo.atlassian.net/browse/VSTOR-150231

Feature: oracle/mm: MADV_DOEXEC madvise() flag
Assisted-by: LLM
Signed-off-by: Konstantin Khorenko <khorenko at virtuozzo.com>
---
 mm/memory.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/mm/memory.c b/mm/memory.c
index 5e414c68f3a9c..d4821379529bf 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1489,10 +1489,16 @@ int copy_page_range_mt(struct vm_area_struct *dst_vma, struct vm_area_struct *sr
 		.min_chunk   = max(1ul << 27, PMD_SIZE),
 		.max_threads = 16,
 	};
+	int ret;
 
 	BUG_ON(!(src_vma->vm_flags & VM_EXEC_KEEP));
 
-	return padata_do_multithreaded(&job);
+	mmap_assert_locked(src_vma->vm_mm);
+	raw_write_seqcount_begin(&src_vma->vm_mm->write_protect_seq);
+	ret = padata_do_multithreaded(&job);
+	raw_write_seqcount_end(&src_vma->vm_mm->write_protect_seq);
+
+	return ret;
 }
 #endif /* CONFIG_PADATA */
 

-- 
2.43.0



More information about the Devel mailing list