linux/arch/arm64/mm
Catalin Marinas 2776e0e8ef arm64: kasan: Fix zero shadow mapping overriding kernel image shadow
With the 16KB and 64KB page size configurations, SWAPPER_BLOCK_SIZE is
PAGE_SIZE and ARM64_SWAPPER_USES_SECTION_MAPS is 0. Since
kimg_shadow_end is not page aligned (_end shifted by
KASAN_SHADOW_SCALE_SHIFT), the edges of previously mapped kernel image
shadow via vmemmap_populate() may be overridden by subsequent calls to
kasan_populate_zero_shadow(), leading to kernel panics like below:

------------------------------------------------------------------------------
Unable to handle kernel paging request at virtual address fffffc100135068c
pgd = fffffc8009ac0000
[fffffc100135068c] *pgd=00000009ffee0003, *pud=00000009ffee0003, *pmd=00000009ffee0003, *pte=00e0000081a00793
Internal error: Oops: 9600004f [#1] PREEMPT SMP
Modules linked in:
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.5.0-rc4+ #1984
Hardware name: Juno (DT)
task: fffffe09001a0000 ti: fffffe0900200000 task.ti: fffffe0900200000
PC is at __memset+0x4c/0x200
LR is at kasan_unpoison_shadow+0x34/0x50
pc : [<fffffc800846f1cc>] lr : [<fffffc800821ff54>] pstate: 00000245
sp : fffffe0900203db0
x29: fffffe0900203db0 x28: 0000000000000000
x27: 0000000000000000 x26: 0000000000000000
x25: fffffc80099b69d0 x24: 0000000000000001
x23: 0000000000000000 x22: 0000000000002000
x21: dffffc8000000000 x20: 1fffff9001350a8c
x19: 0000000000002000 x18: 0000000000000008
x17: 0000000000000147 x16: ffffffffffffffff
x15: 79746972100e041d x14: ffffff0000000000
x13: ffff000000000000 x12: 0000000000000000
x11: 0101010101010101 x10: 1fffffc11c000000
x9 : 0000000000000000 x8 : fffffc100135068c
x7 : 0000000000000000 x6 : 000000000000003f
x5 : 0000000000000040 x4 : 0000000000000004
x3 : fffffc100134f651 x2 : 0000000000000400
x1 : 0000000000000000 x0 : fffffc100135068c

Process swapper/0 (pid: 1, stack limit = 0xfffffe0900200020)
Call trace:
[<fffffc800846f1cc>] __memset+0x4c/0x200
[<fffffc8008220044>] __asan_register_globals+0x5c/0xb0
[<fffffc8008a09d34>] _GLOBAL__sub_I_65535_1_sunrpc_cache_lookup+0x1c/0x28
[<fffffc8008f20d28>] kernel_init_freeable+0x104/0x274
[<fffffc80089e1948>] kernel_init+0x10/0xf8
[<fffffc8008093a00>] ret_from_fork+0x10/0x50
------------------------------------------------------------------------------

This patch aligns kimg_shadow_start and kimg_shadow_end to
SWAPPER_BLOCK_SIZE in all configurations.

Fixes: f9040773b7 ("arm64: move kernel image to base of vmalloc area")
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
2016-03-11 11:03:35 +00:00
..
cache.S arm64: Use PoU cache instr for I/D coherency 2015-12-17 11:07:13 +00:00
context.c arm64: make mrs_s prefixing implicit in read_cpuid 2016-03-04 14:12:46 +00:00
copypage.c arm64: Defer dcache flush in __cpu_copy_user_page 2015-12-17 11:07:13 +00:00
dma-mapping.c arm64: add __init/__initdata section marker to some functions/variables 2015-12-02 12:17:11 +00:00
dump.c arm64: mm: dump: Use VA_START directly instead of private LOWEST_ADDR 2016-02-26 18:31:41 +00:00
extable.c arm64: switch to relative exception tables 2016-02-24 14:57:26 +00:00
fault.c arm64: User die() instead of panic() in do_page_fault() 2016-02-19 14:28:58 +00:00
flush.c arm64, thp: remove infrastructure for handling splitting PMDs 2016-01-15 17:56:32 -08:00
hugetlbpage.c arm64: hugetlb: add support for PTE contiguous bit 2015-12-21 17:26:00 +00:00
init.c arm64: mm: check at build time that PAGE_OFFSET divides the VA space evenly 2016-03-02 09:45:52 +00:00
ioremap.c arm64: add ioremap physical address information 2015-01-23 15:29:06 +00:00
kasan_init.c arm64: kasan: Fix zero shadow mapping overriding kernel image shadow 2016-03-11 11:03:35 +00:00
Makefile arm64: add KASAN support 2015-10-12 17:46:36 +01:00
mm.h arm64: add better page protections to arm64 2015-01-22 14:54:29 +00:00
mmap.c arm64: mm: support ARCH_MMAP_RND_BITS 2016-01-14 16:00:49 -08:00
mmu.c arm64: mm: Mark .rodata as RO 2016-02-26 15:08:04 +00:00
pageattr.c arm64: Add support for ARCH_SUPPORTS_DEBUG_PAGEALLOC 2016-02-16 15:40:30 +00:00
pgd.c arm64: mm: move pgd_cache initialisation to pgtable_cache_init 2016-01-05 15:43:10 +00:00
proc-macros.S arm64: kernel: fix architected PMU registers unconditional access 2016-01-25 11:09:06 +00:00
proc.S arm64: Add workaround for Cavium erratum 27456 2016-02-26 15:14:27 +00:00