summaryrefslogtreecommitdiff
path: root/include/asm-x86/uaccess_64.h
diff options
context:
space:
mode:
authorNick Piggin <npiggin@suse.de>2008-09-10 13:37:17 +0200
committerIngo Molnar <mingo@elte.hu>2008-09-10 13:48:49 +0200
commitc10d38dda1774ed4540380333cabd229eff37094 (patch)
treebe9649dab7c0017c0a700f146db70f730ad819a7 /include/asm-x86/uaccess_64.h
parent76b189e91845eab3a9d52bb97f971d312d25652d (diff)
downloadlwn-c10d38dda1774ed4540380333cabd229eff37094.tar.gz
lwn-c10d38dda1774ed4540380333cabd229eff37094.zip
x86: some lock annotations for user copy paths
copy_to/from_user and all its variants (except the atomic ones) can take a page fault and perform non-trivial work like taking mmap_sem and entering the filesyste/pagecache. Unfortunately, this often escapes lockdep because a common pattern is to use it to read in some arguments just set up from userspace, or write data back to a hot buffer. In those cases, it will be unlikely for page reclaim to get a window in to cause copy_*_user to fault. With the new might_lock primitives, add some annotations to x86. I don't know if I caught all possible faulting points (it's a bit of a maze, and I didn't really look at 32-bit). But this is a starting point. Boots and runs OK so far. Signed-off-by: Nick Piggin <npiggin@suse.de> Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'include/asm-x86/uaccess_64.h')
-rw-r--r--include/asm-x86/uaccess_64.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/asm-x86/uaccess_64.h b/include/asm-x86/uaccess_64.h
index 515d4dce96b5..40a7205fe576 100644
--- a/include/asm-x86/uaccess_64.h
+++ b/include/asm-x86/uaccess_64.h
@@ -28,6 +28,10 @@ static __always_inline __must_check
int __copy_from_user(void *dst, const void __user *src, unsigned size)
{
int ret = 0;
+
+ might_sleep();
+ if (current->mm)
+ might_lock_read(&current->mm->mmap_sem);
if (!__builtin_constant_p(size))
return copy_user_generic(dst, (__force void *)src, size);
switch (size) {
@@ -70,6 +74,10 @@ static __always_inline __must_check
int __copy_to_user(void __user *dst, const void *src, unsigned size)
{
int ret = 0;
+
+ might_sleep();
+ if (current->mm)
+ might_lock_read(&current->mm->mmap_sem);
if (!__builtin_constant_p(size))
return copy_user_generic((__force void *)dst, src, size);
switch (size) {
@@ -112,6 +120,10 @@ static __always_inline __must_check
int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
{
int ret = 0;
+
+ might_sleep();
+ if (current->mm)
+ might_lock_read(&current->mm->mmap_sem);
if (!__builtin_constant_p(size))
return copy_user_generic((__force void *)dst,
(__force void *)src, size);