The patch titled Subject: mm/memremap.c: add a bounds check in devm_memremap_pages() has been added to the -mm tree. Its filename is mm-add-a-bounds-check-in-devm_memremap_pages.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-add-a-bounds-check-in-devm_memremap_pages.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-add-a-bounds-check-in-devm_memremap_pages.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Alastair D'Silva <alastair@xxxxxxxxxxx> Subject: mm/memremap.c: add a bounds check in devm_memremap_pages() The call to check_hotplug_memory_addressable() validates that the memory is fully addressable. Without this call, it is possible that we may remap pages that is not physically addressable, resulting in bogus section numbers being returned from __section_nr(). Link: http://lkml.kernel.org/r/20190917010752.28395-3-alastair@xxxxxxxxxxx Signed-off-by: Alastair D'Silva <alastair@xxxxxxxxxxx> Acked-by: David Hildenbrand <david@xxxxxxxxxx> Cc: Dan Williams <dan.j.williams@xxxxxxxxx> Cc: Ira Weiny <ira.weiny@xxxxxxxxx> Cc: Jason Gunthorpe <jgg@xxxxxxxx> Cc: Logan Gunthorpe <logang@xxxxxxxxxxxx> Cc: Michal Hocko <mhocko@xxxxxxxx> Cc: Oscar Salvador <osalvador@xxxxxxxx> Cc: Pavel Tatashin <pasha.tatashin@xxxxxxxxxx> Cc: Qian Cai <cai@xxxxxx> Cc: Wei Yang <richard.weiyang@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/memremap.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/mm/memremap.c~mm-add-a-bounds-check-in-devm_memremap_pages +++ a/mm/memremap.c @@ -195,6 +195,11 @@ void *devm_memremap_pages(struct device int error, nid, is_ram; bool need_devmap_managed = true; + error = check_hotplug_memory_addressable(res->start, + resource_size(res)); + if (error) + return ERR_PTR(error); + switch (pgmap->type) { case MEMORY_DEVICE_PRIVATE: if (!IS_ENABLED(CONFIG_DEVICE_PRIVATE)) { _ Patches currently in -mm which might be from alastair@xxxxxxxxxxx are memory_hotplug-add-a-bounds-check-to-check_hotplug_memory_range.patch mm-add-a-bounds-check-in-devm_memremap_pages.patch mm-dont-manually-decrement-num_poisoned_pages.patch mm-remove-null-check-in-clear_hwpoisoned_pages.patch