aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm64/include/asm/uaccess.h4
-rw-r--r--arch/frv/include/asm/uaccess.h4
-rw-r--r--arch/m32r/include/asm/uaccess.h12
-rw-r--r--arch/microblaze/include/asm/uaccess.h6
-rw-r--r--arch/mn10300/include/asm/uaccess.h4
-rw-r--r--arch/powerpc/include/asm/uaccess.h16
-rw-r--r--arch/tile/include/asm/uaccess.h2
-rw-r--r--arch/x86/include/asm/uaccess_64.h2
-rw-r--r--include/asm-generic/uaccess.h10
-rw-r--r--include/linux/kernel.h7
-rw-r--r--mm/memory.c10
11 files changed, 39 insertions, 38 deletions
diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h
index 008f8481da65..edb3d5c73a32 100644
--- a/arch/arm64/include/asm/uaccess.h
+++ b/arch/arm64/include/asm/uaccess.h
@@ -166,7 +166,7 @@ do { \
166 166
167#define get_user(x, ptr) \ 167#define get_user(x, ptr) \
168({ \ 168({ \
169 might_sleep(); \ 169 might_fault(); \
170 access_ok(VERIFY_READ, (ptr), sizeof(*(ptr))) ? \ 170 access_ok(VERIFY_READ, (ptr), sizeof(*(ptr))) ? \
171 __get_user((x), (ptr)) : \ 171 __get_user((x), (ptr)) : \
172 ((x) = 0, -EFAULT); \ 172 ((x) = 0, -EFAULT); \
@@ -227,7 +227,7 @@ do { \
227 227
228#define put_user(x, ptr) \ 228#define put_user(x, ptr) \
229({ \ 229({ \
230 might_sleep(); \ 230 might_fault(); \
231 access_ok(VERIFY_WRITE, (ptr), sizeof(*(ptr))) ? \ 231 access_ok(VERIFY_WRITE, (ptr), sizeof(*(ptr))) ? \
232 __put_user((x), (ptr)) : \ 232 __put_user((x), (ptr)) : \
233 -EFAULT; \ 233 -EFAULT; \
diff --git a/arch/frv/include/asm/uaccess.h b/arch/frv/include/asm/uaccess.h
index 0b67ec5b4414..3ac9a59d65d4 100644
--- a/arch/frv/include/asm/uaccess.h
+++ b/arch/frv/include/asm/uaccess.h
@@ -280,14 +280,14 @@ extern long __memcpy_user(void *dst, const void *src, unsigned long count);
280static inline unsigned long __must_check 280static inline unsigned long __must_check
281__copy_to_user(void __user *to, const void *from, unsigned long n) 281__copy_to_user(void __user *to, const void *from, unsigned long n)
282{ 282{
283 might_sleep(); 283 might_fault();
284 return __copy_to_user_inatomic(to, from, n); 284 return __copy_to_user_inatomic(to, from, n);
285} 285}
286 286
287static inline unsigned long 287static inline unsigned long
288__copy_from_user(void *to, const void __user *from, unsigned long n) 288__copy_from_user(void *to, const void __user *from, unsigned long n)
289{ 289{
290 might_sleep(); 290 might_fault();
291 return __copy_from_user_inatomic(to, from, n); 291 return __copy_from_user_inatomic(to, from, n);
292} 292}
293 293
diff --git a/arch/m32r/include/asm/uaccess.h b/arch/m32r/include/asm/uaccess.h
index 1c7047bea200..84fe7ba53035 100644
--- a/arch/m32r/include/asm/uaccess.h
+++ b/arch/m32r/include/asm/uaccess.h
@@ -216,7 +216,7 @@ extern int fixup_exception(struct pt_regs *regs);
216({ \ 216({ \
217 long __gu_err = 0; \ 217 long __gu_err = 0; \
218 unsigned long __gu_val; \ 218 unsigned long __gu_val; \
219 might_sleep(); \ 219 might_fault(); \
220 __get_user_size(__gu_val,(ptr),(size),__gu_err); \ 220 __get_user_size(__gu_val,(ptr),(size),__gu_err); \
221 (x) = (__typeof__(*(ptr)))__gu_val; \ 221 (x) = (__typeof__(*(ptr)))__gu_val; \
222 __gu_err; \ 222 __gu_err; \
@@ -227,7 +227,7 @@ extern int fixup_exception(struct pt_regs *regs);
227 long __gu_err = -EFAULT; \ 227 long __gu_err = -EFAULT; \
228 unsigned long __gu_val = 0; \ 228 unsigned long __gu_val = 0; \
229 const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ 229 const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
230 might_sleep(); \ 230 might_fault(); \
231 if (access_ok(VERIFY_READ,__gu_addr,size)) \ 231 if (access_ok(VERIFY_READ,__gu_addr,size)) \
232 __get_user_size(__gu_val,__gu_addr,(size),__gu_err); \ 232 __get_user_size(__gu_val,__gu_addr,(size),__gu_err); \
233 (x) = (__typeof__(*(ptr)))__gu_val; \ 233 (x) = (__typeof__(*(ptr)))__gu_val; \
@@ -295,7 +295,7 @@ do { \
295#define __put_user_nocheck(x,ptr,size) \ 295#define __put_user_nocheck(x,ptr,size) \
296({ \ 296({ \
297 long __pu_err; \ 297 long __pu_err; \
298 might_sleep(); \ 298 might_fault(); \
299 __put_user_size((x),(ptr),(size),__pu_err); \ 299 __put_user_size((x),(ptr),(size),__pu_err); \
300 __pu_err; \ 300 __pu_err; \
301}) 301})
@@ -305,7 +305,7 @@ do { \
305({ \ 305({ \
306 long __pu_err = -EFAULT; \ 306 long __pu_err = -EFAULT; \
307 __typeof__(*(ptr)) __user *__pu_addr = (ptr); \ 307 __typeof__(*(ptr)) __user *__pu_addr = (ptr); \
308 might_sleep(); \ 308 might_fault(); \
309 if (access_ok(VERIFY_WRITE,__pu_addr,size)) \ 309 if (access_ok(VERIFY_WRITE,__pu_addr,size)) \
310 __put_user_size((x),__pu_addr,(size),__pu_err); \ 310 __put_user_size((x),__pu_addr,(size),__pu_err); \
311 __pu_err; \ 311 __pu_err; \
@@ -597,7 +597,7 @@ unsigned long __generic_copy_from_user(void *, const void __user *, unsigned lon
597 */ 597 */
598#define copy_to_user(to,from,n) \ 598#define copy_to_user(to,from,n) \
599({ \ 599({ \
600 might_sleep(); \ 600 might_fault(); \
601 __generic_copy_to_user((to),(from),(n)); \ 601 __generic_copy_to_user((to),(from),(n)); \
602}) 602})
603 603
@@ -638,7 +638,7 @@ unsigned long __generic_copy_from_user(void *, const void __user *, unsigned lon
638 */ 638 */
639#define copy_from_user(to,from,n) \ 639#define copy_from_user(to,from,n) \
640({ \ 640({ \
641 might_sleep(); \ 641 might_fault(); \
642 __generic_copy_from_user((to),(from),(n)); \ 642 __generic_copy_from_user((to),(from),(n)); \
643}) 643})
644 644
diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h
index 04e49553bdf9..0aa005703a0b 100644
--- a/arch/microblaze/include/asm/uaccess.h
+++ b/arch/microblaze/include/asm/uaccess.h
@@ -145,7 +145,7 @@ static inline unsigned long __must_check __clear_user(void __user *to,
145static inline unsigned long __must_check clear_user(void __user *to, 145static inline unsigned long __must_check clear_user(void __user *to,
146 unsigned long n) 146 unsigned long n)
147{ 147{
148 might_sleep(); 148 might_fault();
149 if (unlikely(!access_ok(VERIFY_WRITE, to, n))) 149 if (unlikely(!access_ok(VERIFY_WRITE, to, n)))
150 return n; 150 return n;
151 151
@@ -371,7 +371,7 @@ extern long __user_bad(void);
371static inline long copy_from_user(void *to, 371static inline long copy_from_user(void *to,
372 const void __user *from, unsigned long n) 372 const void __user *from, unsigned long n)
373{ 373{
374 might_sleep(); 374 might_fault();
375 if (access_ok(VERIFY_READ, from, n)) 375 if (access_ok(VERIFY_READ, from, n))
376 return __copy_from_user(to, from, n); 376 return __copy_from_user(to, from, n);
377 return n; 377 return n;
@@ -385,7 +385,7 @@ static inline long copy_from_user(void *to,
385static inline long copy_to_user(void __user *to, 385static inline long copy_to_user(void __user *to,
386 const void *from, unsigned long n) 386 const void *from, unsigned long n)
387{ 387{
388 might_sleep(); 388 might_fault();
389 if (access_ok(VERIFY_WRITE, to, n)) 389 if (access_ok(VERIFY_WRITE, to, n))
390 return __copy_to_user(to, from, n); 390 return __copy_to_user(to, from, n);
391 return n; 391 return n;
diff --git a/arch/mn10300/include/asm/uaccess.h b/arch/mn10300/include/asm/uaccess.h
index d7966e0f7698..537278746a15 100644
--- a/arch/mn10300/include/asm/uaccess.h
+++ b/arch/mn10300/include/asm/uaccess.h
@@ -471,13 +471,13 @@ extern unsigned long __generic_copy_from_user(void *, const void __user *,
471 471
472#define __copy_to_user(to, from, n) \ 472#define __copy_to_user(to, from, n) \
473({ \ 473({ \
474 might_sleep(); \ 474 might_fault(); \
475 __copy_to_user_inatomic((to), (from), (n)); \ 475 __copy_to_user_inatomic((to), (from), (n)); \
476}) 476})
477 477
478#define __copy_from_user(to, from, n) \ 478#define __copy_from_user(to, from, n) \
479({ \ 479({ \
480 might_sleep(); \ 480 might_fault(); \
481 __copy_from_user_inatomic((to), (from), (n)); \ 481 __copy_from_user_inatomic((to), (from), (n)); \
482}) 482})
483 483
diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
index 4db49590acf5..9485b43a7c00 100644
--- a/arch/powerpc/include/asm/uaccess.h
+++ b/arch/powerpc/include/asm/uaccess.h
@@ -178,7 +178,7 @@ do { \
178 long __pu_err; \ 178 long __pu_err; \
179 __typeof__(*(ptr)) __user *__pu_addr = (ptr); \ 179 __typeof__(*(ptr)) __user *__pu_addr = (ptr); \
180 if (!is_kernel_addr((unsigned long)__pu_addr)) \ 180 if (!is_kernel_addr((unsigned long)__pu_addr)) \
181 might_sleep(); \ 181 might_fault(); \
182 __chk_user_ptr(ptr); \ 182 __chk_user_ptr(ptr); \
183 __put_user_size((x), __pu_addr, (size), __pu_err); \ 183 __put_user_size((x), __pu_addr, (size), __pu_err); \
184 __pu_err; \ 184 __pu_err; \
@@ -188,7 +188,7 @@ do { \
188({ \ 188({ \
189 long __pu_err = -EFAULT; \ 189 long __pu_err = -EFAULT; \
190 __typeof__(*(ptr)) __user *__pu_addr = (ptr); \ 190 __typeof__(*(ptr)) __user *__pu_addr = (ptr); \
191 might_sleep(); \ 191 might_fault(); \
192 if (access_ok(VERIFY_WRITE, __pu_addr, size)) \ 192 if (access_ok(VERIFY_WRITE, __pu_addr, size)) \
193 __put_user_size((x), __pu_addr, (size), __pu_err); \ 193 __put_user_size((x), __pu_addr, (size), __pu_err); \
194 __pu_err; \ 194 __pu_err; \
@@ -268,7 +268,7 @@ do { \
268 const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ 268 const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
269 __chk_user_ptr(ptr); \ 269 __chk_user_ptr(ptr); \
270 if (!is_kernel_addr((unsigned long)__gu_addr)) \ 270 if (!is_kernel_addr((unsigned long)__gu_addr)) \
271 might_sleep(); \ 271 might_fault(); \
272 __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \ 272 __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
273 (x) = (__typeof__(*(ptr)))__gu_val; \ 273 (x) = (__typeof__(*(ptr)))__gu_val; \
274 __gu_err; \ 274 __gu_err; \
@@ -282,7 +282,7 @@ do { \
282 const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ 282 const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
283 __chk_user_ptr(ptr); \ 283 __chk_user_ptr(ptr); \
284 if (!is_kernel_addr((unsigned long)__gu_addr)) \ 284 if (!is_kernel_addr((unsigned long)__gu_addr)) \
285 might_sleep(); \ 285 might_fault(); \
286 __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \ 286 __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
287 (x) = (__typeof__(*(ptr)))__gu_val; \ 287 (x) = (__typeof__(*(ptr)))__gu_val; \
288 __gu_err; \ 288 __gu_err; \
@@ -294,7 +294,7 @@ do { \
294 long __gu_err = -EFAULT; \ 294 long __gu_err = -EFAULT; \
295 unsigned long __gu_val = 0; \ 295 unsigned long __gu_val = 0; \
296 const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ 296 const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \
297 might_sleep(); \ 297 might_fault(); \
298 if (access_ok(VERIFY_READ, __gu_addr, (size))) \ 298 if (access_ok(VERIFY_READ, __gu_addr, (size))) \
299 __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \ 299 __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \
300 (x) = (__typeof__(*(ptr)))__gu_val; \ 300 (x) = (__typeof__(*(ptr)))__gu_val; \
@@ -419,14 +419,14 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
419static inline unsigned long __copy_from_user(void *to, 419static inline unsigned long __copy_from_user(void *to,
420 const void __user *from, unsigned long size) 420 const void __user *from, unsigned long size)
421{ 421{
422 might_sleep(); 422 might_fault();
423 return __copy_from_user_inatomic(to, from, size); 423 return __copy_from_user_inatomic(to, from, size);
424} 424}
425 425
426static inline unsigned long __copy_to_user(void __user *to, 426static inline unsigned long __copy_to_user(void __user *to,
427 const void *from, unsigned long size) 427 const void *from, unsigned long size)
428{ 428{
429 might_sleep(); 429 might_fault();
430 return __copy_to_user_inatomic(to, from, size); 430 return __copy_to_user_inatomic(to, from, size);
431} 431}
432 432
@@ -434,7 +434,7 @@ extern unsigned long __clear_user(void __user *addr, unsigned long size);
434 434
435static inline unsigned long clear_user(void __user *addr, unsigned long size) 435static inline unsigned long clear_user(void __user *addr, unsigned long size)
436{ 436{
437 might_sleep(); 437 might_fault();
438 if (likely(access_ok(VERIFY_WRITE, addr, size))) 438 if (likely(access_ok(VERIFY_WRITE, addr, size)))
439 return __clear_user(addr, size); 439 return __clear_user(addr, size);
440 if ((unsigned long)addr < TASK_SIZE) { 440 if ((unsigned long)addr < TASK_SIZE) {
diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
index 8a082bc6bca5..e4d44bd7df27 100644
--- a/arch/tile/include/asm/uaccess.h
+++ b/arch/tile/include/asm/uaccess.h
@@ -442,7 +442,7 @@ extern unsigned long __copy_in_user_inatomic(
442static inline unsigned long __must_check 442static inline unsigned long __must_check
443__copy_in_user(void __user *to, const void __user *from, unsigned long n) 443__copy_in_user(void __user *to, const void __user *from, unsigned long n)
444{ 444{
445 might_sleep(); 445 might_fault();
446 return __copy_in_user_inatomic(to, from, n); 446 return __copy_in_user_inatomic(to, from, n);
447} 447}
448 448
diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
index 142810c457dc..4f7923dd0007 100644
--- a/arch/x86/include/asm/uaccess_64.h
+++ b/arch/x86/include/asm/uaccess_64.h
@@ -235,7 +235,7 @@ extern long __copy_user_nocache(void *dst, const void __user *src,
235static inline int 235static inline int
236__copy_from_user_nocache(void *dst, const void __user *src, unsigned size) 236__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
237{ 237{
238 might_sleep(); 238 might_fault();
239 return __copy_user_nocache(dst, src, size, 1); 239 return __copy_user_nocache(dst, src, size, 1);
240} 240}
241 241
diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
index c184aa8ec8cd..dc1269c74a52 100644
--- a/include/asm-generic/uaccess.h
+++ b/include/asm-generic/uaccess.h
@@ -163,7 +163,7 @@ static inline __must_check long __copy_to_user(void __user *to,
163 163
164#define put_user(x, ptr) \ 164#define put_user(x, ptr) \
165({ \ 165({ \
166 might_sleep(); \ 166 might_fault(); \
167 access_ok(VERIFY_WRITE, ptr, sizeof(*ptr)) ? \ 167 access_ok(VERIFY_WRITE, ptr, sizeof(*ptr)) ? \
168 __put_user(x, ptr) : \ 168 __put_user(x, ptr) : \
169 -EFAULT; \ 169 -EFAULT; \
@@ -225,7 +225,7 @@ extern int __put_user_bad(void) __attribute__((noreturn));
225 225
226#define get_user(x, ptr) \ 226#define get_user(x, ptr) \
227({ \ 227({ \
228 might_sleep(); \ 228 might_fault(); \
229 access_ok(VERIFY_READ, ptr, sizeof(*ptr)) ? \ 229 access_ok(VERIFY_READ, ptr, sizeof(*ptr)) ? \
230 __get_user(x, ptr) : \ 230 __get_user(x, ptr) : \
231 -EFAULT; \ 231 -EFAULT; \
@@ -255,7 +255,7 @@ extern int __get_user_bad(void) __attribute__((noreturn));
255static inline long copy_from_user(void *to, 255static inline long copy_from_user(void *to,
256 const void __user * from, unsigned long n) 256 const void __user * from, unsigned long n)
257{ 257{
258 might_sleep(); 258 might_fault();
259 if (access_ok(VERIFY_READ, from, n)) 259 if (access_ok(VERIFY_READ, from, n))
260 return __copy_from_user(to, from, n); 260 return __copy_from_user(to, from, n);
261 else 261 else
@@ -265,7 +265,7 @@ static inline long copy_from_user(void *to,
265static inline long copy_to_user(void __user *to, 265static inline long copy_to_user(void __user *to,
266 const void *from, unsigned long n) 266 const void *from, unsigned long n)
267{ 267{
268 might_sleep(); 268 might_fault();
269 if (access_ok(VERIFY_WRITE, to, n)) 269 if (access_ok(VERIFY_WRITE, to, n))
270 return __copy_to_user(to, from, n); 270 return __copy_to_user(to, from, n);
271 else 271 else
@@ -336,7 +336,7 @@ __clear_user(void __user *to, unsigned long n)
336static inline __must_check unsigned long 336static inline __must_check unsigned long
337clear_user(void __user *to, unsigned long n) 337clear_user(void __user *to, unsigned long n)
338{ 338{
339 might_sleep(); 339 might_fault();
340 if (!access_ok(VERIFY_WRITE, to, n)) 340 if (!access_ok(VERIFY_WRITE, to, n))
341 return n; 341 return n;
342 342
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 3afb969441d1..7e6b97e77fb9 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -193,13 +193,10 @@ extern int _cond_resched(void);
193 (__x < 0) ? -__x : __x; \ 193 (__x < 0) ? -__x : __x; \
194 }) 194 })
195 195
196#ifdef CONFIG_PROVE_LOCKING 196#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_DEBUG_ATOMIC_SLEEP)
197void might_fault(void); 197void might_fault(void);
198#else 198#else
199static inline void might_fault(void) 199static inline void might_fault(void) { }
200{
201 might_sleep();
202}
203#endif 200#endif
204 201
205extern struct atomic_notifier_head panic_notifier_list; 202extern struct atomic_notifier_head panic_notifier_list;
diff --git a/mm/memory.c b/mm/memory.c
index 61a262b08e53..95d0cce63583 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -4201,7 +4201,7 @@ void print_vma_addr(char *prefix, unsigned long ip)
4201 up_read(&mm->mmap_sem); 4201 up_read(&mm->mmap_sem);
4202} 4202}
4203 4203
4204#ifdef CONFIG_PROVE_LOCKING 4204#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_DEBUG_ATOMIC_SLEEP)
4205void might_fault(void) 4205void might_fault(void)
4206{ 4206{
4207 /* 4207 /*
@@ -4213,13 +4213,17 @@ void might_fault(void)
4213 if (segment_eq(get_fs(), KERNEL_DS)) 4213 if (segment_eq(get_fs(), KERNEL_DS))
4214 return; 4214 return;
4215 4215
4216 might_sleep();
4217 /* 4216 /*
4218 * it would be nicer only to annotate paths which are not under 4217 * it would be nicer only to annotate paths which are not under
4219 * pagefault_disable, however that requires a larger audit and 4218 * pagefault_disable, however that requires a larger audit and
4220 * providing helpers like get_user_atomic. 4219 * providing helpers like get_user_atomic.
4221 */ 4220 */
4222 if (!in_atomic() && current->mm) 4221 if (in_atomic())
4222 return;
4223
4224 __might_sleep(__FILE__, __LINE__, 0);
4225
4226 if (current->mm)
4223 might_lock_read(&current->mm->mmap_sem); 4227 might_lock_read(&current->mm->mmap_sem);
4224} 4228}
4225EXPORT_SYMBOL(might_fault); 4229EXPORT_SYMBOL(might_fault);