s390/kasan: sort out physical vs virtual memory confusion
authorAlexander Gordeev <agordeev@linux.ibm.com>
Tue, 13 Dec 2022 10:31:39 +0000 (11:31 +0100)
committerHeiko Carstens <hca@linux.ibm.com>
Fri, 13 Jan 2023 13:15:04 +0000 (14:15 +0100)
The kasan early boot memory allocators operate on pgalloc_pos
and segment_pos physical address pointers, but fail to convert
it to the corresponding virtual pointers.

Currently it is not a problem, since virtual and physical
addresses on s390 are the same. Nevertheless, should they
ever differ, this would cause an invalid pointer access.

Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
arch/s390/mm/kasan_init.c

index 9f988d4582ed8f62376cebd898192facbdc23c84..c9674f83ed0cb7f2c6f64c47ccc296704e930795 100644 (file)
@@ -39,7 +39,7 @@ static void * __init kasan_early_alloc_segment(void)
        if (segment_pos < segment_low)
                kasan_early_panic("out of memory during initialisation\n");
 
-       return (void *)segment_pos;
+       return __va(segment_pos);
 }
 
 static void * __init kasan_early_alloc_pages(unsigned int order)
@@ -49,7 +49,7 @@ static void * __init kasan_early_alloc_pages(unsigned int order)
        if (pgalloc_pos < pgalloc_low)
                kasan_early_panic("out of memory during initialisation\n");
 
-       return (void *)pgalloc_pos;
+       return __va(pgalloc_pos);
 }
 
 static void * __init kasan_early_crst_alloc(unsigned long val)