Patch "arm64: kaslr: Fix up the kernel image alignment" has been added to the 4.10-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
arm64: kaslr: Fix up the kernel image alignment
to the 4.10-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
arm64-kaslr-fix-up-the-kernel-image-alignment.patch
and it can be found in the queue-4.10 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
afd0e5a876703accb95894f23317a13e2c49b523Mon Sep 17 00:00:00 2001
From: Neeraj Upadhyay <[email protected]>
Date: Wed, 22 Mar 2017 17:08:25 +0530
Subject: arm64: kaslr: Fix up the kernel image alignment
From: Neeraj Upadhyay <[email protected]>
commit afd0e5a876703accb95894f23317a13e2c49b523 upstream.
If kernel image extends across alignment boundary, existing code increases the KASLR offset by size of kernel image. The offset is masked after resizing. There are cases, where after masking, we may still have kernel image extending across boundary. This eventually results in only 2MB block getting mapped while creating the page tables. This results in data aborts while accessing unmapped regions during second relocation (with kaslr offset) in __primary_switch. To fix this problem, round up the kernel image size, by swapper block size, before adding it for correction.
For example consider below case, where kernel image still crosses 1GB alignment boundary, after masking the offset, which is fixed by rounding up kernel image size.
SWAPPER_TABLE_SHIFT = 30
Swapper using section maps with section size 2MB.CONFIG_PGTABLE_LEVELS = 3VA_BITS = 39
_text : 0xffffff8008080000_end : 0xffffff800aa1b000
offset : 0x1f35600000
mask = ((1UL << (VA_BITS - 2)) - 1) & ~(SZ_2M - 1)
(_text + offset) >> SWAPPER_TABLE_SHIFT = 0x3fffffe7c (_end + offset) >> SWAPPER_TABLE_SHIFT = 0x3fffffe7d
offset after existing correction (before mask) = 0x1f37f9b000 (_text + offset) >> SWAPPER_TABLE_SHIFT = 0x3fffffe7d (_end + offset) >> SWAPPER_TABLE_SHIFT = 0x3fffffe7d
offset (after mask) = 0x1f37e00000
(_text + offset) >> SWAPPER_TABLE_SHIFT = 0x3fffffe7c (_end + offset) >> SWAPPER_TABLE_SHIFT = 0x3fffffe7d
new offset w/ rounding up = 0x1f38000000 (_text + offset) >> SWAPPER_TABLE_SHIFT = 0x3fffffe7d (_end + offset) >> SWAPPER_TABLE_SHIFT = 0x3fffffe7d
--- arch/arm64/kernel/kaslr.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
arch/arm64/kernel/kaslr.c +7 -3
@@ -131,11 +131,15 @@ u64 __init kaslr_early_init(u64 dt_phys,/* * The kernel Image should not extend across a 1GB/32MB/512MB alignment * boundary (for 4KB/16KB/64KB granule kernels, respectively). If this -* happens, increase the KASLR offset by the size of the kernel image. +* happens, increase the KASLR offset by the size of the kernel image +* rounded up by SWAPPER_BLOCK_SIZE. */ if ((((u64 )_text + offset + modulo_offset) >>SWAPPER_TABLE_SHIFT ) != - (((u64 )_end + offset + modulo_offset) >>SWAPPER_TABLE_SHIFT )) - offset = (offset + (u64)(_end - _text)) & mask; + (((u64 )_end + offset + modulo_offset) >>SWAPPER_TABLE_SHIFT )) { +u64 kimg_sz = _end - _text; + offset = (offset +round_up (kimg_sz,SWAPPER_BLOCK_SIZE )) + & mask; + }if (IS_ENABLED (CONFIG_KASAN ))/*
Patches currently in stable-queue which might be from [email protected] are
queue-4.10/arm64-kaslr-fix-up-the-kernel-image-alignment.patch