diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2017-03-21 12:02:25 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2017-04-26 12:05:56 -0400 |
commit | 9a677341cd8de01a9eaf2c24a4b735939e507943 (patch) | |
tree | 2e0a07f71d8fbfd22084c3289b1f5b2ab2bd1aaf | |
parent | 8cd920f26785ce42ec6fb807d40de67fc2eb41ce (diff) |
m32r: switch to RAW_COPY_USER
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | arch/m32r/Kconfig | 1 | ||||
-rw-r--r-- | arch/m32r/include/asm/uaccess.h | 98 | ||||
-rw-r--r-- | arch/m32r/kernel/m32r_ksyms.c | 2 | ||||
-rw-r--r-- | arch/m32r/lib/usercopy.c | 22 |
4 files changed, 8 insertions, 115 deletions
diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig index 95474460b367..b3e82bdd6db0 100644 --- a/arch/m32r/Kconfig +++ b/arch/m32r/Kconfig | |||
@@ -19,6 +19,7 @@ config M32R | |||
19 | select HAVE_DEBUG_STACKOVERFLOW | 19 | select HAVE_DEBUG_STACKOVERFLOW |
20 | select CPU_NO_EFFICIENT_FFS | 20 | select CPU_NO_EFFICIENT_FFS |
21 | select DMA_NOOP_OPS | 21 | select DMA_NOOP_OPS |
22 | select ARCH_HAS_RAW_COPY_USER | ||
22 | 23 | ||
23 | config SBUS | 24 | config SBUS |
24 | bool | 25 | bool |
diff --git a/arch/m32r/include/asm/uaccess.h b/arch/m32r/include/asm/uaccess.h index d5c5e68fa2fb..07be349c00ad 100644 --- a/arch/m32r/include/asm/uaccess.h +++ b/arch/m32r/include/asm/uaccess.h | |||
@@ -13,6 +13,7 @@ | |||
13 | */ | 13 | */ |
14 | #include <asm/page.h> | 14 | #include <asm/page.h> |
15 | #include <asm/setup.h> | 15 | #include <asm/setup.h> |
16 | #include <linux/prefetch.h> | ||
16 | 17 | ||
17 | /* | 18 | /* |
18 | * The fs value determines whether argument validity checking should be | 19 | * The fs value determines whether argument validity checking should be |
@@ -463,107 +464,22 @@ do { \ | |||
463 | /* We let the __ versions of copy_from/to_user inline, because they're often | 464 | /* We let the __ versions of copy_from/to_user inline, because they're often |
464 | * used in fast paths and have only a small space overhead. | 465 | * used in fast paths and have only a small space overhead. |
465 | */ | 466 | */ |
466 | static inline unsigned long __generic_copy_from_user_nocheck(void *to, | 467 | static inline unsigned long |
467 | const void __user *from, unsigned long n) | 468 | raw_copy_from_user(void *to, const void __user *from, unsigned long n) |
468 | { | 469 | { |
470 | prefetchw(to); | ||
469 | __copy_user(to, from, n); | 471 | __copy_user(to, from, n); |
470 | return n; | 472 | return n; |
471 | } | 473 | } |
472 | 474 | ||
473 | static inline unsigned long __generic_copy_to_user_nocheck(void __user *to, | 475 | static inline unsigned long |
474 | const void *from, unsigned long n) | 476 | raw_copy_to_user(void __user *to, const void *from, unsigned long n) |
475 | { | 477 | { |
478 | prefetch(from); | ||
476 | __copy_user(to, from, n); | 479 | __copy_user(to, from, n); |
477 | return n; | 480 | return n; |
478 | } | 481 | } |
479 | 482 | ||
480 | unsigned long __generic_copy_to_user(void __user *, const void *, unsigned long); | ||
481 | unsigned long __generic_copy_from_user(void *, const void __user *, unsigned long); | ||
482 | |||
483 | /** | ||
484 | * __copy_to_user: - Copy a block of data into user space, with less checking. | ||
485 | * @to: Destination address, in user space. | ||
486 | * @from: Source address, in kernel space. | ||
487 | * @n: Number of bytes to copy. | ||
488 | * | ||
489 | * Context: User context only. This function may sleep if pagefaults are | ||
490 | * enabled. | ||
491 | * | ||
492 | * Copy data from kernel space to user space. Caller must check | ||
493 | * the specified block with access_ok() before calling this function. | ||
494 | * | ||
495 | * Returns number of bytes that could not be copied. | ||
496 | * On success, this will be zero. | ||
497 | */ | ||
498 | #define __copy_to_user(to, from, n) \ | ||
499 | __generic_copy_to_user_nocheck((to), (from), (n)) | ||
500 | |||
501 | #define __copy_to_user_inatomic __copy_to_user | ||
502 | #define __copy_from_user_inatomic __copy_from_user | ||
503 | |||
504 | /** | ||
505 | * copy_to_user: - Copy a block of data into user space. | ||
506 | * @to: Destination address, in user space. | ||
507 | * @from: Source address, in kernel space. | ||
508 | * @n: Number of bytes to copy. | ||
509 | * | ||
510 | * Context: User context only. This function may sleep if pagefaults are | ||
511 | * enabled. | ||
512 | * | ||
513 | * Copy data from kernel space to user space. | ||
514 | * | ||
515 | * Returns number of bytes that could not be copied. | ||
516 | * On success, this will be zero. | ||
517 | */ | ||
518 | #define copy_to_user(to, from, n) \ | ||
519 | ({ \ | ||
520 | might_fault(); \ | ||
521 | __generic_copy_to_user((to), (from), (n)); \ | ||
522 | }) | ||
523 | |||
524 | /** | ||
525 | * __copy_from_user: - Copy a block of data from user space, with less checking. * @to: Destination address, in kernel space. | ||
526 | * @from: Source address, in user space. | ||
527 | * @n: Number of bytes to copy. | ||
528 | * | ||
529 | * Context: User context only. This function may sleep if pagefaults are | ||
530 | * enabled. | ||
531 | * | ||
532 | * Copy data from user space to kernel space. Caller must check | ||
533 | * the specified block with access_ok() before calling this function. | ||
534 | * | ||
535 | * Returns number of bytes that could not be copied. | ||
536 | * On success, this will be zero. | ||
537 | * | ||
538 | * If some data could not be copied, this function will pad the copied | ||
539 | * data to the requested size using zero bytes. | ||
540 | */ | ||
541 | #define __copy_from_user(to, from, n) \ | ||
542 | __generic_copy_from_user_nocheck((to), (from), (n)) | ||
543 | |||
544 | /** | ||
545 | * copy_from_user: - Copy a block of data from user space. | ||
546 | * @to: Destination address, in kernel space. | ||
547 | * @from: Source address, in user space. | ||
548 | * @n: Number of bytes to copy. | ||
549 | * | ||
550 | * Context: User context only. This function may sleep if pagefaults are | ||
551 | * enabled. | ||
552 | * | ||
553 | * Copy data from user space to kernel space. | ||
554 | * | ||
555 | * Returns number of bytes that could not be copied. | ||
556 | * On success, this will be zero. | ||
557 | * | ||
558 | * If some data could not be copied, this function will pad the copied | ||
559 | * data to the requested size using zero bytes. | ||
560 | */ | ||
561 | #define copy_from_user(to, from, n) \ | ||
562 | ({ \ | ||
563 | might_fault(); \ | ||
564 | __generic_copy_from_user((to), (from), (n)); \ | ||
565 | }) | ||
566 | |||
567 | long __must_check strncpy_from_user(char *dst, const char __user *src, | 483 | long __must_check strncpy_from_user(char *dst, const char __user *src, |
568 | long count); | 484 | long count); |
569 | long __must_check __strncpy_from_user(char *dst, | 485 | long __must_check __strncpy_from_user(char *dst, |
diff --git a/arch/m32r/kernel/m32r_ksyms.c b/arch/m32r/kernel/m32r_ksyms.c index d763f0bd2106..a4d43b5cc102 100644 --- a/arch/m32r/kernel/m32r_ksyms.c +++ b/arch/m32r/kernel/m32r_ksyms.c | |||
@@ -26,8 +26,6 @@ EXPORT_SYMBOL(strncpy_from_user); | |||
26 | EXPORT_SYMBOL(__strncpy_from_user); | 26 | EXPORT_SYMBOL(__strncpy_from_user); |
27 | EXPORT_SYMBOL(clear_user); | 27 | EXPORT_SYMBOL(clear_user); |
28 | EXPORT_SYMBOL(__clear_user); | 28 | EXPORT_SYMBOL(__clear_user); |
29 | EXPORT_SYMBOL(__generic_copy_from_user); | ||
30 | EXPORT_SYMBOL(__generic_copy_to_user); | ||
31 | EXPORT_SYMBOL(strnlen_user); | 29 | EXPORT_SYMBOL(strnlen_user); |
32 | 30 | ||
33 | #ifdef CONFIG_SMP | 31 | #ifdef CONFIG_SMP |
diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c index 6aacf5ba0a58..b3ef2c899f96 100644 --- a/arch/m32r/lib/usercopy.c +++ b/arch/m32r/lib/usercopy.c | |||
@@ -11,28 +11,6 @@ | |||
11 | #include <linux/thread_info.h> | 11 | #include <linux/thread_info.h> |
12 | #include <linux/uaccess.h> | 12 | #include <linux/uaccess.h> |
13 | 13 | ||
14 | unsigned long | ||
15 | __generic_copy_to_user(void __user *to, const void *from, unsigned long n) | ||
16 | { | ||
17 | prefetch(from); | ||
18 | if (access_ok(VERIFY_WRITE, to, n)) | ||
19 | __copy_user(to,from,n); | ||
20 | return n; | ||
21 | } | ||
22 | |||
23 | unsigned long | ||
24 | __generic_copy_from_user(void *to, const void __user *from, unsigned long n) | ||
25 | { | ||
26 | unsigned long ret = n; | ||
27 | prefetchw(to); | ||
28 | if (access_ok(VERIFY_READ, from, n)) | ||
29 | ret = __copy_user(to,from,n); | ||
30 | if (unlikely(ret)) | ||
31 | memset(to + n - ret, 0, ret); | ||
32 | return ret; | ||
33 | } | ||
34 | |||
35 | |||
36 | /* | 14 | /* |
37 | * Copy a null terminated string from userspace. | 15 | * Copy a null terminated string from userspace. |
38 | */ | 16 | */ |