diff options
author | Michal Simek <monstr@monstr.eu> | 2010-03-22 13:49:45 -0400 |
---|---|---|
committer | Michal Simek <monstr@monstr.eu> | 2010-04-01 02:38:23 -0400 |
commit | 89ae9753aef160c2f7bcecec21a7c4a6bc4c9b9b (patch) | |
tree | 5eeebd436301aa2598ba7b8db41afe52fa58cae6 /arch/microblaze | |
parent | 94804a9b3d0e62096a52fb62afcea32b899380c5 (diff) |
microblaze: uaccess: Sync strlen, strnlen, copy_to/from_user
Last sync.
Signed-off-by: Michal Simek <monstr@monstr.eu>
Diffstat (limited to 'arch/microblaze')
-rw-r--r-- | arch/microblaze/include/asm/uaccess.h | 88 |
1 files changed, 32 insertions, 56 deletions
diff --git a/arch/microblaze/include/asm/uaccess.h b/arch/microblaze/include/asm/uaccess.h index b33ab659781e..446bec29b142 100644 --- a/arch/microblaze/include/asm/uaccess.h +++ b/arch/microblaze/include/asm/uaccess.h | |||
@@ -294,40 +294,6 @@ extern long __user_bad(void); | |||
294 | 294 | ||
295 | #define put_user(x, ptr) __put_user((x), (ptr)) | 295 | #define put_user(x, ptr) __put_user((x), (ptr)) |
296 | 296 | ||
297 | static inline long strnlen_user(const char __user *src, long count) | ||
298 | { | ||
299 | return strlen(src) + 1; | ||
300 | } | ||
301 | |||
302 | #define __do_strncpy_from_user(dst, src, count, res) \ | ||
303 | do { \ | ||
304 | char *tmp; \ | ||
305 | strncpy(dst, src, count); \ | ||
306 | for (tmp = dst; *tmp && count > 0; tmp++, count--) \ | ||
307 | ; \ | ||
308 | res = (tmp - dst); \ | ||
309 | } while (0) | ||
310 | |||
311 | static inline long __strncpy_from_user(char *dst, | ||
312 | const char __user *src, long count) | ||
313 | { | ||
314 | long res; | ||
315 | __do_strncpy_from_user(dst, src, count, res); | ||
316 | return res; | ||
317 | } | ||
318 | |||
319 | static inline long strncpy_from_user(char *dst, | ||
320 | const char __user *src, long count) | ||
321 | { | ||
322 | long res = -EFAULT; | ||
323 | if (access_ok(VERIFY_READ, src, 1)) | ||
324 | __do_strncpy_from_user(dst, src, count, res); | ||
325 | return res; | ||
326 | } | ||
327 | |||
328 | extern long strncpy_from_user(char *dst, const char *src, long count); | ||
329 | extern long strnlen_user(const char *src, long count); | ||
330 | |||
331 | #else /* CONFIG_MMU */ | 297 | #else /* CONFIG_MMU */ |
332 | 298 | ||
333 | #define put_user(x, ptr) \ | 299 | #define put_user(x, ptr) \ |
@@ -335,26 +301,9 @@ extern long strnlen_user(const char *src, long count); | |||
335 | access_ok(VERIFY_WRITE, (ptr), sizeof(*(ptr))) \ | 301 | access_ok(VERIFY_WRITE, (ptr), sizeof(*(ptr))) \ |
336 | ? __put_user((x), (ptr)) : -EFAULT; \ | 302 | ? __put_user((x), (ptr)) : -EFAULT; \ |
337 | }) | 303 | }) |
338 | |||
339 | extern int __strncpy_user(char *to, const char __user *from, int len); | ||
340 | |||
341 | #define __strncpy_from_user __strncpy_user | ||
342 | |||
343 | static inline long | ||
344 | strncpy_from_user(char *dst, const char __user *src, long count) | ||
345 | { | ||
346 | if (!access_ok(VERIFY_READ, src, 1)) | ||
347 | return -EFAULT; | ||
348 | return __strncpy_from_user(dst, src, count); | ||
349 | } | ||
350 | |||
351 | extern int __strnlen_user(const char __user *sstr, int len); | ||
352 | |||
353 | #define strnlen_user(str, len) \ | ||
354 | (access_ok(VERIFY_READ, str, 1) ? __strnlen_user(str, len) : 0) | ||
355 | |||
356 | #endif /* CONFIG_MMU */ | 304 | #endif /* CONFIG_MMU */ |
357 | 305 | ||
306 | /* copy_to_from_user */ | ||
358 | #define __copy_from_user(to, from, n) \ | 307 | #define __copy_from_user(to, from, n) \ |
359 | __copy_tofrom_user((__force void __user *)(to), \ | 308 | __copy_tofrom_user((__force void __user *)(to), \ |
360 | (void __user *)(from), (n)) | 309 | (void __user *)(from), (n)) |
@@ -367,8 +316,7 @@ static inline long copy_from_user(void *to, | |||
367 | might_sleep(); | 316 | might_sleep(); |
368 | if (access_ok(VERIFY_READ, from, n)) | 317 | if (access_ok(VERIFY_READ, from, n)) |
369 | return __copy_from_user(to, from, n); | 318 | return __copy_from_user(to, from, n); |
370 | else | 319 | return n; |
371 | return n; | ||
372 | } | 320 | } |
373 | 321 | ||
374 | #define __copy_to_user(to, from, n) \ | 322 | #define __copy_to_user(to, from, n) \ |
@@ -382,8 +330,36 @@ static inline long copy_to_user(void __user *to, | |||
382 | might_sleep(); | 330 | might_sleep(); |
383 | if (access_ok(VERIFY_WRITE, to, n)) | 331 | if (access_ok(VERIFY_WRITE, to, n)) |
384 | return __copy_to_user(to, from, n); | 332 | return __copy_to_user(to, from, n); |
385 | else | 333 | return n; |
386 | return n; | 334 | } |
335 | |||
336 | /* | ||
337 | * Copy a null terminated string from userspace. | ||
338 | */ | ||
339 | extern int __strncpy_user(char *to, const char __user *from, int len); | ||
340 | |||
341 | #define __strncpy_from_user __strncpy_user | ||
342 | |||
343 | static inline long | ||
344 | strncpy_from_user(char *dst, const char __user *src, long count) | ||
345 | { | ||
346 | if (!access_ok(VERIFY_READ, src, 1)) | ||
347 | return -EFAULT; | ||
348 | return __strncpy_from_user(dst, src, count); | ||
349 | } | ||
350 | |||
351 | /* | ||
352 | * Return the size of a string (including the ending 0) | ||
353 | * | ||
354 | * Return 0 on exception, a value greater than N if too long | ||
355 | */ | ||
356 | extern int __strnlen_user(const char __user *sstr, int len); | ||
357 | |||
358 | static inline long strnlen_user(const char __user *src, long n) | ||
359 | { | ||
360 | if (!access_ok(VERIFY_READ, src, 1)) | ||
361 | return 0; | ||
362 | return __strnlen_user(src, n); | ||
387 | } | 363 | } |
388 | 364 | ||
389 | #endif /* __ASSEMBLY__ */ | 365 | #endif /* __ASSEMBLY__ */ |