mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
kexec_file: stop the top-down search before it underflows
locate_mem_hole_top_down() walks candidates downwards by subtracting
PAGE_SIZE whenever the window conflicts with an existing segment or with
an architecture exclude range.
Nothing stops that subtraction at zero, so a search that reaches the
bottom of the address space wraps temp_start around and continues.
The walk starts inside the range being scanned and only moves down, so
bail out once a candidate ends up above end. That covers every step in
the loop rather than the subtractions alone, and it matches
locate_mem_hole_bottom_up(), which already bounds its candidate on both
sides.
This is a better check than subtracting with check_sub_overflow(), given
that we would have 3 subtractions in this block, and this single fix
would take care of them all (instead of three check_sub_overflow()).
Fixes: cb1052581e ("kexec: implementation of new syscall kexec_file_load")
Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Bradley Morgan <include@grrlz.net>
Link: https://patch.msgid.link/20260812-kexec_posioned-v6-1-e477887086f0@debian.org
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
This commit is contained in:
parent
cee9395acd
commit
c711461303
|
|
@ -484,7 +484,9 @@ static int locate_mem_hole_top_down(unsigned long start, unsigned long end,
|
|||
/* align down start */
|
||||
temp_start = ALIGN_DOWN(temp_start, kbuf->buf_align);
|
||||
|
||||
if (temp_start < start || temp_start < kbuf->buf_min)
|
||||
/* A candidate above the range means the walk wrapped around */
|
||||
if (temp_start < start || temp_start < kbuf->buf_min ||
|
||||
temp_start > end)
|
||||
return 0;
|
||||
|
||||
temp_end = temp_start + kbuf->memsz - 1;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user