Skip to content

Commit 6dccdcb

Browse files
shangwtorvalds
authored andcommitted
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 41546c1 ("bootmem: clean up free_all_bootmem_core") (2.6.27) without known reports. Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org> Acked-by: Tejun Heo <tj@kernel.org> Acked-by: David S. Miller <davem@davemloft.net> Cc: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 955c1cd commit 6dccdcb

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

mm/bootmem.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ static unsigned long __init free_all_bootmem_core(bootmem_data_t *bdata)
203203
} else {
204204
unsigned long off = 0;
205205

206+
vec >>= start & (BITS_PER_LONG - 1);
206207
while (vec && off < BITS_PER_LONG) {
207208
if (vec & 1) {
208209
page = pfn_to_page(start + off);

0 commit comments

Comments
 (0)