diff options
-rw-r--r-- | arch/parisc/Kconfig | 1 | ||||
-rw-r--r-- | arch/parisc/Kconfig.debug | 14 | ||||
-rw-r--r-- | arch/s390/Kconfig | 1 | ||||
-rw-r--r-- | arch/s390/Kconfig.debug | 14 | ||||
-rw-r--r-- | arch/s390/lib/Makefile | 1 | ||||
-rw-r--r-- | arch/sparc/lib/Makefile | 1 | ||||
-rw-r--r-- | arch/sparc/lib/usercopy.c | 9 | ||||
-rw-r--r-- | arch/tile/Kconfig | 8 | ||||
-rw-r--r-- | arch/tile/include/asm/uaccess.h | 7 | ||||
-rw-r--r-- | arch/tile/lib/uaccess.c | 8 | ||||
-rw-r--r-- | arch/x86/Kconfig | 1 | ||||
-rw-r--r-- | arch/x86/Kconfig.debug | 14 | ||||
-rw-r--r-- | arch/x86/lib/usercopy_32.c | 6 | ||||
-rw-r--r-- | lib/Kconfig.debug | 18 | ||||
-rw-r--r-- | lib/Makefile | 1 | ||||
-rw-r--r-- | lib/usercopy.c (renamed from arch/s390/lib/usercopy.c) | 3 |
16 files changed, 31 insertions, 76 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 @@ | |||
1 | config PARISC | 1 | config 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 | ||
15 | config 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 | |||
29 | endmenu | 15 | endmenu |
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 | ||
20 | config 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 | |||
34 | config S390_PTDUMP | 20 | config 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 | ||
5 | lib-y += delay.o string.o uaccess_std.o uaccess_pt.o | 5 | lib-y += delay.o string.o uaccess_std.o uaccess_pt.o |
6 | obj-y += usercopy.o | ||
7 | obj-$(CONFIG_32BIT) += div64.o qrnnd.o ucmpdi2.o mem32.o | 6 | obj-$(CONFIG_32BIT) += div64.o qrnnd.o ucmpdi2.o mem32.o |
8 | obj-$(CONFIG_64BIT) += mem64.o | 7 | obj-$(CONFIG_64BIT) += mem64.o |
9 | lib-$(CONFIG_64BIT) += uaccess_mvcos.o | 8 | lib-$(CONFIG_64BIT) += uaccess_mvcos.o |
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 | |||
45 | obj-$(CONFIG_SPARC32) += atomic32.o ucmpdi2.o | 45 | obj-$(CONFIG_SPARC32) += atomic32.o ucmpdi2.o |
46 | obj-y += ksyms.o | 46 | obj-y += ksyms.o |
47 | obj-$(CONFIG_SPARC64) += PeeCeeI.o | 47 | obj-$(CONFIG_SPARC64) += PeeCeeI.o |
48 | obj-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 | |||
5 | void copy_from_user_overflow(void) | ||
6 | { | ||
7 | WARN(1, "Buffer overflow detected!\n"); | ||
8 | } | ||
9 | EXPORT_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 | |||
114 | config SMP | 115 | config 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. | ||
121 | config DEBUG_COPY_FROM_USER | ||
122 | def_bool n | ||
123 | |||
124 | config HVC_TILE | 118 | config 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 | */ | ||
399 | extern void copy_from_user_overflow(void) | 404 | extern 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 | } |
24 | EXPORT_SYMBOL(__range_ok); | 24 | EXPORT_SYMBOL(__range_ok); |
25 | |||
26 | #ifdef CONFIG_DEBUG_COPY_FROM_USER | ||
27 | void copy_from_user_overflow(void) | ||
28 | { | ||
29 | WARN(1, "Buffer overflow detected!\n"); | ||
30 | } | ||
31 | EXPORT_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 |
21 | config X86 | 21 | config 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 | ||
295 | config 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 | |||
309 | config DEBUG_NMI_SELFTEST | 295 | config 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 | } |
691 | EXPORT_SYMBOL(_copy_from_user); | 691 | EXPORT_SYMBOL(_copy_from_user); |
692 | |||
693 | void copy_from_user_overflow(void) | ||
694 | { | ||
695 | WARN(1, "Buffer overflow detected!\n"); | ||
696 | } | ||
697 | EXPORT_SYMBOL(copy_from_user_overflow); | ||
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 77ebaa3dfa12..770a422a42e8 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
@@ -1292,6 +1292,24 @@ config LATENCYTOP | |||
1292 | Enable this option if you want to use the LatencyTOP tool | 1292 | Enable this option if you want to use the LatencyTOP tool |
1293 | to find out which userspace is blocking on what kernel operations. | 1293 | to find out which userspace is blocking on what kernel operations. |
1294 | 1294 | ||
1295 | config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS | ||
1296 | bool | ||
1297 | |||
1298 | config DEBUG_STRICT_USER_COPY_CHECKS | ||
1299 | bool "Strict user copy size checks" | ||
1300 | depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS | ||
1301 | depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING | ||
1302 | help | ||
1303 | Enabling this option turns a certain set of sanity checks for user | ||
1304 | copy operations into compile time failures. | ||
1305 | |||
1306 | The copy_from_user() etc checks are there to help test if there | ||
1307 | are sufficient security checks on the length argument of | ||
1308 | the copy operation, by having gcc prove that the argument is | ||
1309 | within bounds. | ||
1310 | |||
1311 | If unsure, say N. | ||
1312 | |||
1295 | source mm/Kconfig.debug | 1313 | source mm/Kconfig.debug |
1296 | source kernel/trace/Kconfig | 1314 | source kernel/trace/Kconfig |
1297 | 1315 | ||
diff --git a/lib/Makefile b/lib/Makefile index 23c9a0fe74fc..e9c52e1b853a 100644 --- a/lib/Makefile +++ b/lib/Makefile | |||
@@ -15,6 +15,7 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \ | |||
15 | is_single_threaded.o plist.o decompress.o kobject_uevent.o \ | 15 | is_single_threaded.o plist.o decompress.o kobject_uevent.o \ |
16 | earlycpio.o | 16 | earlycpio.o |
17 | 17 | ||
18 | obj-$(CONFIG_ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS) += usercopy.o | ||
18 | lib-$(CONFIG_MMU) += ioremap.o | 19 | lib-$(CONFIG_MMU) += ioremap.o |
19 | lib-$(CONFIG_SMP) += cpumask.o | 20 | lib-$(CONFIG_SMP) += cpumask.o |
20 | 21 | ||
diff --git a/arch/s390/lib/usercopy.c b/lib/usercopy.c index 14b363fec8a2..4f5b1ddbcd25 100644 --- a/arch/s390/lib/usercopy.c +++ b/lib/usercopy.c | |||
@@ -1,5 +1,6 @@ | |||
1 | #include <linux/module.h> | 1 | #include <linux/export.h> |
2 | #include <linux/bug.h> | 2 | #include <linux/bug.h> |
3 | #include <linux/uaccess.h> | ||
3 | 4 | ||
4 | void copy_from_user_overflow(void) | 5 | void copy_from_user_overflow(void) |
5 | { | 6 | { |