Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1442901

[PATCH v2 04/11] ARM: uaccess: Enable hardened usercopy

From Kees Cook <keescook@chromium.org>
Newsgroups linux.kernel
Subject [PATCH v2 04/11] ARM: uaccess: Enable hardened usercopy
Date 2016-07-14 00:00 +0200
Message-ID <rUAmj-nH-29@gated-at.bofh.it> (permalink)
References <rUAmd-nH-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Enables CONFIG_HARDENED_USERCOPY checks on arm.

Based on code from PaX and grsecurity.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 arch/arm/Kconfig               |  1 +
 arch/arm/include/asm/uaccess.h | 11 +++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 90542db1220d..f56b29b3f57e 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -35,6 +35,7 @@ config ARM
 	select HARDIRQS_SW_RESEND
 	select HAVE_ARCH_AUDITSYSCALL if (AEABI && !OABI_COMPAT)
 	select HAVE_ARCH_BITREVERSE if (CPU_32v7M || CPU_32v7) && !CPU_32v6
+	select HAVE_ARCH_HARDENED_USERCOPY
 	select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL && !CPU_ENDIAN_BE32 && MMU
 	select HAVE_ARCH_KGDB if !CPU_ENDIAN_BE32 && MMU
 	select HAVE_ARCH_MMAP_RND_BITS if MMU
diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
index 35c9db857ebe..7fb59199c6bb 100644
--- a/arch/arm/include/asm/uaccess.h
+++ b/arch/arm/include/asm/uaccess.h
@@ -496,7 +496,10 @@ arm_copy_from_user(void *to, const void __user *from, unsigned long n);
 static inline unsigned long __must_check
 __copy_from_user(void *to, const void __user *from, unsigned long n)
 {
-	unsigned int __ua_flags = uaccess_save_and_enable();
+	unsigned int __ua_flags;
+
+	check_object_size(to, n, false);
+	__ua_flags = uaccess_save_and_enable();
 	n = arm_copy_from_user(to, from, n);
 	uaccess_restore(__ua_flags);
 	return n;
@@ -511,11 +514,15 @@ static inline unsigned long __must_check
 __copy_to_user(void __user *to, const void *from, unsigned long n)
 {
 #ifndef CONFIG_UACCESS_WITH_MEMCPY
-	unsigned int __ua_flags = uaccess_save_and_enable();
+	unsigned int __ua_flags;
+
+	check_object_size(from, n, true);
+	__ua_flags = uaccess_save_and_enable();
 	n = arm_copy_to_user(to, from, n);
 	uaccess_restore(__ua_flags);
 	return n;
 #else
+	check_object_size(from, n, true);
 	return arm_copy_to_user(to, from, n);
 #endif
 }
-- 
2.7.4

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 0/11] mm: Hardened usercopy Kees Cook <keescook@chromium.org> - 2016-07-14 00:00 +0200
  [PATCH v2 04/11] ARM: uaccess: Enable hardened usercopy Kees Cook <keescook@chromium.org> - 2016-07-14 00:00 +0200
  [PATCH v2 01/11] mm: Implement stack frame object validation Kees Cook <keescook@chromium.org> - 2016-07-14 00:00 +0200
    Re: [PATCH v2 01/11] mm: Implement stack frame object validation Kees Cook <keescook@chromium.org> - 2016-07-14 00:10 +0200
      Re: [PATCH v2 01/11] mm: Implement stack frame object validation Josh Poimboeuf <jpoimboe@redhat.com> - 2016-07-14 07:50 +0200
        Re: [PATCH v2 01/11] mm: Implement stack frame object validation Kees Cook <keescook@chromium.org> - 2016-07-14 20:20 +0200
          Re: [PATCH v2 01/11] mm: Implement stack frame object validation Josh Poimboeuf <jpoimboe@redhat.com> - 2016-07-14 21:30 +0200
            Re: [PATCH v2 01/11] mm: Implement stack frame object validation Kees Cook <keescook@chromium.org> - 2016-07-14 23:40 +0200
    Re: [PATCH v2 01/11] mm: Implement stack frame object validation Andy Lutomirski <luto@amacapital.net> - 2016-07-14 00:10 +0200
  [PATCH v2 06/11] ia64/uaccess: Enable hardened usercopy Kees Cook <keescook@chromium.org> - 2016-07-14 00:00 +0200

csiph-web