Skip to content

Commit

Permalink
mm: bootmem: fix checking the bitmap when finally freeing bootmem
Browse files Browse the repository at this point in the history
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 41546c1 ("bootmem: clean up
free_all_bootmem_core") (2.6.27) without known reports.

Signed-off-by: Gavin Shan <[email protected]>
Signed-off-by: Johannes Weiner <[email protected]>
Acked-by: Tejun Heo <[email protected]>
Acked-by: David S. Miller <[email protected]>
Cc: Yinghai Lu <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
shangw authored and torvalds committed May 29, 2012
1 parent 955c1cd commit 6dccdcb
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions mm/bootmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6dccdcb

Please sign in to comment.