mm/memblock.c: Correctly check whether to trim a block
Subsystems (3)
PATCH 1/1 mm/memblock.c: Correctly check whether to trim a block
Currently in __memblock_remove, the check to trim the top of a block off only checks if the requested base is less than the memblock end. If the end of the requested region is equal to the start of a memblock, this will incorrectly try to remove the block, possibly causing an integer underflow:
---------------------------------------
| | | | | | base end = rgn->base rend
An additional check is needed to see if the end of the requested region is greater than the memblock region:
----------------------
| |
| |
rgn->base base rend end
| |
| |
----------------------- mm/memblock.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
mm/memblock.c +1 -1
@@ -459,7 +459,7 @@ static long __init_memblock __memblock_remove(struct memblock_type *type, }/* And check if we need to trim the top of a block */ -if (base < rend) +if (base < rend && end > rend) rgn->size -= rend - base; }
Signature · 1 line
1.7.8.3
Quoted 6 lines · Laura Abbott
Currently in
__memblock_remove, the check to trim the top of a block off only checks if the requested base is less than the memblock end. If the end of the requested region is equal to the start of a memblock, this will incorrectly try to remove the block, possibly causing an integer underflow:
Quoted 7 lines
---------------------------------------
| | | | | | base end = rgn->base rendAn additional check is needed to see if the end of the requested region is greater than the memblock region:
__memblock_remove() open coded logic is gone now, re-implemented in term of memblock_isolate_range()... though I suppose your patch might have value in -stable...
Cheers,
Ben.
Quoted 18 lines
---------------------- | | | | rgn->base base rend end | | | | --------------------Signed-off-by Laura Abbott <[email protected]>--- mm/memblock.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)mm/memblock.c +0
-0
mm/memblock.c static long __init_memblock __memblock_remove(struct memblock_type *type, · line 465
Quoted 8 lines
mm/memblock.c +1
-1@@ -459,7 +459,7 @@ static long __init_memblock __memblock_remove(struct memblock_type *type, }/* And check if we need to trim the top of a block */ -if (base < rend) +if (base < rend && end > rend) rgn->size -= rend - base; }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>