aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorStephen Boyd <sboyd@codeaurora.org>2013-04-30 18:28:42 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-30 20:04:09 -0400
commit446f24d1199e8a546ba7c97da3fbb9a505a94795 (patch)
tree42c44a565fbdd6f923e0c2403b1c62154acab1b2 /arch
parenta05342cbd62b7f6dacb8d71683d799f5e5e694b8 (diff)
Kconfig: consolidate CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
The help text for this config is duplicated across the x86, parisc, and s390 Kconfig.debug files. Arnd Bergman noted that the help text was slightly misleading and should be fixed to state that enabling this option isn't a problem when using pre 4.4 gcc. To simplify the rewording, consolidate the text into lib/Kconfig.debug and modify it there to be more explicit about when you should say N to this config. Also, make the text a bit more generic by stating that this option enables compile time checks so we can cover architectures which emit warnings vs. ones which emit errors. The details of how an architecture decided to implement the checks isn't as important as the concept of compile time checking of copy_from_user() calls. While we're doing this, remove all the copy_from_user_overflow() code that's duplicated many times and place it into lib/ so that any architecture supporting this option can get the function for free. Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> Acked-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Ingo Molnar <mingo@kernel.org> Acked-by: H. Peter Anvin <hpa@zytor.com> Cc: Arjan van de Ven <arjan@linux.intel.com> Acked-by: Helge Deller <deller@gmx.de> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Stephen Rothwell <sfr@canb.auug.org.au> Cc: Chris Metcalf <cmetcalf@tilera.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/parisc/Kconfig1
-rw-r--r--arch/parisc/Kconfig.debug14
-rw-r--r--arch/s390/Kconfig1
-rw-r--r--arch/s390/Kconfig.debug14
-rw-r--r--arch/s390/lib/Makefile1
-rw-r--r--arch/s390/lib/usercopy.c8
-rw-r--r--arch/sparc/lib/Makefile1
-rw-r--r--arch/sparc/lib/usercopy.c9
-rw-r--r--arch/tile/Kconfig8
-rw-r--r--arch/tile/include/asm/uaccess.h7
-rw-r--r--arch/tile/lib/uaccess.c8
-rw-r--r--arch/x86/Kconfig1
-rw-r--r--arch/x86/Kconfig.debug14
-rw-r--r--arch/x86/lib/usercopy_32.c6
14 files changed, 10 insertions, 83 deletions
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index 0339181bf3ac..433e75a2ee9a 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -1,5 +1,6 @@
1config PARISC 1config PARISC
2 def_bool y 2 def_bool y
3 select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
3 select HAVE_IDE 4 select HAVE_IDE
4 select HAVE_OPROFILE 5 select HAVE_OPROFILE
5 select HAVE_FUNCTION_TRACER if 64BIT 6 select HAVE_FUNCTION_TRACER if 64BIT
diff --git a/arch/parisc/Kconfig.debug b/arch/parisc/Kconfig.debug
index 7305ac8f7f5b..bc989e522a04 100644
--- a/arch/parisc/Kconfig.debug
+++ b/arch/parisc/Kconfig.debug
@@ -12,18 +12,4 @@ config DEBUG_RODATA
12 portion of the kernel code won't be covered by a TLB anymore. 12 portion of the kernel code won't be covered by a TLB anymore.
13 If in doubt, say "N". 13 If in doubt, say "N".
14 14
15config DEBUG_STRICT_USER_COPY_CHECKS
16 bool "Strict copy size checks"
17 depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
18 ---help---
19 Enabling this option turns a certain set of sanity checks for user
20 copy operations into compile time failures.
21
22 The copy_from_user() etc checks are there to help test if there
23 are sufficient security checks on the length argument of
24 the copy operation, by having gcc prove that the argument is
25 within bounds.
26
27 If unsure, or if you run an older (pre 4.4) gcc, say N.
28
29endmenu 15endmenu
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index bda6ba6f3cf5..ce640aff61a1 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -91,6 +91,7 @@ config S390
91 select ARCH_INLINE_WRITE_UNLOCK_BH 91 select ARCH_INLINE_WRITE_UNLOCK_BH
92 select ARCH_INLINE_WRITE_UNLOCK_IRQ 92 select ARCH_INLINE_WRITE_UNLOCK_IRQ
93 select ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE 93 select ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE
94 select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
94 select ARCH_SAVE_PAGE_KEYS if HIBERNATION 95 select ARCH_SAVE_PAGE_KEYS if HIBERNATION
95 select ARCH_WANT_IPC_PARSE_VERSION 96 select ARCH_WANT_IPC_PARSE_VERSION
96 select BUILDTIME_EXTABLE_SORT 97 select BUILDTIME_EXTABLE_SORT
diff --git a/arch/s390/Kconfig.debug b/arch/s390/Kconfig.debug
index fc32a2df4974..c56878e1245f 100644
--- a/arch/s390/Kconfig.debug
+++ b/arch/s390/Kconfig.debug
@@ -17,20 +17,6 @@ config STRICT_DEVMEM
17 17
18 If you are unsure, say Y. 18 If you are unsure, say Y.
19 19
20config DEBUG_STRICT_USER_COPY_CHECKS
21 def_bool n
22 prompt "Strict user copy size checks"
23 ---help---
24 Enabling this option turns a certain set of sanity checks for user
25 copy operations into compile time warnings.
26
27 The copy_from_user() etc checks are there to help test if there
28 are sufficient security checks on the length argument of
29 the copy operation, by having gcc prove that the argument is
30 within bounds.
31
32 If unsure, or if you run an older (pre 4.4) gcc, say N.
33
34config S390_PTDUMP 20config S390_PTDUMP
35 bool "Export kernel pagetable layout to userspace via debugfs" 21 bool "Export kernel pagetable layout to userspace via debugfs"
36 depends on DEBUG_KERNEL 22 depends on DEBUG_KERNEL
diff --git a/arch/s390/lib/Makefile b/arch/s390/lib/Makefile
index 6ab0d0b5cec8..20b0e97a7df2 100644
--- a/arch/s390/lib/Makefile
+++ b/arch/s390/lib/Makefile
@@ -3,7 +3,6 @@
3# 3#
4 4
5lib-y += delay.o string.o uaccess_std.o uaccess_pt.o 5lib-y += delay.o string.o uaccess_std.o uaccess_pt.o
6obj-y += usercopy.o
7obj-$(CONFIG_32BIT) += div64.o qrnnd.o ucmpdi2.o mem32.o 6obj-$(CONFIG_32BIT) += div64.o qrnnd.o ucmpdi2.o mem32.o
8obj-$(CONFIG_64BIT) += mem64.o 7obj-$(CONFIG_64BIT) += mem64.o
9lib-$(CONFIG_64BIT) += uaccess_mvcos.o 8lib-$(CONFIG_64BIT) += uaccess_mvcos.o
diff --git a/arch/s390/lib/usercopy.c b/arch/s390/lib/usercopy.c
deleted file mode 100644
index 14b363fec8a2..000000000000
--- a/arch/s390/lib/usercopy.c
+++ /dev/null
@@ -1,8 +0,0 @@
1#include <linux/module.h>
2#include <linux/bug.h>
3
4void copy_from_user_overflow(void)
5{
6 WARN(1, "Buffer overflow detected!\n");
7}
8EXPORT_SYMBOL(copy_from_user_overflow);
diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
index 8410065f2862..dbe119b63b48 100644
--- a/arch/sparc/lib/Makefile
+++ b/arch/sparc/lib/Makefile
@@ -45,4 +45,3 @@ obj-y += iomap.o
45obj-$(CONFIG_SPARC32) += atomic32.o ucmpdi2.o 45obj-$(CONFIG_SPARC32) += atomic32.o ucmpdi2.o
46obj-y += ksyms.o 46obj-y += ksyms.o
47obj-$(CONFIG_SPARC64) += PeeCeeI.o 47obj-$(CONFIG_SPARC64) += PeeCeeI.o
48obj-y += usercopy.o
diff --git a/arch/sparc/lib/usercopy.c b/arch/sparc/lib/usercopy.c
deleted file mode 100644
index 5c4284ce1c03..000000000000
--- a/arch/sparc/lib/usercopy.c
+++ /dev/null
@@ -1,9 +0,0 @@
1#include <linux/module.h>
2#include <linux/kernel.h>
3#include <linux/bug.h>
4
5void copy_from_user_overflow(void)
6{
7 WARN(1, "Buffer overflow detected!\n");
8}
9EXPORT_SYMBOL(copy_from_user_overflow);
diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
index 25877aebc685..0f712f4e1b33 100644
--- a/arch/tile/Kconfig
+++ b/arch/tile/Kconfig
@@ -19,6 +19,7 @@ config TILE
19 select HAVE_SYSCALL_WRAPPERS if TILEGX 19 select HAVE_SYSCALL_WRAPPERS if TILEGX
20 select VIRT_TO_BUS 20 select VIRT_TO_BUS
21 select SYS_HYPERVISOR 21 select SYS_HYPERVISOR
22 select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
22 select ARCH_HAVE_NMI_SAFE_CMPXCHG 23 select ARCH_HAVE_NMI_SAFE_CMPXCHG
23 select GENERIC_CLOCKEVENTS 24 select GENERIC_CLOCKEVENTS
24 select MODULES_USE_ELF_RELA 25 select MODULES_USE_ELF_RELA
@@ -114,13 +115,6 @@ config STRICT_DEVMEM
114config SMP 115config SMP
115 def_bool y 116 def_bool y
116 117
117# Allow checking for compile-time determined overflow errors in
118# copy_from_user(). There are still unprovable places in the
119# generic code as of 2.6.34, so this option is not really compatible
120# with -Werror, which is more useful in general.
121config DEBUG_COPY_FROM_USER
122 def_bool n
123
124config HVC_TILE 118config HVC_TILE
125 depends on TTY 119 depends on TTY
126 select HVC_DRIVER 120 select HVC_DRIVER
diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
index 9ab078a4605d..8a082bc6bca5 100644
--- a/arch/tile/include/asm/uaccess.h
+++ b/arch/tile/include/asm/uaccess.h
@@ -395,7 +395,12 @@ _copy_from_user(void *to, const void __user *from, unsigned long n)
395 return n; 395 return n;
396} 396}
397 397
398#ifdef CONFIG_DEBUG_COPY_FROM_USER 398#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
399/*
400 * There are still unprovable places in the generic code as of 2.6.34, so this
401 * option is not really compatible with -Werror, which is more useful in
402 * general.
403 */
399extern void copy_from_user_overflow(void) 404extern void copy_from_user_overflow(void)
400 __compiletime_warning("copy_from_user() size is not provably correct"); 405 __compiletime_warning("copy_from_user() size is not provably correct");
401 406
diff --git a/arch/tile/lib/uaccess.c b/arch/tile/lib/uaccess.c
index f8d398c9ee7f..030abe3ee4f1 100644
--- a/arch/tile/lib/uaccess.c
+++ b/arch/tile/lib/uaccess.c
@@ -22,11 +22,3 @@ int __range_ok(unsigned long addr, unsigned long size)
22 is_arch_mappable_range(addr, size)); 22 is_arch_mappable_range(addr, size));
23} 23}
24EXPORT_SYMBOL(__range_ok); 24EXPORT_SYMBOL(__range_ok);
25
26#ifdef CONFIG_DEBUG_COPY_FROM_USER
27void copy_from_user_overflow(void)
28{
29 WARN(1, "Buffer overflow detected!\n");
30}
31EXPORT_SYMBOL(copy_from_user_overflow);
32#endif
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 05b057dca4a7..5db2117ae288 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -20,6 +20,7 @@ config X86_64
20### Arch settings 20### Arch settings
21config X86 21config X86
22 def_bool y 22 def_bool y
23 select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
23 select HAVE_AOUT if X86_32 24 select HAVE_AOUT if X86_32
24 select HAVE_UNSTABLE_SCHED_CLOCK 25 select HAVE_UNSTABLE_SCHED_CLOCK
25 select ARCH_SUPPORTS_NUMA_BALANCING 26 select ARCH_SUPPORTS_NUMA_BALANCING
diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
index 16f738385dcb..c198b7e13e7b 100644
--- a/arch/x86/Kconfig.debug
+++ b/arch/x86/Kconfig.debug
@@ -292,20 +292,6 @@ config OPTIMIZE_INLINING
292 292
293 If unsure, say N. 293 If unsure, say N.
294 294
295config DEBUG_STRICT_USER_COPY_CHECKS
296 bool "Strict copy size checks"
297 depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
298 ---help---
299 Enabling this option turns a certain set of sanity checks for user
300 copy operations into compile time failures.
301
302 The copy_from_user() etc checks are there to help test if there
303 are sufficient security checks on the length argument of
304 the copy operation, by having gcc prove that the argument is
305 within bounds.
306
307 If unsure, or if you run an older (pre 4.4) gcc, say N.
308
309config DEBUG_NMI_SELFTEST 295config DEBUG_NMI_SELFTEST
310 bool "NMI Selftest" 296 bool "NMI Selftest"
311 depends on DEBUG_KERNEL && X86_LOCAL_APIC 297 depends on DEBUG_KERNEL && X86_LOCAL_APIC
diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
index f0312d746402..3eb18acd0e40 100644
--- a/arch/x86/lib/usercopy_32.c
+++ b/arch/x86/lib/usercopy_32.c
@@ -689,9 +689,3 @@ _copy_from_user(void *to, const void __user *from, unsigned long n)
689 return n; 689 return n;
690} 690}
691EXPORT_SYMBOL(_copy_from_user); 691EXPORT_SYMBOL(_copy_from_user);
692
693void copy_from_user_overflow(void)
694{
695 WARN(1, "Buffer overflow detected!\n");
696}
697EXPORT_SYMBOL(copy_from_user_overflow);