Skip to content

Commit e1de943

Browse files
linuswRussell King
authored and
Russell King
committed
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 <[email protected]> Cc: Florian Fainelli <[email protected]> Suggested-by: Ard Biesheuvel <[email protected]> Signed-off-by: Linus Walleij <[email protected]> Signed-off-by: Russell King <[email protected]>
1 parent fce2bc2 commit e1de943

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/arm/mm/proc-macros.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* VMA_VM_FLAGS
66
* VM_EXEC
77
*/
8+
#include <linux/const.h>
89
#include <asm/asm-offsets.h>
910
#include <asm/thread_info.h>
1011

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

0 commit comments

Comments
 (0)