]> www.infradead.org Git - users/hch/configfs.git/commitdiff
s390/boot: Avoid possible physmem_info segment corruption
authorAlexander Gordeev <agordeev@linux.ibm.com>
Wed, 21 Aug 2024 16:55:06 +0000 (18:55 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Thu, 22 Aug 2024 17:24:13 +0000 (19:24 +0200)
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@linux.ibm.com>
Fixes: 693d41f7c938 ("s390/mm: Restore mapping of kernel image using large pages")
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Acked-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/boot/startup.c

index cff34744b5a9bf5c3219120d38a412cfb182477a..d69f1dfd3b1e73f4910264d8adc29075e4ae3b0d 100644 (file)
@@ -457,9 +457,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;