From: Gavin Shan Date: Tue, 29 May 2012 22:06:32 +0000 (-0700) Subject: mm: bootmem: fix checking the bitmap when finally freeing bootmem X-Git-Tag: upstream/snapshot3+hdmi~7343^2~144 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6dccdcbe2c3ebe152847ac8507e7bded4e3f4546;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git mm: bootmem: fix checking the bitmap when finally freeing bootmem When bootmem releases an unaligned chunk of memory at the beginning of a node to the page allocator, it iterates from that unaligned PFN but checks an aligned word of the page bitmap. The checked bits do not correspond to the PFNs and, as a result, reserved pages can be freed. Properly shift the bitmap word so that the lowest bit corresponds to the starting PFN before entering the freeing loop. This bug has been around since commit 41546c17418f ("bootmem: clean up free_all_bootmem_core") (2.6.27) without known reports. Signed-off-by: Gavin Shan Signed-off-by: Johannes Weiner Acked-by: Tejun Heo Acked-by: David S. Miller Cc: Yinghai Lu Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/bootmem.c b/mm/bootmem.c index 0131170..67872fc 100644 --- a/mm/bootmem.c +++ b/mm/bootmem.c @@ -203,6 +203,7 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata) } else { unsigned long off = 0; + vec >>= start & (BITS_PER_LONG - 1); while (vec && off < BITS_PER_LONG) { if (vec & 1) { page = pfn_to_page(start + off);