aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorHeiko Carstens <heiko.carstens@de.ibm.com>2014-01-24 06:51:27 -0500
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2014-02-21 02:50:15 -0500
commit211deca6bf413560b562d69748ebc4df5d80d65e (patch)
treef7975539a30a9460ae32aca62e16b4951a2412b0 /arch
parent4f41c2b4567dbfb7ff93e5c552b869e2865bcd9d (diff)
s390/uaccess: consistent types
The types 'size_t' and 'unsigned long' have been used randomly for the uaccess functions. This looks rather confusing. So let's change all functions to use unsigned long instead and get rid of size_t in order to have a consistent interface. The only exception is strncpy_from_user() which uses 'long' since it may return a signed value (-EFAULT). Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/s390/include/asm/uaccess.h20
-rw-r--r--arch/s390/lib/uaccess.h12
-rw-r--r--arch/s390/lib/uaccess_mvcos.c39
-rw-r--r--arch/s390/lib/uaccess_pt.c38
-rw-r--r--arch/s390/mm/maccess.c4
5 files changed, 57 insertions, 56 deletions
diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
index 49885a518e5e..2710b41eed22 100644
--- a/arch/s390/include/asm/uaccess.h
+++ b/arch/s390/include/asm/uaccess.h
@@ -111,8 +111,8 @@ int __handle_fault(unsigned long, unsigned long, int);
111 * If some data could not be copied, this function will pad the copied 111 * If some data could not be copied, this function will pad the copied
112 * data to the requested size using zero bytes. 112 * data to the requested size using zero bytes.
113 */ 113 */
114size_t __must_check __copy_from_user(void *to, const void __user *from, 114unsigned long __must_check __copy_from_user(void *to, const void __user *from,
115 size_t n); 115 unsigned long n);
116 116
117/** 117/**
118 * __copy_to_user: - Copy a block of data into user space, with less checking. 118 * __copy_to_user: - Copy a block of data into user space, with less checking.
@@ -134,13 +134,13 @@ unsigned long __must_check __copy_to_user(void __user *to, const void *from,
134#define __copy_to_user_inatomic __copy_to_user 134#define __copy_to_user_inatomic __copy_to_user
135#define __copy_from_user_inatomic __copy_from_user 135#define __copy_from_user_inatomic __copy_from_user
136 136
137static inline int __put_user_fn(void *x, void __user *ptr, size_t size) 137static inline int __put_user_fn(void *x, void __user *ptr, unsigned long size)
138{ 138{
139 size = __copy_to_user(ptr, x, size); 139 size = __copy_to_user(ptr, x, size);
140 return size ? -EFAULT : 0; 140 return size ? -EFAULT : 0;
141} 141}
142 142
143static inline int __get_user_fn(void *x, const void __user *ptr, size_t size) 143static inline int __get_user_fn(void *x, const void __user *ptr, unsigned long size)
144{ 144{
145 size = __copy_from_user(x, ptr, size); 145 size = __copy_from_user(x, ptr, size);
146 return size ? -EFAULT : 0; 146 return size ? -EFAULT : 0;
@@ -308,9 +308,9 @@ strncpy_from_user(char *dst, const char __user *src, long count)
308 return __strncpy_from_user(dst, src, count); 308 return __strncpy_from_user(dst, src, count);
309} 309}
310 310
311size_t __must_check __strnlen_user(const char __user *src, size_t count); 311unsigned long __must_check __strnlen_user(const char __user *src, unsigned long count);
312 312
313static inline size_t strnlen_user(const char __user *src, size_t n) 313static inline unsigned long strnlen_user(const char __user *src, unsigned long n)
314{ 314{
315 might_fault(); 315 might_fault();
316 return __strnlen_user(src, n); 316 return __strnlen_user(src, n);
@@ -335,15 +335,15 @@ static inline size_t strnlen_user(const char __user *src, size_t n)
335/* 335/*
336 * Zero Userspace 336 * Zero Userspace
337 */ 337 */
338size_t __must_check __clear_user(void __user *to, size_t size); 338unsigned long __must_check __clear_user(void __user *to, unsigned long size);
339 339
340static inline size_t __must_check clear_user(void __user *to, size_t n) 340static inline unsigned long __must_check clear_user(void __user *to, unsigned long n)
341{ 341{
342 might_fault(); 342 might_fault();
343 return __clear_user(to, n); 343 return __clear_user(to, n);
344} 344}
345 345
346int copy_to_user_real(void __user *dest, void *src, size_t count); 346int copy_to_user_real(void __user *dest, void *src, unsigned long count);
347int copy_from_user_real(void *dest, void __user *src, size_t count); 347int copy_from_user_real(void *dest, void __user *src, unsigned long count);
348 348
349#endif /* __S390_UACCESS_H */ 349#endif /* __S390_UACCESS_H */
diff --git a/arch/s390/lib/uaccess.h b/arch/s390/lib/uaccess.h
index e5b9c924b733..c7e0e81f4b4e 100644
--- a/arch/s390/lib/uaccess.h
+++ b/arch/s390/lib/uaccess.h
@@ -6,11 +6,11 @@
6#ifndef __ARCH_S390_LIB_UACCESS_H 6#ifndef __ARCH_S390_LIB_UACCESS_H
7#define __ARCH_S390_LIB_UACCESS_H 7#define __ARCH_S390_LIB_UACCESS_H
8 8
9size_t copy_from_user_pt(void *to, const void __user *from, size_t n); 9unsigned long copy_from_user_pt(void *to, const void __user *from, unsigned long n);
10size_t copy_to_user_pt(void __user *to, const void *from, size_t n); 10unsigned long copy_to_user_pt(void __user *to, const void *from, unsigned long n);
11size_t copy_in_user_pt(void __user *to, const void __user *from, size_t n); 11unsigned long copy_in_user_pt(void __user *to, const void __user *from, unsigned long n);
12size_t clear_user_pt(void __user *to, size_t n); 12unsigned long clear_user_pt(void __user *to, unsigned long n);
13size_t strnlen_user_pt(const char __user *src, size_t count); 13unsigned long strnlen_user_pt(const char __user *src, unsigned long count);
14size_t strncpy_from_user_pt(char *dst, const char __user *src, size_t count); 14long strncpy_from_user_pt(char *dst, const char __user *src, long count);
15 15
16#endif /* __ARCH_S390_LIB_UACCESS_H */ 16#endif /* __ARCH_S390_LIB_UACCESS_H */
diff --git a/arch/s390/lib/uaccess_mvcos.c b/arch/s390/lib/uaccess_mvcos.c
index 66f35e15db2d..8c01f3aaf95c 100644
--- a/arch/s390/lib/uaccess_mvcos.c
+++ b/arch/s390/lib/uaccess_mvcos.c
@@ -30,8 +30,8 @@
30 30
31static struct static_key have_mvcos = STATIC_KEY_INIT_TRUE; 31static struct static_key have_mvcos = STATIC_KEY_INIT_TRUE;
32 32
33static inline size_t copy_from_user_mvcos(void *x, const void __user *ptr, 33static inline unsigned long copy_from_user_mvcos(void *x, const void __user *ptr,
34 size_t size) 34 unsigned long size)
35{ 35{
36 register unsigned long reg0 asm("0") = 0x81UL; 36 register unsigned long reg0 asm("0") = 0x81UL;
37 unsigned long tmp1, tmp2; 37 unsigned long tmp1, tmp2;
@@ -70,7 +70,7 @@ static inline size_t copy_from_user_mvcos(void *x, const void __user *ptr,
70 return size; 70 return size;
71} 71}
72 72
73size_t __copy_from_user(void *to, const void __user *from, size_t n) 73unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
74{ 74{
75 if (static_key_true(&have_mvcos)) 75 if (static_key_true(&have_mvcos))
76 return copy_from_user_mvcos(to, from, n); 76 return copy_from_user_mvcos(to, from, n);
@@ -78,8 +78,8 @@ size_t __copy_from_user(void *to, const void __user *from, size_t n)
78} 78}
79EXPORT_SYMBOL(__copy_from_user); 79EXPORT_SYMBOL(__copy_from_user);
80 80
81static inline size_t copy_to_user_mvcos(void __user *ptr, const void *x, 81static inline unsigned long copy_to_user_mvcos(void __user *ptr, const void *x,
82 size_t size) 82 unsigned long size)
83{ 83{
84 register unsigned long reg0 asm("0") = 0x810000UL; 84 register unsigned long reg0 asm("0") = 0x810000UL;
85 unsigned long tmp1, tmp2; 85 unsigned long tmp1, tmp2;
@@ -108,7 +108,7 @@ static inline size_t copy_to_user_mvcos(void __user *ptr, const void *x,
108 return size; 108 return size;
109} 109}
110 110
111size_t __copy_to_user(void __user *to, const void *from, size_t n) 111unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
112{ 112{
113 if (static_key_true(&have_mvcos)) 113 if (static_key_true(&have_mvcos))
114 return copy_to_user_mvcos(to, from, n); 114 return copy_to_user_mvcos(to, from, n);
@@ -116,8 +116,8 @@ size_t __copy_to_user(void __user *to, const void *from, size_t n)
116} 116}
117EXPORT_SYMBOL(__copy_to_user); 117EXPORT_SYMBOL(__copy_to_user);
118 118
119static inline size_t copy_in_user_mvcos(void __user *to, const void __user *from, 119static inline unsigned long copy_in_user_mvcos(void __user *to, const void __user *from,
120 size_t size) 120 unsigned long size)
121{ 121{
122 register unsigned long reg0 asm("0") = 0x810081UL; 122 register unsigned long reg0 asm("0") = 0x810081UL;
123 unsigned long tmp1, tmp2; 123 unsigned long tmp1, tmp2;
@@ -139,7 +139,7 @@ static inline size_t copy_in_user_mvcos(void __user *to, const void __user *from
139 return size; 139 return size;
140} 140}
141 141
142size_t __copy_in_user(void __user *to, const void __user *from, size_t n) 142unsigned long __copy_in_user(void __user *to, const void __user *from, unsigned long n)
143{ 143{
144 if (static_key_true(&have_mvcos)) 144 if (static_key_true(&have_mvcos))
145 return copy_in_user_mvcos(to, from, n); 145 return copy_in_user_mvcos(to, from, n);
@@ -147,7 +147,7 @@ size_t __copy_in_user(void __user *to, const void __user *from, size_t n)
147} 147}
148EXPORT_SYMBOL(__copy_in_user); 148EXPORT_SYMBOL(__copy_in_user);
149 149
150static inline size_t clear_user_mvcos(void __user *to, size_t size) 150static inline unsigned long clear_user_mvcos(void __user *to, unsigned long size)
151{ 151{
152 register unsigned long reg0 asm("0") = 0x810000UL; 152 register unsigned long reg0 asm("0") = 0x810000UL;
153 unsigned long tmp1, tmp2; 153 unsigned long tmp1, tmp2;
@@ -175,7 +175,7 @@ static inline size_t clear_user_mvcos(void __user *to, size_t size)
175 return size; 175 return size;
176} 176}
177 177
178size_t __clear_user(void __user *to, size_t size) 178unsigned long __clear_user(void __user *to, unsigned long size)
179{ 179{
180 if (static_key_true(&have_mvcos)) 180 if (static_key_true(&have_mvcos))
181 return clear_user_mvcos(to, size); 181 return clear_user_mvcos(to, size);
@@ -183,14 +183,15 @@ size_t __clear_user(void __user *to, size_t size)
183} 183}
184EXPORT_SYMBOL(__clear_user); 184EXPORT_SYMBOL(__clear_user);
185 185
186static inline size_t strnlen_user_mvcos(const char __user *src, size_t count) 186static inline unsigned long strnlen_user_mvcos(const char __user *src,
187 unsigned long count)
187{ 188{
188 size_t done, len, offset, len_str; 189 unsigned long done, len, offset, len_str;
189 char buf[256]; 190 char buf[256];
190 191
191 done = 0; 192 done = 0;
192 do { 193 do {
193 offset = (size_t)src & ~PAGE_MASK; 194 offset = (unsigned long)src & ~PAGE_MASK;
194 len = min(256UL, PAGE_SIZE - offset); 195 len = min(256UL, PAGE_SIZE - offset);
195 len = min(count - done, len); 196 len = min(count - done, len);
196 if (copy_from_user_mvcos(buf, src, len)) 197 if (copy_from_user_mvcos(buf, src, len))
@@ -202,7 +203,7 @@ static inline size_t strnlen_user_mvcos(const char __user *src, size_t count)
202 return done + 1; 203 return done + 1;
203} 204}
204 205
205size_t __strnlen_user(const char __user *src, size_t count) 206unsigned long __strnlen_user(const char __user *src, unsigned long count)
206{ 207{
207 if (static_key_true(&have_mvcos)) 208 if (static_key_true(&have_mvcos))
208 return strnlen_user_mvcos(src, count); 209 return strnlen_user_mvcos(src, count);
@@ -210,16 +211,16 @@ size_t __strnlen_user(const char __user *src, size_t count)
210} 211}
211EXPORT_SYMBOL(__strnlen_user); 212EXPORT_SYMBOL(__strnlen_user);
212 213
213static inline size_t strncpy_from_user_mvcos(char *dst, const char __user *src, 214static inline long strncpy_from_user_mvcos(char *dst, const char __user *src,
214 size_t count) 215 long count)
215{ 216{
216 unsigned long done, len, offset, len_str; 217 unsigned long done, len, offset, len_str;
217 218
218 if (unlikely(!count)) 219 if (unlikely(count <= 0))
219 return 0; 220 return 0;
220 done = 0; 221 done = 0;
221 do { 222 do {
222 offset = (size_t)src & ~PAGE_MASK; 223 offset = (unsigned long)src & ~PAGE_MASK;
223 len = min(count - done, PAGE_SIZE - offset); 224 len = min(count - done, PAGE_SIZE - offset);
224 if (copy_from_user_mvcos(dst, src, len)) 225 if (copy_from_user_mvcos(dst, src, len))
225 return -EFAULT; 226 return -EFAULT;
diff --git a/arch/s390/lib/uaccess_pt.c b/arch/s390/lib/uaccess_pt.c
index b49c3a440a24..8d39760bae68 100644
--- a/arch/s390/lib/uaccess_pt.c
+++ b/arch/s390/lib/uaccess_pt.c
@@ -22,7 +22,7 @@
22#define SLR "slgr" 22#define SLR "slgr"
23#endif 23#endif
24 24
25static size_t strnlen_kernel(const char __user *src, size_t count) 25static unsigned long strnlen_kernel(const char __user *src, unsigned long count)
26{ 26{
27 register unsigned long reg0 asm("0") = 0UL; 27 register unsigned long reg0 asm("0") = 0UL;
28 unsigned long tmp1, tmp2; 28 unsigned long tmp1, tmp2;
@@ -42,8 +42,8 @@ static size_t strnlen_kernel(const char __user *src, size_t count)
42 return count; 42 return count;
43} 43}
44 44
45static size_t copy_in_kernel(void __user *to, const void __user *from, 45static unsigned long copy_in_kernel(void __user *to, const void __user *from,
46 size_t count) 46 unsigned long count)
47{ 47{
48 unsigned long tmp1; 48 unsigned long tmp1;
49 49
@@ -146,8 +146,8 @@ static unsigned long follow_table(struct mm_struct *mm,
146 146
147#endif /* CONFIG_64BIT */ 147#endif /* CONFIG_64BIT */
148 148
149static __always_inline size_t __user_copy_pt(unsigned long uaddr, void *kptr, 149static inline unsigned long __user_copy_pt(unsigned long uaddr, void *kptr,
150 size_t n, int write_user) 150 unsigned long n, int write_user)
151{ 151{
152 struct mm_struct *mm = current->mm; 152 struct mm_struct *mm = current->mm;
153 unsigned long offset, done, size, kaddr; 153 unsigned long offset, done, size, kaddr;
@@ -189,8 +189,7 @@ fault:
189 * Do DAT for user address by page table walk, return kernel address. 189 * Do DAT for user address by page table walk, return kernel address.
190 * This function needs to be called with current->mm->page_table_lock held. 190 * This function needs to be called with current->mm->page_table_lock held.
191 */ 191 */
192static __always_inline unsigned long __dat_user_addr(unsigned long uaddr, 192static inline unsigned long __dat_user_addr(unsigned long uaddr, int write)
193 int write)
194{ 193{
195 struct mm_struct *mm = current->mm; 194 struct mm_struct *mm = current->mm;
196 unsigned long kaddr; 195 unsigned long kaddr;
@@ -211,9 +210,9 @@ fault:
211 return 0; 210 return 0;
212} 211}
213 212
214size_t copy_from_user_pt(void *to, const void __user *from, size_t n) 213unsigned long copy_from_user_pt(void *to, const void __user *from, unsigned long n)
215{ 214{
216 size_t rc; 215 unsigned long rc;
217 216
218 if (segment_eq(get_fs(), KERNEL_DS)) 217 if (segment_eq(get_fs(), KERNEL_DS))
219 return copy_in_kernel((void __user *) to, from, n); 218 return copy_in_kernel((void __user *) to, from, n);
@@ -223,17 +222,17 @@ size_t copy_from_user_pt(void *to, const void __user *from, size_t n)
223 return rc; 222 return rc;
224} 223}
225 224
226size_t copy_to_user_pt(void __user *to, const void *from, size_t n) 225unsigned long copy_to_user_pt(void __user *to, const void *from, unsigned long n)
227{ 226{
228 if (segment_eq(get_fs(), KERNEL_DS)) 227 if (segment_eq(get_fs(), KERNEL_DS))
229 return copy_in_kernel(to, (void __user *) from, n); 228 return copy_in_kernel(to, (void __user *) from, n);
230 return __user_copy_pt((unsigned long) to, (void *) from, n, 1); 229 return __user_copy_pt((unsigned long) to, (void *) from, n, 1);
231} 230}
232 231
233size_t clear_user_pt(void __user *to, size_t n) 232unsigned long clear_user_pt(void __user *to, unsigned long n)
234{ 233{
235 void *zpage = (void *) empty_zero_page; 234 void *zpage = (void *) empty_zero_page;
236 long done, size, ret; 235 unsigned long done, size, ret;
237 236
238 done = 0; 237 done = 0;
239 do { 238 do {
@@ -253,12 +252,12 @@ size_t clear_user_pt(void __user *to, size_t n)
253 return 0; 252 return 0;
254} 253}
255 254
256size_t strnlen_user_pt(const char __user *src, size_t count) 255unsigned long strnlen_user_pt(const char __user *src, unsigned long count)
257{ 256{
258 unsigned long uaddr = (unsigned long) src; 257 unsigned long uaddr = (unsigned long) src;
259 struct mm_struct *mm = current->mm; 258 struct mm_struct *mm = current->mm;
260 unsigned long offset, done, len, kaddr; 259 unsigned long offset, done, len, kaddr;
261 size_t len_str; 260 unsigned long len_str;
262 261
263 if (unlikely(!count)) 262 if (unlikely(!count))
264 return 0; 263 return 0;
@@ -289,15 +288,15 @@ fault:
289 goto retry; 288 goto retry;
290} 289}
291 290
292size_t strncpy_from_user_pt(char *dst, const char __user *src, size_t count) 291long strncpy_from_user_pt(char *dst, const char __user *src, long count)
293{ 292{
294 size_t done, len, offset, len_str; 293 unsigned long done, len, offset, len_str;
295 294
296 if (unlikely(!count)) 295 if (unlikely(count <= 0))
297 return 0; 296 return 0;
298 done = 0; 297 done = 0;
299 do { 298 do {
300 offset = (size_t)src & ~PAGE_MASK; 299 offset = (unsigned long)src & ~PAGE_MASK;
301 len = min(count - done, PAGE_SIZE - offset); 300 len = min(count - done, PAGE_SIZE - offset);
302 if (segment_eq(get_fs(), KERNEL_DS)) { 301 if (segment_eq(get_fs(), KERNEL_DS)) {
303 if (copy_in_kernel((void __user *) dst, src, len)) 302 if (copy_in_kernel((void __user *) dst, src, len))
@@ -314,7 +313,8 @@ size_t strncpy_from_user_pt(char *dst, const char __user *src, size_t count)
314 return done; 313 return done;
315} 314}
316 315
317size_t copy_in_user_pt(void __user *to, const void __user *from, size_t n) 316unsigned long copy_in_user_pt(void __user *to, const void __user *from,
317 unsigned long n)
318{ 318{
319 struct mm_struct *mm = current->mm; 319 struct mm_struct *mm = current->mm;
320 unsigned long offset_max, uaddr, done, size, error_code; 320 unsigned long offset_max, uaddr, done, size, error_code;
diff --git a/arch/s390/mm/maccess.c b/arch/s390/mm/maccess.c
index d1e0e0c7a7e2..efe8ad045c7b 100644
--- a/arch/s390/mm/maccess.c
+++ b/arch/s390/mm/maccess.c
@@ -128,7 +128,7 @@ void memcpy_absolute(void *dest, void *src, size_t count)
128/* 128/*
129 * Copy memory from kernel (real) to user (virtual) 129 * Copy memory from kernel (real) to user (virtual)
130 */ 130 */
131int copy_to_user_real(void __user *dest, void *src, size_t count) 131int copy_to_user_real(void __user *dest, void *src, unsigned long count)
132{ 132{
133 int offs = 0, size, rc; 133 int offs = 0, size, rc;
134 char *buf; 134 char *buf;
@@ -154,7 +154,7 @@ out:
154/* 154/*
155 * Copy memory from user (virtual) to kernel (real) 155 * Copy memory from user (virtual) to kernel (real)
156 */ 156 */
157int copy_from_user_real(void *dest, void __user *src, size_t count) 157int copy_from_user_real(void *dest, void __user *src, unsigned long count)
158{ 158{
159 int offs = 0, size, rc; 159 int offs = 0, size, rc;
160 char *buf; 160 char *buf;