mm: fix pageblock bitmap allocation
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 18 Feb 2013 17:58:02 +0000 (09:58 -0800)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 6 Mar 2013 03:24:03 +0000 (03:24 +0000)
commit0d15de8ef0b034aa2829ed18492a08789a6ece8a
treee0efd0d7ac21c26b313e92504814f7c45eb87c95
parentf861f64d9250a14a1b84e1edf3f6d0531fc37a0c
mm: fix pageblock bitmap allocation

commit 7c45512df987c5619db041b5c9b80d281e26d3db upstream.

Commit c060f943d092 ("mm: use aligned zone start for pfn_to_bitidx
calculation") fixed out calculation of the index into the pageblock
bitmap when a !SPARSEMEM zome was not aligned to pageblock_nr_pages.

However, the _allocation_ of that bitmap had never taken this alignment
requirement into accout, so depending on the exact size and alignment of
the zone, the use of that index could then access past the allocation,
resulting in some very subtle memory corruption.

This was reported (and bisected) by Ingo Molnar: one of his random
config builds would hang with certain very specific kernel command line
options.

In the meantime, commit c060f943d092 has been marked for stable, so this
fix needs to be back-ported to the stable kernels that backported the
commit to use the right alignment.

Bisected-and-tested-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Mel Gorman <mgorman@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
mm/page_alloc.c