diff mbox series

[2/8] ARM: spectre-v1.1: force address sanitizing for __put_user*()

Message ID 1533828403-21323-3-git-send-email-julien.thierry@arm.com (mailing list archive)
State New, archived
Headers show
Series ARM: spectre-v1.1 mitigations | expand

Commit Message

Julien Thierry Aug. 9, 2018, 3:26 p.m. UTC
When Spectre mitigation is required, define __put_user() and
__put_user_error() to include check_uaccess, ensuring user address
is sanitized.

Signed-off-by: Julien Thierry <julien.thierry@arm.com>
Cc: Russell King <linux@armlinux.org.uk>
---
 arch/arm/include/asm/uaccess.h | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

--
1.9.1
diff mbox series

Patch

diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
index d65ef85..2e18b91 100644
--- a/arch/arm/include/asm/uaccess.h
+++ b/arch/arm/include/asm/uaccess.h
@@ -370,6 +370,20 @@  static inline void set_fs(mm_segment_t fs)
 	__pu_err;							\
 })

+#ifdef CONFIG_CPU_SPECTRE
+/*
+ * When mitigating Spectre variant 1.1, all accessors need to include
+ * verification of the address space.
+ */
+#define __put_user(x, ptr) put_user(x, ptr)
+
+#define __put_user_error(x, ptr, err)					\
+({									\
+	__put_user_switch((x), (ptr), (err), __put_user_check);		\
+	(void) 0;							\
+})
+
+#else
 #define __put_user(x, ptr)						\
 ({									\
 	long __pu_err = 0;						\
@@ -462,6 +476,7 @@  static inline void set_fs(mm_segment_t fs)
 	: "r" (x), "i" (-EFAULT)				\
 	: "cc")

+#endif /* !CONFIG_CPU_SPECTRE */

 #ifdef CONFIG_MMU
 extern unsigned long __must_check