• M
    arm64: fix alignment when RANDOMIZE_TEXT_OFFSET is enabled · aed7eb83
    Mark Rutland 提交于
    With ARM64_64K_PAGES and RANDOMIZE_TEXT_OFFSET enabled, we hit the
    following issue on the boot:
    
    kernel BUG at arch/arm64/mm/mmu.c:480!
    Internal error: Oops - BUG: 0 [#1] PREEMPT SMP
    Modules linked in:
    CPU: 0 PID: 0 Comm: swapper Not tainted 4.6.0 #310
    Hardware name: ARM Juno development board (r2) (DT)
    task: ffff000008d58a80 ti: ffff000008d30000 task.ti: ffff000008d30000
    PC is at map_kernel_segment+0x44/0xb0
    LR is at paging_init+0x84/0x5b0
    pc : [<ffff000008c450b4>] lr : [<ffff000008c451a4>] pstate: 600002c5
    
    Call trace:
    [<ffff000008c450b4>] map_kernel_segment+0x44/0xb0
    [<ffff000008c451a4>] paging_init+0x84/0x5b0
    [<ffff000008c42728>] setup_arch+0x198/0x534
    [<ffff000008c40848>] start_kernel+0x70/0x388
    [<ffff000008c401bc>] __primary_switched+0x30/0x74
    
    Commit 7eb90f2f ("arm64: cover the .head.text section in the .text
    segment mapping") removed the alignment between the .head.text and .text
    sections, and used the _text rather than the _stext interval for mapping
    the .text segment.
    
    Prior to this commit _stext was always section aligned and didn't cause
    any issue even when RANDOMIZE_TEXT_OFFSET was enabled. Since that
    alignment has been removed and _text is used to map the .text segment,
    we need ensure _text is always page aligned when RANDOMIZE_TEXT_OFFSET
    is enabled.
    
    This patch adds logic to TEXT_OFFSET fuzzing to ensure that the offset
    is always aligned to the kernel page size. To ensure this, we rely on
    the PAGE_SHIFT being available via Kconfig.
    Signed-off-by: NMark Rutland <mark.rutland@arm.com>
    Reported-by: NSudeep Holla <sudeep.holla@arm.com>
    Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
    Cc: Catalin Marinas <catalin.marinas@arm.com>
    Cc: Will Deacon <will.deacon@arm.com>
    Fixes: 7eb90f2f ("arm64: cover the .head.text section in the .text segment mapping")
    Signed-off-by: NWill Deacon <will.deacon@arm.com>
    aed7eb83
Makefile 3.8 KB