Commit f69229f5 authored by Linus Torvalds's avatar Linus Torvalds

Add extra debugging help for bad user accesses.

parent b060c521
...@@ -514,6 +514,7 @@ do { \ ...@@ -514,6 +514,7 @@ do { \
unsigned long __copy_to_user_ll(void __user *to, const void *from, unsigned long n) unsigned long __copy_to_user_ll(void __user *to, const void *from, unsigned long n)
{ {
BUG_ON((long) n < 0);
#ifndef CONFIG_X86_WP_WORKS_OK #ifndef CONFIG_X86_WP_WORKS_OK
if (unlikely(boot_cpu_data.wp_works_ok == 0) && if (unlikely(boot_cpu_data.wp_works_ok == 0) &&
((unsigned long )to) < TASK_SIZE) { ((unsigned long )to) < TASK_SIZE) {
...@@ -573,6 +574,7 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from, unsigned long ...@@ -573,6 +574,7 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from, unsigned long
unsigned long unsigned long
__copy_from_user_ll(void *to, const void __user *from, unsigned long n) __copy_from_user_ll(void *to, const void __user *from, unsigned long n)
{ {
BUG_ON((long)n < 0);
if (movsl_is_ok(to, from, n)) if (movsl_is_ok(to, from, n))
__copy_user_zeroing(to, from, n); __copy_user_zeroing(to, from, n);
else else
...@@ -597,6 +599,7 @@ unsigned long ...@@ -597,6 +599,7 @@ unsigned long
copy_to_user(void __user *to, const void *from, unsigned long n) copy_to_user(void __user *to, const void *from, unsigned long n)
{ {
might_sleep(); might_sleep();
BUG_ON((long) n < 0);
if (access_ok(VERIFY_WRITE, to, n)) if (access_ok(VERIFY_WRITE, to, n))
n = __copy_to_user(to, from, n); n = __copy_to_user(to, from, n);
return n; return n;
...@@ -623,6 +626,7 @@ unsigned long ...@@ -623,6 +626,7 @@ unsigned long
copy_from_user(void *to, const void __user *from, unsigned long n) copy_from_user(void *to, const void __user *from, unsigned long n)
{ {
might_sleep(); might_sleep();
BUG_ON((long) n < 0);
if (access_ok(VERIFY_READ, from, n)) if (access_ok(VERIFY_READ, from, n))
n = __copy_from_user(to, from, n); n = __copy_from_user(to, from, n);
else else
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment