ARM: 8978/1: mm: make act_mm() respect THREAD_SIZE
authorLinus Walleij <linus.walleij@linaro.org>
Tue, 19 May 2020 11:59:12 +0000 (12:59 +0100)
committerRussell King <rmk+kernel@armlinux.org.uk>
Tue, 26 May 2020 11:02:39 +0000 (12:02 +0100)
commite1de94380af588bdf6ad6f0cc1f75004c35bc096
treecfee95f272b0fa026757140f1f9078b88c4564e8
parentfce2bc254adbfe0449ab6bfb51bffba9d3c42689
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: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
arch/arm/mm/proc-macros.S