* [PATCH] [PATCH] memblock: Fix return sizeless candidate on __memblock_find_range_top_down.
@ 2023-01-04 9:50 Levi Yun
2023-01-04 10:24 ` Mike Rapoport
0 siblings, 1 reply; 5+ messages in thread
From: Levi Yun @ 2023-01-04 9:50 UTC (permalink / raw)
To: rppt, akpm; +Cc: linux-mm, linux-kernel, Levi Yun
__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.
Signed-off-by: Levi Yun <ppbuk5246@gmail.com>
---
mm/memblock.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/memblock.c b/mm/memblock.c
index 511d4783dcf1..710e2ef8d67d 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -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;
}
--
2.35.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] [PATCH] memblock: Fix return sizeless candidate on __memblock_find_range_top_down.
2023-01-04 9:50 [PATCH] [PATCH] memblock: Fix return sizeless candidate on __memblock_find_range_top_down Levi Yun
@ 2023-01-04 10:24 ` Mike Rapoport
2023-01-04 10:33 ` Yun Levi
0 siblings, 1 reply; 5+ messages in thread
From: Mike Rapoport @ 2023-01-04 10:24 UTC (permalink / raw)
To: Levi Yun; +Cc: akpm, linux-mm, linux-kernel
On Wed, Jan 04, 2023 at 06:50:49PM +0900, Levi Yun wrote:
> __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.
Did you see an actual issue or it's solely based on code inspection?
> Signed-off-by: Levi Yun <ppbuk5246@gmail.com>
> ---
> mm/memblock.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/memblock.c b/mm/memblock.c
> index 511d4783dcf1..710e2ef8d67d 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -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;
> }
>
> --
> 2.35.1
>
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] [PATCH] memblock: Fix return sizeless candidate on __memblock_find_range_top_down.
2023-01-04 10:24 ` Mike Rapoport
@ 2023-01-04 10:33 ` Yun Levi
2023-01-04 10:46 ` Mike Rapoport
0 siblings, 1 reply; 5+ messages in thread
From: Yun Levi @ 2023-01-04 10:33 UTC (permalink / raw)
To: Mike Rapoport; +Cc: akpm, linux-mm, linux-kernel
> 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.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] [PATCH] memblock: Fix return sizeless candidate on __memblock_find_range_top_down.
2023-01-04 10:33 ` Yun Levi
@ 2023-01-04 10:46 ` Mike Rapoport
2023-01-04 21:13 ` Yun Levi
0 siblings, 1 reply; 5+ messages in thread
From: Mike Rapoport @ 2023-01-04 10:46 UTC (permalink / raw)
To: Yun Levi; +Cc: akpm, linux-mm, linux-kernel
On Wed, Jan 04, 2023 at 07:33:25PM +0900, Yun Levi wrote:
> > 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?
> Thanks.
>
> --
> Sincerely,
> Levi.
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] [PATCH] memblock: Fix return sizeless candidate on __memblock_find_range_top_down.
2023-01-04 10:46 ` Mike Rapoport
@ 2023-01-04 21:13 ` Yun Levi
0 siblings, 0 replies; 5+ messages in thread
From: Yun Levi @ 2023-01-04 21:13 UTC (permalink / raw)
To: Mike Rapoport; +Cc: akpm, linux-mm, linux-kernel
I've got possessed by something... Sorry to make noise again :) Thanks!
On Wed, Jan 4, 2023 at 7:46 PM Mike Rapoport <rppt@kernel.org> wrote:
>
> On Wed, Jan 04, 2023 at 07:33:25PM +0900, Yun Levi wrote:
> > > 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?
>
> > Thanks.
> >
> > --
> > Sincerely,
> > Levi.
>
> --
> Sincerely yours,
> Mike.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-01-04 21:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-04 9:50 [PATCH] [PATCH] memblock: Fix return sizeless candidate on __memblock_find_range_top_down Levi Yun
2023-01-04 10:24 ` Mike Rapoport
2023-01-04 10:33 ` Yun Levi
2023-01-04 10:46 ` Mike Rapoport
2023-01-04 21:13 ` Yun Levi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox