Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
lkl: follow up fix after v6.1 merge (kasan_addr_to_slab)
A note from Eugene Rodionov on github: kasan_addr_to_slab() in mm/kasan/common.c, when addr doesn't correspond to the LKL virtual memory but points in stack. LKL assumes that all the virtual memory is located between memory_start and memory_end variables which are initialized in arch/lkl/mm/bootmem.c. However, the actual memory for stack for LKL threads is located outside of this region and, thus, calling virt_to_slab for a stack address which is outside of the region of LKL memory would result in the crash. In theory, virt_addr_valid above should prevent from calling virt_to_slab on the pointer which isn't a valid virtual address but if we look at the implementation of virt_addr_valid used in LKL we find that it checks the pointer only against memory_end but memory_start isn't used. // include/asm-generic/page.h #define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) \ && ((void *)(kaddr) < (void *)memory_end)) As a result, if the stack memory is located below the LKL virtual memory (which is in my case), then virt_addr_valid would return a non-zero value leading to the call to virt_to_slab. This commit fixes this issue to set PAGE_OFFSET value to memory_start, instead of the default value, 0. Fixes: 0f282f1 ("kasan: use kasan_addr_to_slab in print_address_description") Reported-by: Eugene Rodionov <[email protected]> Co-developed-by: Octavian Purdila <[email protected]> Signed-off-by: Octavian Purdila <[email protected]> Signed-off-by: Hajime Tazaki <[email protected]>
- Loading branch information