]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Kconfig: consolidate CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
authorStephen Boyd <sboyd@codeaurora.org>
Sat, 23 Mar 2013 02:33:19 +0000 (13:33 +1100)
committerStephen Rothwell <sfr@canb.auug.org.au>
Tue, 26 Mar 2013 05:33:44 +0000 (16:33 +1100)
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>
16 files changed:
arch/parisc/Kconfig
arch/parisc/Kconfig.debug
arch/s390/Kconfig
arch/s390/Kconfig.debug
arch/s390/lib/Makefile
arch/sparc/lib/Makefile
arch/sparc/lib/usercopy.c [deleted file]
arch/tile/Kconfig
arch/tile/include/asm/uaccess.h
arch/tile/lib/uaccess.c
arch/x86/Kconfig
arch/x86/Kconfig.debug
arch/x86/lib/usercopy_32.c
lib/Kconfig.debug
lib/Makefile
lib/usercopy.c [moved from arch/s390/lib/usercopy.c with 73% similarity]

index 0339181bf3ac3d377db760ef93a7e74933288eee..433e75a2ee9afa2ff315bf39a97a429ebc64f6a4 100644 (file)
@@ -1,5 +1,6 @@
 config PARISC
        def_bool y
+       select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
        select HAVE_IDE
        select HAVE_OPROFILE
        select HAVE_FUNCTION_TRACER if 64BIT
index 7305ac8f7f5ba7438ac2207ada7aaeb60b419d36..bc989e522a045c17ca4514478b7cb5ef9d77fc4d 100644 (file)
@@ -12,18 +12,4 @@ config DEBUG_RODATA
          portion of the kernel code won't be covered by a TLB anymore.
          If in doubt, say "N".
 
-config DEBUG_STRICT_USER_COPY_CHECKS
-       bool "Strict copy size checks"
-       depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
-       ---help---
-         Enabling this option turns a certain set of sanity checks for user
-         copy operations into compile time failures.
-
-         The copy_from_user() etc checks are there to help test if there
-         are sufficient security checks on the length argument of
-         the copy operation, by having gcc prove that the argument is
-         within bounds.
-
-         If unsure, or if you run an older (pre 4.4) gcc, say N.
-
 endmenu
index 830ec55d246feffd88867af4e07ab78f0501cec0..6a94c397ad08075b2e8d5c16841cc74c0390bd21 100644 (file)
@@ -91,6 +91,7 @@ config S390
        select ARCH_INLINE_WRITE_UNLOCK_BH
        select ARCH_INLINE_WRITE_UNLOCK_IRQ
        select ARCH_INLINE_WRITE_UNLOCK_IRQRESTORE
+       select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
        select ARCH_SAVE_PAGE_KEYS if HIBERNATION
        select ARCH_WANT_IPC_PARSE_VERSION
        select BUILDTIME_EXTABLE_SORT
index fc32a2df497464cf7707f6843ba55a5d60f56341..c56878e1245fb4c4e75425f6e87ddd86457d5da1 100644 (file)
@@ -17,20 +17,6 @@ config STRICT_DEVMEM
 
          If you are unsure, say Y.
 
-config DEBUG_STRICT_USER_COPY_CHECKS
-       def_bool n
-       prompt "Strict user copy size checks"
-       ---help---
-         Enabling this option turns a certain set of sanity checks for user
-         copy operations into compile time warnings.
-
-         The copy_from_user() etc checks are there to help test if there
-         are sufficient security checks on the length argument of
-         the copy operation, by having gcc prove that the argument is
-         within bounds.
-
-         If unsure, or if you run an older (pre 4.4) gcc, say N.
-
 config S390_PTDUMP
        bool "Export kernel pagetable layout to userspace via debugfs"
        depends on DEBUG_KERNEL
index 6ab0d0b5cec82f83ab025ace480ed5b32771602c..20b0e97a7df2e204f9a680be4d95c86e0944652d 100644 (file)
@@ -3,7 +3,6 @@
 #
 
 lib-y += delay.o string.o uaccess_std.o uaccess_pt.o
-obj-y += usercopy.o
 obj-$(CONFIG_32BIT) += div64.o qrnnd.o ucmpdi2.o mem32.o
 obj-$(CONFIG_64BIT) += mem64.o
 lib-$(CONFIG_64BIT) += uaccess_mvcos.o
index 8410065f2862a4ad7a43d0ae1fc36a2e77e771e0..dbe119b63b48ba968a503ee3bd40d3dceaa8ac13 100644 (file)
@@ -45,4 +45,3 @@ obj-y                 += iomap.o
 obj-$(CONFIG_SPARC32) += atomic32.o ucmpdi2.o
 obj-y                 += ksyms.o
 obj-$(CONFIG_SPARC64) += PeeCeeI.o
-obj-y                 += usercopy.o
diff --git a/arch/sparc/lib/usercopy.c b/arch/sparc/lib/usercopy.c
deleted file mode 100644 (file)
index 5c4284c..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/bug.h>
-
-void copy_from_user_overflow(void)
-{
-       WARN(1, "Buffer overflow detected!\n");
-}
-EXPORT_SYMBOL(copy_from_user_overflow);
index 15f6b42b59509768cd2c9b59ba87a912e0198161..5b6a40dd5556765d4abf6fdc059fd54ad7c3ecb2 100644 (file)
@@ -18,6 +18,7 @@ config TILE
        select HAVE_DEBUG_BUGVERBOSE
        select VIRT_TO_BUS
        select SYS_HYPERVISOR
