diff options
author | Nick Piggin <npiggin@suse.de> | 2008-09-10 07:37:17 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-09-11 03:44:21 -0400 |
commit | 3ee1afa308f2a38e5d1e2ad3752ad7abcf480da1 (patch) | |
tree | 914e0f3bbd32a387cf6095c6955369fa8da7ebf6 /arch/x86 | |
parent | c10d38dda1774ed4540380333cabd229eff37094 (diff) |
x86: some lock annotations for user copy paths, v2
- introduce might_fault()
- handle the atomic user copy paths correctly
[ mingo@elte.hu: move might_sleep() outside of in_atomic(). ]
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 'arch/x86')
-rw-r--r-- | arch/x86/lib/usercopy_32.c | 12 | ||||
-rw-r--r-- | arch/x86/lib/usercopy_64.c | 8 |
2 files changed, 5 insertions, 15 deletions
diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c index 8eedde2a9cac..7393152a252e 100644 --- a/arch/x86/lib/usercopy_32.c +++ b/arch/x86/lib/usercopy_32.c | |||
@@ -32,9 +32,7 @@ static inline int __movsl_is_ok(unsigned long a1, unsigned long a2, unsigned lon | |||
32 | #define __do_strncpy_from_user(dst, src, count, res) \ | 32 | #define __do_strncpy_from_user(dst, src, count, res) \ |
33 | do { \ | 33 | do { \ |
34 | int __d0, __d1, __d2; \ | 34 | int __d0, __d1, __d2; \ |
35 | might_sleep(); \ | 35 | might_fault(); \ |
36 | if (current->mm) \ | ||
37 | might_lock_read(¤t->mm->mmap_sem); \ | ||
38 | __asm__ __volatile__( \ | 36 | __asm__ __volatile__( \ |
39 | " testl %1,%1\n" \ | 37 | " testl %1,%1\n" \ |
40 | " jz 2f\n" \ | 38 | " jz 2f\n" \ |
@@ -121,9 +119,7 @@ EXPORT_SYMBOL(strncpy_from_user); | |||
121 | #define __do_clear_user(addr,size) \ | 119 | #define __do_clear_user(addr,size) \ |
122 | do { \ | 120 | do { \ |
123 | int __d0; \ | 121 | int __d0; \ |
124 | might_sleep(); \ | 122 | might_fault(); \ |
125 | if (current->mm) \ | ||
126 | might_lock_read(¤t->mm->mmap_sem); \ | ||
127 | __asm__ __volatile__( \ | 123 | __asm__ __volatile__( \ |
128 | "0: rep; stosl\n" \ | 124 | "0: rep; stosl\n" \ |
129 | " movl %2,%0\n" \ | 125 | " movl %2,%0\n" \ |
@@ -193,9 +189,7 @@ long strnlen_user(const char __user *s, long n) | |||
193 | unsigned long mask = -__addr_ok(s); | 189 | unsigned long mask = -__addr_ok(s); |
194 | unsigned long res, tmp; | 190 | unsigned long res, tmp; |
195 | 191 | ||
196 | might_sleep(); | 192 | might_fault(); |
197 | if (current->mm) | ||
198 | might_lock_read(¤t->mm->mmap_sem); | ||
199 | 193 | ||
200 | __asm__ __volatile__( | 194 | __asm__ __volatile__( |
201 | " testl %0, %0\n" | 195 | " testl %0, %0\n" |
diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c index 847d12945998..64d6c84e6353 100644 --- a/arch/x86/lib/usercopy_64.c +++ b/arch/x86/lib/usercopy_64.c | |||
@@ -15,9 +15,7 @@ | |||
15 | #define __do_strncpy_from_user(dst,src,count,res) \ | 15 | #define __do_strncpy_from_user(dst,src,count,res) \ |
16 | do { \ | 16 | do { \ |
17 | long __d0, __d1, __d2; \ | 17 | long __d0, __d1, __d2; \ |
18 | might_sleep(); \ | 18 | might_fault(); \ |
19 | if (current->mm) \ | ||
20 | might_lock_read(¤t->mm->mmap_sem); \ | ||
21 | __asm__ __volatile__( \ | 19 | __asm__ __volatile__( \ |
22 | " testq %1,%1\n" \ | 20 | " testq %1,%1\n" \ |
23 | " jz 2f\n" \ | 21 | " jz 2f\n" \ |
@@ -66,9 +64,7 @@ EXPORT_SYMBOL(strncpy_from_user); | |||
66 | unsigned long __clear_user(void __user *addr, unsigned long size) | 64 | unsigned long __clear_user(void __user *addr, unsigned long size) |
67 | { | 65 | { |
68 | long __d0; | 66 | long __d0; |
69 | might_sleep(); | 67 | might_fault(); |
70 | if (current->mm) | ||
71 | might_lock_read(¤t->mm->mmap_sem); | ||
72 | /* no memory constraint because it doesn't change any memory gcc knows | 68 | /* no memory constraint because it doesn't change any memory gcc knows |
73 | about */ | 69 | about */ |
74 | asm volatile( | 70 | asm volatile( |