]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Check for wraps in copy_page_range
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Wed, 16 Feb 2005 23:54:05 +0000 (15:54 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Wed, 16 Feb 2005 23:54:05 +0000 (15:54 -0800)
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.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
mm/memory.c

index 81699244f60631b890b1d7ab45fa08b700d736cd..c74ced6b9ccae7d8b24e7e49f6e665356ce67366 100644 (file)
@@ -358,7 +358,7 @@ static int copy_pmd_range(struct mm_struct *dst_mm,  struct mm_struct *src_mm,
 
        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 @@ static int copy_pud_range(struct mm_struct *dst_mm,  struct mm_struct *src_mm,
 
        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;