+       select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
        select ARCH_HAVE_NMI_SAFE_CMPXCHG
        select GENERIC_CLOCKEVENTS
        select MODULES_USE_ELF_RELA
@@ -107,13 +108,6 @@ config STRICT_DEVMEM
 config SMP
        def_bool y
 
-# Allow checking for compile-time determined overflow errors in
-# copy_from_user().  There are still unprovable places in the
-# generic code as of 2.6.34, so this option is not really compatible
-# with -Werror, which is more useful in general.
-config DEBUG_COPY_FROM_USER
-       def_bool n
-
 config HVC_TILE
        depends on TTY
        select HVC_DRIVER
index 9ab078a4605dd9750384b15b72b34c523b038fb5..8a082bc6bca57153efb53d69fc36068a9741f0ff 100644 (file)
@@ -395,7 +395,12 @@ _copy_from_user(void *to, const void __user *from, unsigned long n)
        return n;
 }
 
-#ifdef CONFIG_DEBUG_COPY_FROM_USER
+#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
+/*
+ * There are still unprovable places in the generic code as of 2.6.34, so this
+ * option is not really compatible with -Werror, which is more useful in
+ * general.
+ */
 extern void copy_from_user_overflow(void)
        __compiletime_warning("copy_from_user() size is not provably correct");
 
index f8d398c9ee7f3e174b70d94648db32d7500b2e80..030abe3ee4f1da38380cd592a7405fdefd346c36 100644 (file)
@@ -22,11 +22,3 @@ int __range_ok(unsigned long addr, unsigned long size)
                 is_arch_mappable_range(addr, size));
 }
 EXPORT_SYMBOL(__range_ok);
-
-#ifdef CONFIG_DEBUG_COPY_FROM_USER
-void copy_from_user_overflow(void)
-{
-       WARN(1, "Buffer overflow detected!\n");
-}
-EXPORT_SYMBOL(copy_from_user_overflow);
-#endif
index 24f12c9613397d670042fb1f91649a1f8e31303b..1028904bf368fe4c7369e223e8ad4c8ede225015 100644 (file)
@@ -20,6 +20,7 @@ config X86_64
 ### Arch settings
 config X86
        def_bool y
+       select ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
        select HAVE_AOUT if X86_32
        select HAVE_UNSTABLE_SCHED_CLOCK
        select ARCH_SUPPORTS_NUMA_BALANCING
index b322f124ee3ca689d389b37da81ad80d112b4bbf..dea0da520e138befec88714a781f3353f8df17ed 100644 (file)
@@ -292,20 +292,6 @@ config OPTIMIZE_INLINING
 
          If unsure, say N.
 
-config DEBUG_STRICT_USER_COPY_CHECKS
-       bool "Strict copy size checks"
-       depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
-       ---help---
-         Enabling this option turns a certain set of sanity checks for user
-         copy operations into compile time failures.
-
-         The copy_from_user() etc checks are there to help test if there
-         are sufficient security checks on the length argument of
-         the copy operation, by having gcc prove that the argument is
-         within bounds.
-
-         If unsure, or if you run an older (pre 4.4) gcc, say N.
-
 config DEBUG_NMI_SELFTEST
        bool "NMI Selftest"
        depends on DEBUG_KERNEL && X86_LOCAL_APIC
index f0312d7464027e73f52505c892409cf0d96c9945..3eb18acd0e409e41b9e0efc669b65296e57afd8e 100644 (file)
@@ -689,9 +689,3 @@ _copy_from_user(void *to, const void __user *from, unsigned long n)
        return n;
 }
 EXPORT_SYMBOL(_copy_from_user);
-
-void copy_from_user_overflow(void)
-{
-       WARN(1, "Buffer overflow detected!\n");
-}
-EXPORT_SYMBOL(copy_from_user_overflow);
index 28be08c09babda27bb77959538c9645962f84d75..ae805189e8d62e0a19921c7a8387c84f2bf149c2 100644 (file)
@@ -1292,6 +1292,24 @@ config LATENCYTOP
          Enable this option if you want to use the LatencyTOP tool
          to find out which userspace is blocking on what kernel operations.
 
+config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
+       bool
+
+config DEBUG_STRICT_USER_COPY_CHECKS
+       bool "Strict user copy size checks"
+       depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
+       depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
+       help
+         Enabling this option turns a certain set of sanity checks for user
+         copy operations into compile time failures.
+
+         The copy_from_user() etc checks are there to help test if there
+         are sufficient security checks on the length argument of
+         the copy operation, by having gcc prove that the argument is
+         within bounds.
+
+         If unsure, say N.
+
 source mm/Kconfig.debug
 source kernel/trace/Kconfig
 
index 32f445541423d1521e63085c508fd231d8a5588e..59fabd022e38ee00d1cae8a3318c679492285c50 100644 (file)
@@ -15,6 +15,7 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \
         is_single_threaded.o plist.o decompress.o kobject_uevent.o \
         earlycpio.o percpu-refcount.o
 
+lib-$(CONFIG_ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS) += usercopy.o
 lib-$(CONFIG_MMU) += ioremap.o
 lib-$(CONFIG_SMP) += cpumask.o
 
similarity index 73%
rename from arch/s390/lib/usercopy.c
rename to lib/usercopy.c
index 14b363fec8a2a108636411db2acb49f5e5b03946..4f5b1ddbcd2566b8c0e654c4c776a7b3843c3713 100644 (file)
@@ -1,5 +1,6 @@
-#include <linux/module.h>
+#include <linux/export.h>
 #include <linux/bug.h>
+#include <linux/uaccess.h>
 
 void copy_from_user_overflow(void)
 {