summaryrefslogtreecommitdiff
path: root/include/asm-x86/uaccess_32.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-x86/uaccess_32.h')
-rw-r--r--include/asm-x86/uaccess_32.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/include/asm-x86/uaccess_32.h b/include/asm-x86/uaccess_32.h
index 6fdef39a0bcb..d725e2d703f7 100644
--- a/include/asm-x86/uaccess_32.h
+++ b/include/asm-x86/uaccess_32.h
@@ -82,8 +82,10 @@ __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
static __always_inline unsigned long __must_check
__copy_to_user(void __user *to, const void *from, unsigned long n)
{
- might_sleep();
- return __copy_to_user_inatomic(to, from, n);
+ might_sleep();
+ if (current->mm)
+ might_lock_read(&current->mm->mmap_sem);
+ return __copy_to_user_inatomic(to, from, n);
}
static __always_inline unsigned long
@@ -138,6 +140,8 @@ static __always_inline unsigned long
__copy_from_user(void *to, const void __user *from, unsigned long n)
{
might_sleep();
+ if (current->mm)
+ might_lock_read(&current->mm->mmap_sem);
if (__builtin_constant_p(n)) {
unsigned long ret;
@@ -160,6 +164,8 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
const void __user *from, unsigned long n)
{
might_sleep();
+ if (current->mm)
+ might_lock_read(&current->mm->mmap_sem);
if (__builtin_constant_p(n)) {
unsigned long ret;