Skip to content

Commit d7fd294

Browse files
Alexander GordeevVasily Gorbik
authored andcommitted
s390/boot: Avoid possible physmem_info segment corruption
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 <[email protected]> Fixes: 693d41f ("s390/mm: Restore mapping of kernel image using large pages") Signed-off-by: Alexander Gordeev <[email protected]> Acked-by: Vasily Gorbik <[email protected]> Signed-off-by: Vasily Gorbik <[email protected]>
1 parent b4f5bd6 commit d7fd294

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

arch/s390/boot/startup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,9 @@ void startup_kernel(void)
457457
*/
458458
kaslr_large_page_offset = __kaslr_offset & ~_SEGMENT_MASK;
459459
if (kaslr_enabled()) {
460-
unsigned long end = ident_map_size - kaslr_large_page_offset;
460+
unsigned long size = kernel_size + kaslr_large_page_offset;
461461

462-
__kaslr_offset_phys = randomize_within_range(kernel_size, _SEGMENT_SIZE, 0, end);
462+
__kaslr_offset_phys = randomize_within_range(size, _SEGMENT_SIZE, 0, ident_map_size);
463463
}
464464
if (!__kaslr_offset_phys)
465465
__kaslr_offset_phys = nokaslr_offset_phys;

0 commit comments

Comments
 (0)