mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 04:34:03 +02:00
kho: fix size calculation in kho_preserved_memory_reserve()
kho_preserved_memory_reserve() calculates the size of a preservation by
doing 1 << (order + PAGE_SHIFT). Since the '1' is a 32-bit integer, it
can only be shifted by 31. That is, it will only work for preservations
up to 2 GiB. Larger preservations will trigger undefined behaviour.
While preservations larger than 2 GiB can't be obtained via folios
currently, they can be obtained via kho_preserve_pages().
For example, memblock reserve_mem uses kho_preserve_pages().
Reservations larger than 2 GiB are valid and will trigger this bug if
properly aligned.
Fix it by using 1UL for shifting.
Fixes: fc33e4b44b ("kexec: enable KHO support for memory preservation")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Cc: stable@vger.kernel.org
Signed-off-by: Pratyush Yadav (Google) <pratyush@kernel.org>
Link: https://patch.msgid.link/20260727150240.889555-1-pratyush@kernel.org
Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
This commit is contained in:
parent
5c4a03afcb
commit
3a0b8fa2eb
|
|
@ -501,7 +501,7 @@ static int __init kho_preserved_memory_reserve(phys_addr_t phys,
|
|||
struct page *page;
|
||||
u64 sz;
|
||||
|
||||
sz = 1 << (order + PAGE_SHIFT);
|
||||
sz = 1UL << (order + PAGE_SHIFT);
|
||||
page = kho_get_preserved_page(phys, order);
|
||||
|
||||
/* Reserve the memory preserved in KHO in memblock */
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user