ARM: Prepare for randomized task_struct
authorArnd Bergmann <arnd@arndb.de>
Fri, 30 Jun 2017 16:03:59 +0000 (18:03 +0200)
committerKees Cook <keescook@chromium.org>
Fri, 30 Jun 2017 19:00:50 +0000 (12:00 -0700)
With the new task struct randomization, we can run into a build
failure for certain random seeds, which will place fields beyond
the allow immediate size in the assembly:

arch/arm/kernel/entry-armv.S: Assembler messages:
arch/arm/kernel/entry-armv.S:803: Error: bad immediate value for offset (4096)

Only two constants in asm-offset.h are affected, and I'm changing
both of them here to work correctly in all configurations.

One more macro has the problem, but is currently unused, so this
removes it instead of adding complexity.

Suggested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
[kees: Adjust commit log slightly]
Signed-off-by: Kees Cook <keescook@chromium.org>
arch/arm/include/asm/assembler.h
arch/arm/kernel/entry-armv.S
arch/arm/mm/proc-macros.S

index 68b06f9c65ded6c810421a79b345e16f77e3d527..ad301f107dd286cff4432b8cc0284ff5976eec54 100644 (file)
@@ -87,6 +87,8 @@
 #define CALGN(code...)
 #endif
 
+#define IMM12_MASK 0xfff
+
 /*
  * Enable and disable interrupts
  */
index 9f157e7c51e75cc468de327bd9c5403353885849..c731f0d2b2af1549dea68dcce2035ce398b81604 100644 (file)
@@ -797,7 +797,10 @@ ENTRY(__switch_to)
 #if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP)
        ldr     r7, [r2, #TI_TASK]
        ldr     r8, =__stack_chk_guard
-       ldr     r7, [r7, #TSK_STACK_CANARY]
+       .if (TSK_STACK_CANARY > IMM12_MASK)
+       add     r7, r7, #TSK_STACK_CANARY & ~IMM12_MASK
+       .endif
+       ldr     r7, [r7, #TSK_STACK_CANARY & IMM12_MASK]
 #endif
 #ifdef CONFIG_CPU_USE_DOMAINS
        mcr     p15, 0, r6, c3, c0, 0           @ Set domain register
index 0d40c285bd864c87a5e02d59d35d789183334700..f944836da8a222cd97c4e29070afa3aa370e0cbb 100644 (file)
        ldr     \rd, [\rn, #VMA_VM_FLAGS]
        .endm
 
-       .macro  tsk_mm, rd, rn
-       ldr     \rd, [\rn, #TI_TASK]
-       ldr     \rd, [\rd, #TSK_ACTIVE_MM]
-       .endm
-
 /*
  * act_mm - get current->active_mm
  */
        bic     \rd, sp, #8128
        bic     \rd, \rd, #63
        ldr     \rd, [\rd, #TI_TASK]
-       ldr     \rd, [\rd, #TSK_ACTIVE_MM]
+       .if (TSK_ACTIVE_MM > IMM12_MASK)
+       add     \rd, \rd, #TSK_ACTIVE_MM & ~IMM12_MASK
+       .endif
+       ldr     \rd, [\rd, #TSK_ACTIVE_MM & IMM12_MASK]
        .endm
 
 /*