Skip to content

Commit ffa47aa

Browse files
arndbkees
authored andcommitted
ARM: Prepare for randomized task_struct
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 <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]> [kees: Adjust commit log slightly] Signed-off-by: Kees Cook <[email protected]>
1 parent 1854c19 commit ffa47aa

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

arch/arm/include/asm/assembler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@
8787
#define CALGN(code...)
8888
#endif
8989

90+
#define IMM12_MASK 0xfff
91+
9092
/*
9193
* Enable and disable interrupts
9294
*/

arch/arm/kernel/entry-armv.S

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,10 @@ ENTRY(__switch_to)
797797
#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP)
798798
ldr r7, [r2, #TI_TASK]
799799
ldr r8, =__stack_chk_guard
800-
ldr r7, [r7, #TSK_STACK_CANARY]
800+
.if (TSK_STACK_CANARY > IMM12_MASK)
801+
add r7, r7, #TSK_STACK_CANARY & ~IMM12_MASK
802+
.endif
803+
ldr r7, [r7, #TSK_STACK_CANARY & IMM12_MASK]
801804
#endif
802805
#ifdef CONFIG_CPU_USE_DOMAINS
803806
mcr p15, 0, r6, c3, c0, 0 @ Set domain register

arch/arm/mm/proc-macros.S

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,17 @@
2525
ldr \rd, [\rn, #VMA_VM_FLAGS]
2626
.endm
2727

28-
.macro tsk_mm, rd, rn
29-
ldr \rd, [\rn, #TI_TASK]
30-
ldr \rd, [\rd, #TSK_ACTIVE_MM]
31-
.endm
32-
3328
/*
3429
* act_mm - get current->active_mm
3530
*/
3631
.macro act_mm, rd
3732
bic \rd, sp, #8128
3833
bic \rd, \rd, #63
3934
ldr \rd, [\rd, #TI_TASK]
40-
ldr \rd, [\rd, #TSK_ACTIVE_MM]
35+
.if (TSK_ACTIVE_MM > IMM12_MASK)
36+
add \rd, \rd, #TSK_ACTIVE_MM & ~IMM12_MASK
37+
.endif
38+
ldr \rd, [\rd, #TSK_ACTIVE_MM & IMM12_MASK]
4139
.endm
4240

4341
/*

0 commit comments

Comments
 (0)