diff options
author | Mike Rapoport <rppt@linux.ibm.com> | 2021-12-13 11:57:08 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-12-17 12:12:24 +0300 |
commit | 492f4d3cde95aadcd1d070db5dd4796ae8019165 (patch) | |
tree | bca9c5ddc08b7eed1f8d2271086806093a3558ac /mm/memblock.c | |
parent | bdca964781a0a804e8183ee856ad028d4386cab5 (diff) | |
download | linux-492f4d3cde95aadcd1d070db5dd4796ae8019165.tar.xz |
memblock: ensure there is no overflow in memblock_overlaps_region()
commit 023accf5cdc1e504a9b04187ec23ff156fe53d90 upstream.
There maybe an overflow in memblock_overlaps_region() if it is called with
base and size such that
base + size > PHYS_ADDR_MAX
Make sure that memblock_overlaps_region() caps the size to prevent such
overflow and remove now duplicated call to memblock_cap_size() from
memblock_is_region_reserved().
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
Tested-by: Tony Lindgren <tony@atomide.com>
Link: https://lore.kernel.org/lkml/20210630071211.21011-1-rppt@kernel.org/
Signed-off-by: Mark-PK Tsai <mark-pk.tsai@mediatek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'mm/memblock.c')
-rw-r--r-- | mm/memblock.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/mm/memblock.c b/mm/memblock.c index 11f6ae37d669..38cef8b6df05 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -164,6 +164,8 @@ bool __init_memblock memblock_overlaps_region(struct memblock_type *type, { unsigned long i; + memblock_cap_size(base, &size); + for (i = 0; i < type->cnt; i++) if (memblock_addrs_overlap(base, size, type->regions[i].base, type->regions[i].size)) @@ -1760,7 +1762,6 @@ bool __init_memblock memblock_is_region_memory(phys_addr_t base, phys_addr_t siz */ bool __init_memblock memblock_is_region_reserved(phys_addr_t base, phys_addr_t size) { - memblock_cap_size(base, &size); return memblock_overlaps_region(&memblock.reserved, base, size); } |