Skip to contentSkip to conversation

Check for wraps in copy_page_range

PATCH New Benjamin Herrenschmidt 1 participant 1 message Feb 17, 2005

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Check for wraps in copy_page_range

Hi !

While browsing the 4 level page table changes (looking for a bug), I noticed that copy_page_range, unlike others, do not check for wraparound, which I suppose could be a problem with 4G/4G architectures or that sort of thing.

This patch fixes it.

mm/memory.c +2 -2
Index: linux-work/mm/memory.c
===================================================================
@@ -358,7 +358,7 @@
 
 	for (; addr < end; addr = next, src_pmd++, dst_pmd++) {
 		next = (addr + PMD_SIZE) & PMD_MASK;
-		if (next > end)
+		if (next > end || next <= addr)
 			next = end;
 		if (pmd_none(*src_pmd))
 			continue;
@@ -390,7 +390,7 @@
 
 	for (; addr < end; addr = next, src_pud++, dst_pud++) {
 		next = (addr + PUD_SIZE) & PUD_MASK;
-		if (next > end)
+		if (next > end || next <= addr)
 			next = end;
 		if (pud_none(*src_pud))
 			continue;