mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 19:29:37 +00:00
memblock: ensure there is no overflow in memblock_overlaps_region()
commit 023accf5cd
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>
This commit is contained in:
parent
bdca964781
commit
492f4d3cde
1 changed files with 2 additions and 1 deletions
|
@ -164,6 +164,8 @@ bool __init_memblock memblock_overlaps_region(struct memblock_type *type,
|
||||||
{
|
{
|
||||||
unsigned long i;
|
unsigned long i;
|
||||||
|
|
||||||
|
memblock_cap_size(base, &size);
|
||||||
|
|
||||||
for (i = 0; i < type->cnt; i++)
|
for (i = 0; i < type->cnt; i++)
|
||||||
if (memblock_addrs_overlap(base, size, type->regions[i].base,
|
if (memblock_addrs_overlap(base, size, type->regions[i].base,
|
||||||
type->regions[i].size))
|
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)
|
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);
|
return memblock_overlaps_region(&memblock.reserved, base, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue