aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/include/asm/assembler.h
diff options
context:
space:
mode:
authorJulien Thierry <[email protected]>2018-09-11 09:14:50 +0000
committerRussell King <[email protected]>2018-10-05 09:51:15 +0000
commitafaf6838f4bc896a711180b702b388b8cfa638fc (patch)
tree1971dfe3cd88aba8e98339d928f17a9dd87cf285 /arch/arm/include/asm/assembler.h
parentARM: 8795/1: spectre-v1.1: use put_user() for __put_user() (diff)
downloadkernel-afaf6838f4bc896a711180b702b388b8cfa638fc.tar.gz
kernel-afaf6838f4bc896a711180b702b388b8cfa638fc.zip
ARM: 8796/1: spectre-v1,v1.1: provide helpers for address sanitization
Introduce C and asm helpers to sanitize user address, taking the address range they target into account. Use asm helper for existing sanitization in __copy_from_user(). Signed-off-by: Julien Thierry <[email protected]> Signed-off-by: Russell King <[email protected]>
Diffstat (limited to 'arch/arm/include/asm/assembler.h')
-rw-r--r--arch/arm/include/asm/assembler.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h
index f0515f60cff5..39651c1ec157 100644
--- a/arch/arm/include/asm/assembler.h
+++ b/arch/arm/include/asm/assembler.h
@@ -467,6 +467,17 @@ THUMB( orr \reg , \reg , #PSR_T_BIT )
#endif
.endm
+ .macro uaccess_mask_range_ptr, addr:req, size:req, limit:req, tmp:req
+#ifdef CONFIG_CPU_SPECTRE
+ sub \tmp, \limit, #1
+ subs \tmp, \tmp, \addr @ tmp = limit - 1 - addr
+ addhs \tmp, \tmp, #1 @ if (tmp >= 0) {
+ subhss \tmp, \tmp, \size @ tmp = limit - (addr + size) }
+ movlo \addr, #0 @ if (tmp < 0) addr = NULL
+ csdb
+#endif
+ .endm
+
.macro uaccess_disable, tmp, isb=1
#ifdef CONFIG_CPU_SW_DOMAIN_PAN
/*