memblock: Fix return sizeless candidate on __memblock_find_range_top_down.
PATCH 1/1 memblock: Fix return sizeless candidate on __memblock_find_range_top_down.
__memblock_find_range_top_down can return start address of free region which sizeless then user speicified.
To prevent the above case, add size check on candidate free region.
--- mm/memblock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memblock.c +1 -1
@@ -262,7 +262,7 @@ __memblock_find_range_top_down(phys_addr_t start, phys_addr_t end,continue ; cand =round_down (this_end - size, align); -if (cand >= this_start) +if (cand >= this_start && this_end - cand >= size)return cand; }
Signature · 1 line
2.35.1
Mike Rapoport
maintainerQuoted 3 lines · Levi Yun
__memblock_find_range_top_downcan return start address of free region which sizeless then user speicified.
To prevent the above case, add size check on candidate free region.
Did you see an actual issue or it's solely based on code inspection?
Quoted 21 lines
Signed-off-by Levi Yun <[email protected]>--- mm/memblock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/memblock.c +1
-1@@ -262,7 +262,7 @@ __memblock_find_range_top_down(phys_addr_t start, phys_addr_t end,continue ; cand =round_down (this_end - size, align); -if (cand >= this_start) +if (cand >= this_start && this_end - cand >= size)return cand; }Signature · 1 line
2.35.1
Signature · 2 lines
Sincerely yours, Mike.
Quoted 1 line
Did you see an actual issue or it's solely based on code inspection?
Based on code inspection. I haven't seen the actual issue yet :)
Thanks.
--
Sincerely,
Levi.
Mike Rapoport
maintainerQuoted 3 lines · Yun Levi
Quoted 1 line
Did you see an actual issue or it's solely based on code inspection?
Based on code inspection. I haven't seen the actual issue yet :)
I don't see a problem there. Do you have an example how this could happen?
Quoted 5 lines
Thanks.
--
Sincerely,
Levi.
Signature · 2 lines
Sincerely yours, Mike.
I've got possessed by something... Sorry to make noise again :) Thanks!
Quoted 17 lines · Mike Rapoport
Quoted 3 lines · Yun Levi
Quoted 1 line
Did you see an actual issue or it's solely based on code inspection?
Based on code inspection. I haven't seen the actual issue yet :)
I don't see a problem there. Do you have an example how this could happen?
Quoted 5 lines
Thanks.
--
Sincerely,
Levi.--
Sincerely yours,
Mike.