diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-05-01 17:41:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-05-01 17:41:04 -0400 |
commit | 5db6db0d400edd8bec274e34960cfa22838e1df5 (patch) | |
tree | 3d7934f2eb27a2b72b87eae3c2918cf2e635d814 /arch/nios2 | |
parent | 5fab10041b4389b61de7e7a49893190bae686241 (diff) | |
parent | 2fefc97b2180518bac923fba3f79fdca1f41dc15 (diff) |
Merge branch 'work.uaccess' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull uaccess unification updates from Al Viro:
"This is the uaccess unification pile. It's _not_ the end of uaccess
work, but the next batch of that will go into the next cycle. This one
mostly takes copy_from_user() and friends out of arch/* and gets the
zero-padding behaviour in sync for all architectures.
Dealing with the nocache/writethrough mess is for the next cycle;
fortunately, that's x86-only. Same for cleanups in iov_iter.c (I am
sold on access_ok() in there, BTW; just not in this pile), same for
reducing __copy_... callsites, strn*... stuff, etc. - there will be a
pile about as large as this one in the next merge window.
This one sat in -next for weeks. -3KLoC"
* 'work.uaccess' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (96 commits)
HAVE_ARCH_HARDENED_USERCOPY is unconditional now
CONFIG_ARCH_HAS_RAW_COPY_USER is unconditional now
m32r: switch to RAW_COPY_USER
hexagon: switch to RAW_COPY_USER
microblaze: switch to RAW_COPY_USER
get rid of padding, switch to RAW_COPY_USER
ia64: get rid of copy_in_user()
ia64: sanitize __access_ok()
ia64: get rid of 'segment' argument of __do_{get,put}_user()
ia64: get rid of 'segment' argument of __{get,put}_user_check()
ia64: add extable.h
powerpc: get rid of zeroing, switch to RAW_COPY_USER
esas2r: don't open-code memdup_user()
alpha: fix stack smashing in old_adjtimex(2)
don't open-code kernel_setsockopt()
mips: switch to RAW_COPY_USER
mips: get rid of tail-zeroing in primitives
mips: make copy_from_user() zero tail explicitly
mips: clean and reorder the forest of macros...
mips: consolidate __invoke_... wrappers
...
Diffstat (limited to 'arch/nios2')
-rw-r--r-- | arch/nios2/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/nios2/include/asm/uaccess.h | 55 | ||||
-rw-r--r-- | arch/nios2/mm/uaccess.c | 16 |
3 files changed, 16 insertions, 56 deletions
diff --git a/arch/nios2/include/asm/Kbuild b/arch/nios2/include/asm/Kbuild index aaa3c218b56c..87e70f2b463f 100644 --- a/arch/nios2/include/asm/Kbuild +++ b/arch/nios2/include/asm/Kbuild | |||
@@ -13,6 +13,7 @@ generic-y += dma.h | |||
13 | generic-y += emergency-restart.h | 13 | generic-y += emergency-restart.h |
14 | generic-y += errno.h | 14 | generic-y += errno.h |
15 | generic-y += exec.h | 15 | generic-y += exec.h |
16 | generic-y += extable.h | ||
16 | generic-y += fb.h | 17 | generic-y += fb.h |
17 | generic-y += fcntl.h | 18 | generic-y += fcntl.h |
18 | generic-y += ftrace.h | 19 | generic-y += ftrace.h |
diff --git a/arch/nios2/include/asm/uaccess.h b/arch/nios2/include/asm/uaccess.h index 0ab82324c817..727bd9504899 100644 --- a/arch/nios2/include/asm/uaccess.h +++ b/arch/nios2/include/asm/uaccess.h | |||
@@ -13,33 +13,11 @@ | |||
13 | #ifndef _ASM_NIOS2_UACCESS_H | 13 | #ifndef _ASM_NIOS2_UACCESS_H |
14 | #define _ASM_NIOS2_UACCESS_H | 14 | #define _ASM_NIOS2_UACCESS_H |
15 | 15 | ||
16 | #include <linux/errno.h> | ||
17 | #include <linux/thread_info.h> | ||
18 | #include <linux/string.h> | 16 | #include <linux/string.h> |
19 | 17 | ||
20 | #include <asm/page.h> | 18 | #include <asm/page.h> |
21 | 19 | ||
22 | #define VERIFY_READ 0 | 20 | #include <asm/extable.h> |
23 | #define VERIFY_WRITE 1 | ||
24 | |||
25 | /* | ||
26 | * The exception table consists of pairs of addresses: the first is the | ||
27 | * address of an instruction that is allowed to fault, and the second is | ||
28 | * the address at which the program should continue. No registers are | ||
29 | * modified, so it is entirely up to the continuation code to figure out | ||
30 | * what to do. | ||
31 | * | ||
32 | * All the routines below use bits of fixup code that are out of line | ||
33 | * with the main instruction path. This means when everything is well, | ||
34 | * we don't even have to jump over them. Further, they do not intrude | ||
35 | * on our cache or tlb entries. | ||
36 | */ | ||
37 | struct exception_table_entry { | ||
38 | unsigned long insn; | ||
39 | unsigned long fixup; | ||
40 | }; | ||
41 | |||
42 | extern int fixup_exception(struct pt_regs *regs); | ||
43 | 21 | ||
44 | /* | 22 | /* |
45 | * Segment stuff | 23 | * Segment stuff |
@@ -95,36 +73,17 @@ static inline unsigned long __must_check clear_user(void __user *to, | |||
95 | return __clear_user(to, n); | 73 | return __clear_user(to, n); |
96 | } | 74 | } |
97 | 75 | ||
98 | extern long __copy_from_user(void *to, const void __user *from, | 76 | extern unsigned long |
99 | unsigned long n); | 77 | raw_copy_from_user(void *to, const void __user *from, unsigned long n); |
100 | extern long __copy_to_user(void __user *to, const void *from, unsigned long n); | 78 | extern unsigned long |
101 | 79 | raw_copy_to_user(void __user *to, const void *from, unsigned long n); | |
102 | static inline long copy_from_user(void *to, const void __user *from, | 80 | #define INLINE_COPY_FROM_USER |
103 | unsigned long n) | 81 | #define INLINE_COPY_TO_USER |
104 | { | ||
105 | unsigned long res = n; | ||
106 | if (access_ok(VERIFY_READ, from, n)) | ||
107 | res = __copy_from_user(to, from, n); | ||
108 | if (unlikely(res)) | ||
109 | memset(to + (n - res), 0, res); | ||
110 | return res; | ||
111 | } | ||
112 | |||
113 | static inline long copy_to_user(void __user *to, const void *from, | ||
114 | unsigned long n) | ||
115 | { | ||
116 | if (!access_ok(VERIFY_WRITE, to, n)) | ||
117 | return n; | ||
118 | return __copy_to_user(to, from, n); | ||
119 | } | ||
120 | 82 | ||
121 | extern long strncpy_from_user(char *__to, const char __user *__from, | 83 | extern long strncpy_from_user(char *__to, const char __user *__from, |
122 | long __len); | 84 | long __len); |
123 | extern long strnlen_user(const char __user *s, long n); | 85 | extern long strnlen_user(const char __user *s, long n); |
124 | 86 | ||
125 | #define __copy_from_user_inatomic __copy_from_user | ||
126 | #define __copy_to_user_inatomic __copy_to_user | ||
127 | |||
128 | /* Optimized macros */ | 87 | /* Optimized macros */ |
129 | #define __get_user_asm(val, insn, addr, err) \ | 88 | #define __get_user_asm(val, insn, addr, err) \ |
130 | { \ | 89 | { \ |
diff --git a/arch/nios2/mm/uaccess.c b/arch/nios2/mm/uaccess.c index 7663e156ff4f..804983317766 100644 --- a/arch/nios2/mm/uaccess.c +++ b/arch/nios2/mm/uaccess.c | |||
@@ -10,9 +10,9 @@ | |||
10 | #include <linux/export.h> | 10 | #include <linux/export.h> |
11 | #include <linux/uaccess.h> | 11 | #include <linux/uaccess.h> |
12 | 12 | ||
13 | asm(".global __copy_from_user\n" | 13 | asm(".global raw_copy_from_user\n" |
14 | " .type __copy_from_user, @function\n" | 14 | " .type raw_copy_from_user, @function\n" |
15 | "__copy_from_user:\n" | 15 | "raw_copy_from_user:\n" |
16 | " movi r2,7\n" | 16 | " movi r2,7\n" |
17 | " mov r3,r4\n" | 17 | " mov r3,r4\n" |
18 | " bge r2,r6,1f\n" | 18 | " bge r2,r6,1f\n" |
@@ -65,12 +65,12 @@ asm(".global __copy_from_user\n" | |||
65 | ".word 7b,13b\n" | 65 | ".word 7b,13b\n" |
66 | ".previous\n" | 66 | ".previous\n" |
67 | ); | 67 | ); |
68 | EXPORT_SYMBOL(__copy_from_user); | 68 | EXPORT_SYMBOL(raw_copy_from_user); |
69 | 69 | ||
70 | asm( | 70 | asm( |
71 | " .global __copy_to_user\n" | 71 | " .global raw_copy_to_user\n" |
72 | " .type __copy_to_user, @function\n" | 72 | " .type raw_copy_to_user, @function\n" |
73 | "__copy_to_user:\n" | 73 | "raw_copy_to_user:\n" |
74 | " movi r2,7\n" | 74 | " movi r2,7\n" |
75 | " mov r3,r4\n" | 75 | " mov r3,r4\n" |
76 | " bge r2,r6,1f\n" | 76 | " bge r2,r6,1f\n" |
@@ -127,7 +127,7 @@ asm( | |||
127 | ".word 11b,13b\n" | 127 | ".word 11b,13b\n" |
128 | ".word 12b,13b\n" | 128 | ".word 12b,13b\n" |
129 | ".previous\n"); | 129 | ".previous\n"); |
130 | EXPORT_SYMBOL(__copy_to_user); | 130 | EXPORT_SYMBOL(raw_copy_to_user); |
131 | 131 | ||
132 | long strncpy_from_user(char *__to, const char __user *__from, long __len) | 132 | long strncpy_from_user(char *__to, const char __user *__from, long __len) |
133 | { | 133 | { |