]> www.infradead.org Git - users/jedix/linux-maple.git/commit
base/memory, hotplug: fix a kernel oops in show_valid_zones()
authorToshi Kani <toshi.kani@hpe.com>
Fri, 3 Feb 2017 21:13:23 +0000 (13:13 -0800)
committerBrian Maly <brian.maly@oracle.com>
Mon, 24 Dec 2018 02:33:17 +0000 (21:33 -0500)
commitbc28b5d3c2e77ec7ff31f63076c9070d6b1cb343
tree95b05d0edfe939d6e4ac672b5037b6b4120b5091
parent69b3d6da397c10bdaacec7c35e05b0921ce647b3
base/memory, hotplug: fix a kernel oops in show_valid_zones()

Reading a sysfs "memoryN/valid_zones" file leads to the following oops
when the first page of a range is not backed by struct page.
show_valid_zones() assumes that 'start_pfn' is always valid for
page_zone().

 BUG: unable to handle kernel paging request at ffffea017a000000
 IP: show_valid_zones+0x6f/0x160

This issue may happen on x86-64 systems with 64GiB or more memory since
their memory block size is bumped up to 2GiB.  [1] An example of such
systems is desribed below.  0x3240000000 is only aligned by 1GiB and
this memory block starts from 0x3200000000, which is not backed by
struct page.

 BIOS-e820: [mem 0x0000003240000000-0x000000603fffffff] usable

Since test_pages_in_a_zone() already checks holes, fix this issue by
extending this function to return 'valid_start' and 'valid_end' for a
given range.  show_valid_zones() then proceeds with the valid range.

Orabug: 29050538

[1] 'Commit bdee237c0343 ("x86: mm: Use 2GB memory block size on
    large-memory x86-64 systems")'

Link: http://lkml.kernel.org/r/20170127222149.30893-3-toshi.kani@hpe.com
Signed-off-by: Toshi Kani <toshi.kani@hpe.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Zhang Zhen <zhenzhang.zhang@huawei.com>
Cc: Reza Arbab <arbab@linux.vnet.ibm.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: <stable@vger.kernel.org> [4.4+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit a96dfddbcc04336bbed50dc2b24823e45e09e80c)
Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
Reviewed-by: Larry Bassel <larry.bassel@oracle.com>
Signed-off-by: Brian Maly <brian.maly@oracle.com>
Conflicts:
drivers/base/memory.c
(retained existing show_valid_zones() code and modified
 to use valid pfns)

Signed-off-by: Brian Maly <brian.maly@oracle.com>
drivers/base/memory.c
include/linux/memory_hotplug.h
mm/memory_hotplug.c