mm/migrate: fix indexing bug (off by one) and avoid out of bound access
Subsystems (2)
PATCH 1/1 mm/migrate: fix indexing bug (off by one) and avoid out of bound access
From: Mark Hairgrove <[email protected]>
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 <[email protected]>
Signed-off-by Jérôme Glisse <[email protected]>
Cc Andrew Morton <[email protected]>
--- mm/migrate.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
mm/migrate.c +2 -1
@@ -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++; }
Signature · 1 line
2.4.11