mm/memory_hotplug.c: check for missing sections in test_pages_in_a_zone()
authorAndrew Banman <[email protected]>
Tue, 29 Dec 2015 22:54:25 +0000 (14:54 -0800)
committerLinus Torvalds <[email protected]>
Wed, 30 Dec 2015 01:45:49 +0000 (17:45 -0800)
commit5f0f2887f4de9508dcf438deab28f1de8070c271
tree00b2343ccdfd201a3cd19acc26d1460715c01a51
parentb5a8bc338e68d5f6f753e14ae59b30e75a5ffdde
mm/memory_hotplug.c: check for missing sections in test_pages_in_a_zone()

test_pages_in_a_zone() does not account for the possibility of missing
sections in the given pfn range.  pfn_valid_within always returns 1 when
CONFIG_HOLES_IN_ZONE is not set, allowing invalid pfns from missing
sections to pass the test, leading to a kernel oops.

Wrap an additional pfn loop with PAGES_PER_SECTION granularity to check
for missing sections before proceeding into the zone-check code.

This also prevents a crash from offlining memory devices with missing
sections.  Despite this, it may be a good idea to keep the related patch
'[PATCH 3/3] drivers: memory: prohibit offlining of memory blocks with
missing sections' because missing sections in a memory block may lead to
other problems not covered by the scope of this fix.

Signed-off-by: Andrew Banman <[email protected]>
Acked-by: Alex Thorlton <[email protected]>
Cc: Russ Anderson <[email protected]>
Cc: Alex Thorlton <[email protected]>
Cc: Yinghai Lu <[email protected]>
Cc: Greg KH <[email protected]>
Cc: Seth Jennings <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/memory_hotplug.c