[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1506973525-16491-1-git-send-email-jglisse@redhat.com>
Date: Mon, 2 Oct 2017 15:45:25 -0400
From: Jérôme Glisse <jglisse@...hat.com>
To: <linux-kernel@...r.kernel.org>, linux-mm@...ck.org
Cc: Mark Hairgrove <mhairgrove@...dia.com>,
Jérôme Glisse <jglisse@...hat.com>,
Andrew Morton <akpm@...ux-foundation.org>
Subject: [PATCH] mm/migrate: fix indexing bug (off by one) and avoid out of bound access
From: Mark Hairgrove <mhairgrove@...dia.com>
Index was incremented before last use and thus the second array
could dereference to an invalid address (not mentioning the fact
that it did not properly clear the entry we intended to clear).
Signed-off-by: Mark Hairgrove <mhairgrove@...dia.com>
Signed-off-by: Jérôme Glisse <jglisse@...hat.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>
---
mm/migrate.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mm/migrate.c b/mm/migrate.c
index 6954c14..e00814c 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -2146,8 +2146,9 @@ static int migrate_vma_collect_hole(unsigned long start,
unsigned long addr;
for (addr = start & PAGE_MASK; addr < end; addr += PAGE_SIZE) {
- migrate->src[migrate->npages++] = MIGRATE_PFN_MIGRATE;
+ migrate->src[migrate->npages] = MIGRATE_PFN_MIGRATE;
migrate->dst[migrate->npages] = 0;
+ migrate->npages++;
migrate->cpages++;
}
--
2.4.11
Powered by blists - more mailing lists