lkml.org 
[lkml]   [2020]   [Jun]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 4.4 052/101] ARM: 8978/1: mm: make act_mm() respect THREAD_SIZE
    Date
    From: Linus Walleij <linus.walleij@linaro.org>

    [ Upstream commit e1de94380af588bdf6ad6f0cc1f75004c35bc096 ]

    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>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    arch/arm/mm/proc-macros.S | 3 ++-
    1 file changed, 2 insertions(+), 1 deletion(-)

    diff --git a/arch/arm/mm/proc-macros.S b/arch/arm/mm/proc-macros.S
    index e6bfdcc381f8..1da55d34f4d6 100644
    --- a/arch/arm/mm/proc-macros.S
    +++ b/arch/arm/mm/proc-macros.S
    @@ -4,6 +4,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]
    ldr \rd, [\rd, #TSK_ACTIVE_MM]
    --
    2.25.1


    \
     
     \ /
      Last update: 2020-06-19 16:38    [W:4.244 / U:0.064 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site