Commit e1de9438 authored by Linus Walleij's avatar Linus Walleij Committed by Russell King
Browse files

ARM: 8978/1: mm: make act_mm() respect THREAD_SIZE



Recent work with KASan exposed the folling hard-coded bitmask
in arch/arm/mm/proc-macros.S:

  bic     rd, sp, #8128
  bic     rd, rd, #63

This forms the bitmask 0x1FFF that is coinciding with
(PAGE_SIZE << THREAD_SIZE_ORDER) - 1, this code was assuming
that THREAD_SIZE is always 8K (8192).

As KASan was increasing THREAD_SIZE_ORDER to 2, I ran into
this bug.

Fix it by this little oneline suggested by Ard:

  bic     rd, sp, #(THREAD_SIZE - 1) & ~63

Where THREAD_SIZE is defined using THREAD_SIZE_ORDER.

We have to also include <linux/const.h> since the THREAD_SIZE
expands to use the _AC() macro.

Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Suggested-by: default avatarArd Biesheuvel <ardb@kernel.org>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
parent fce2bc25
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
 *  VMA_VM_FLAGS
 *  VM_EXEC
 */
#include <linux/const.h>
#include <asm/asm-offsets.h>
#include <asm/thread_info.h>

@@ -30,7 +31,7 @@
 * act_mm - get current->active_mm
 */
	.macro	act_mm, rd
	bic	\rd, sp, #8128
	bic	\rd, sp, #(THREAD_SIZE - 1) & ~63
	bic	\rd, \rd, #63
	ldr	\rd, [\rd, #TI_TASK]
	.if (TSK_ACTIVE_MM > IMM12_MASK)