aboutsummaryrefslogtreecommitdiffstats
path: root/arch/blackfin/include/asm/uaccess.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/blackfin/include/asm/uaccess.h')
-rw-r--r--arch/blackfin/include/asm/uaccess.h32
1 files changed, 20 insertions, 12 deletions
diff --git a/arch/blackfin/include/asm/uaccess.h b/arch/blackfin/include/asm/uaccess.h
index 3248033531e6..8894e9ffbb57 100644
--- a/arch/blackfin/include/asm/uaccess.h
+++ b/arch/blackfin/include/asm/uaccess.h
@@ -59,12 +59,8 @@ static inline int is_in_rom(unsigned long addr)
59#ifndef CONFIG_ACCESS_CHECK 59#ifndef CONFIG_ACCESS_CHECK
60static inline int _access_ok(unsigned long addr, unsigned long size) { return 1; } 60static inline int _access_ok(unsigned long addr, unsigned long size) { return 1; }
61#else 61#else
62#ifdef CONFIG_ACCESS_OK_L1
63extern int _access_ok(unsigned long addr, unsigned long size)__attribute__((l1_text));
64#else
65extern int _access_ok(unsigned long addr, unsigned long size); 62extern int _access_ok(unsigned long addr, unsigned long size);
66#endif 63#endif
67#endif
68 64
69/* 65/*
70 * The exception table consists of pairs of addresses: the first is the 66 * The exception table consists of pairs of addresses: the first is the
@@ -83,9 +79,6 @@ struct exception_table_entry {
83 unsigned long insn, fixup; 79 unsigned long insn, fixup;
84}; 80};
85 81
86/* Returns 0 if exception not found and fixup otherwise. */
87extern unsigned long search_exception_table(unsigned long);
88
89/* 82/*
90 * These are the main single-value transfer routines. They automatically 83 * These are the main single-value transfer routines. They automatically
91 * use the right size if we just have the right pointer type. 84 * use the right size if we just have the right pointer type.
@@ -233,16 +226,29 @@ strncpy_from_user(char *dst, const char *src, long count)
233} 226}
234 227
235/* 228/*
236 * Return the size of a string (including the ending 0) 229 * Get the size of a string in user space.
230 * src: The string to measure
231 * n: The maximum valid length
237 * 232 *
238 * Return 0 on exception, a value greater than N if too long 233 * Get the size of a NUL-terminated string in user space.
234 *
235 * Returns the size of the string INCLUDING the terminating NUL.
236 * On exception, returns 0.
237 * If the string is too long, returns a value greater than n.
239 */ 238 */
240static inline long strnlen_user(const char *src, long n) 239static inline long __must_check strnlen_user(const char *src, long n)
241{ 240{
242 return (strlen(src) + 1); 241 if (!access_ok(VERIFY_READ, src, 1))
242 return 0;
243 return strnlen(src, n) + 1;
243} 244}
244 245
245#define strlen_user(str) strnlen_user(str, 32767) 246static inline long __must_check strlen_user(const char *src)
247{
248 if (!access_ok(VERIFY_READ, src, 1))
249 return 0;
250 return strlen(src) + 1;
251}
246 252
247/* 253/*
248 * Zero Userspace 254 * Zero Userspace
@@ -251,6 +257,8 @@ static inline long strnlen_user(const char *src, long n)
251static inline unsigned long __must_check 257static inline unsigned long __must_check
252__clear_user(void *to, unsigned long n) 258__clear_user(void *to, unsigned long n)
253{ 259{
260 if (!access_ok(VERIFY_WRITE, to, n))
261 return n;
254 memset(to, 0, n); 262 memset(to, 0, n);
255 return 0; 263 return 0;
256} 264}