]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Strict user copy checks are only really supported on x86_32 even though
authorStephen Boyd <sboyd@codeaurora.org>
Wed, 24 Aug 2011 23:47:26 +0000 (09:47 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 15 Sep 2011 06:21:30 +0000 (16:21 +1000)
the config option is selectable on x86_64.  Add the necessary support to
the 64 bit code to trigger copy_from_user() warnings at compile time.

Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Acked-by: Ingo Molnar <mingo@elte.hu>
Acked-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
arch/x86/include/asm/uaccess_64.h
arch/x86/lib/usercopy_64.c

index 1c66d30971adedaac940770d701e141ae464e1f4..6ca53e5077776dd43bb67508a6407d7e1e006e7e 100644 (file)
@@ -43,6 +43,14 @@ _copy_from_user(void *to, const void __user *from, unsigned len);
 __must_check unsigned long
 copy_in_user(void __user *to, const void __user *from, unsigned len);
 
+extern void copy_from_user_overflow(void)
+#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
+       __compiletime_error("copy_from_user() buffer size is not provably correct")
+#else
+       __compiletime_warning("copy_from_user() buffer size is not provably correct")
+#endif
+;
+
 static inline unsigned long __must_check copy_from_user(void *to,
                                          const void __user *from,
                                          unsigned long n)
@@ -52,10 +60,8 @@ static inline unsigned long __must_check copy_from_user(void *to,
        might_fault();
        if (likely(sz == -1 || sz >= n))
                n = _copy_from_user(to, from, n);
-#ifdef CONFIG_DEBUG_VM
        else
-               WARN(1, "Buffer overflow detected!\n");
-#endif
+               copy_from_user_overflow();
        return n;
 }
 
index b7c2849ffb66015ed114a5ab2015956aecd69d7b..d7a5d9ac5479750131957c7fc83e4d5d26dac6db 100644 (file)
@@ -181,3 +181,9 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
                        break;
        return len;
 }
+
+void copy_from_user_overflow(void)
+{
+       WARN(1, "Buffer overflow detected!\n");
+}
+EXPORT_SYMBOL(copy_from_user_overflow);