This is a note to let you know that I've just added the patch titled s390/boot: Avoid possible physmem_info segment corruption to the 6.10-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: s390-boot-avoid-possible-physmem_info-segment-corrup.patch and it can be found in the queue-6.10 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. commit c9fc3e6f11c891837278d2aaa7345c20f3b378ef Author: Alexander Gordeev <agordeev@xxxxxxxxxxxxx> Date: Wed Aug 21 18:55:06 2024 +0200 s390/boot: Avoid possible physmem_info segment corruption [ Upstream commit d7fd2941ae9a67423d1c7bee985f240e4686634f ] When physical memory for the kernel image is allocated it does not consider extra memory required for offsetting the image start to match it with the lower 20 bits of KASLR virtual base address. That might lead to kernel access beyond its memory range. Suggested-by: Vasily Gorbik <gor@xxxxxxxxxxxxx> Fixes: 693d41f7c938 ("s390/mm: Restore mapping of kernel image using large pages") Signed-off-by: Alexander Gordeev <agordeev@xxxxxxxxxxxxx> Acked-by: Vasily Gorbik <gor@xxxxxxxxxxxxx> Signed-off-by: Vasily Gorbik <gor@xxxxxxxxxxxxx> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx> diff --git a/arch/s390/boot/startup.c b/arch/s390/boot/startup.c index 5a36d5538dae8..7797446620b64 100644 --- a/arch/s390/boot/startup.c +++ b/arch/s390/boot/startup.c @@ -446,9 +446,9 @@ void startup_kernel(void) */ kaslr_large_page_offset = __kaslr_offset & ~_SEGMENT_MASK; if (kaslr_enabled()) { - unsigned long end = ident_map_size - kaslr_large_page_offset; + unsigned long size = kernel_size + kaslr_large_page_offset; - __kaslr_offset_phys = randomize_within_range(kernel_size, _SEGMENT_SIZE, 0, end); + __kaslr_offset_phys = randomize_within_range(size, _SEGMENT_SIZE, 0, ident_map_size); } if (!__kaslr_offset_phys) __kaslr_offset_phys = nokaslr_offset_phys;