From: Jason Yan yanaijie@huawei.com
maillist inclusion category: feature feature: PowerPC64 kaslr support bugzilla: https://gitee.com/openeuler/kernel/issues/I8OHAZ CVE: NA
Reference: https://patchwork.ozlabs.org/project/linuxppc-dev/patch/20200306064033.3398-...
-------------------------------------------------
The BSS section has already cleared out in the first pass. No need to clear it again. This can save some time when booting with KASLR enabled.
Signed-off-by: Jason Yan yanaijie@huawei.com Cc: Scott Wood oss@buserror.net Cc: Diana Craciun diana.craciun@nxp.com Cc: Michael Ellerman mpe@ellerman.id.au Cc: Christophe Leroy christophe.leroy@c-s.fr Cc: Benjamin Herrenschmidt benh@kernel.crashing.org Cc: Paul Mackerras paulus@samba.org Cc: Nicholas Piggin npiggin@gmail.com Cc: Kees Cook keescook@chromium.org Signed-off-by: Cui GaoSheng cuigaosheng1@huawei.com Signed-off-by: GUO Zihua guozihua@huawei.com --- arch/powerpc/kernel/head_64.S | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/arch/powerpc/kernel/head_64.S b/arch/powerpc/kernel/head_64.S index 41d5cbd1e003..68592eec0e70 100644 --- a/arch/powerpc/kernel/head_64.S +++ b/arch/powerpc/kernel/head_64.S @@ -958,6 +958,13 @@ start_here_multiplatform: /* Adjust TOC for moved kernel. Could adjust when moving it instead. */ bl relative_toc
+ /* Do not clear the BSS for the second pass if randomized */ + LOAD_REG_ADDR(r3, kernstart_virt_addr) + ld r3,0(r3) + LOAD_REG_IMMEDIATE(r4, KERNELBASE) + cmpd r3,r4 + bne 4f + /* Clear out the BSS. It may have been done in prom_init, * already but that's irrelevant since prom_init will soon * be detached from the kernel completely. Besides, we need