aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-generic/uaccess.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/asm-generic/uaccess.h')
-rw-r--r--include/asm-generic/uaccess.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
index 6d8cab22e294..b218b8513d04 100644
--- a/include/asm-generic/uaccess.h
+++ b/include/asm-generic/uaccess.h
@@ -163,7 +163,7 @@ static inline __must_check long __copy_to_user(void __user *to,
163#define put_user(x, ptr) \ 163#define put_user(x, ptr) \
164({ \ 164({ \
165 might_sleep(); \ 165 might_sleep(); \
166 __access_ok(ptr, sizeof (*ptr)) ? \ 166 access_ok(VERIFY_WRITE, ptr, sizeof(*ptr)) ? \
167 __put_user(x, ptr) : \ 167 __put_user(x, ptr) : \
168 -EFAULT; \ 168 -EFAULT; \
169}) 169})
@@ -219,7 +219,7 @@ extern int __put_user_bad(void) __attribute__((noreturn));
219#define get_user(x, ptr) \ 219#define get_user(x, ptr) \
220({ \ 220({ \
221 might_sleep(); \ 221 might_sleep(); \
222 __access_ok(ptr, sizeof (*ptr)) ? \ 222 access_ok(VERIFY_READ, ptr, sizeof(*ptr)) ? \
223 __get_user(x, ptr) : \ 223 __get_user(x, ptr) : \
224 -EFAULT; \ 224 -EFAULT; \
225}) 225})
@@ -244,7 +244,7 @@ static inline long copy_from_user(void *to,
244 const void __user * from, unsigned long n) 244 const void __user * from, unsigned long n)
245{ 245{
246 might_sleep(); 246 might_sleep();
247 if (__access_ok(from, n)) 247 if (access_ok(VERIFY_READ, from, n))
248 return __copy_from_user(to, from, n); 248 return __copy_from_user(to, from, n);
249 else 249 else
250 return n; 250 return n;
@@ -254,7 +254,7 @@ static inline long copy_to_user(void __user *to,
254 const void *from, unsigned long n) 254 const void *from, unsigned long n)
255{ 255{
256 might_sleep(); 256 might_sleep();
257 if (__access_ok(to, n)) 257 if (access_ok(VERIFY_WRITE, to, n))
258 return __copy_to_user(to, from, n); 258 return __copy_to_user(to, from, n);
259 else 259 else
260 return n; 260 return n;
@@ -278,7 +278,7 @@ __strncpy_from_user(char *dst, const char __user *src, long count)
278static inline long 278static inline long
279strncpy_from_user(char *dst, const char __user *src, long count) 279strncpy_from_user(char *dst, const char __user *src, long count)
280{ 280{
281 if (!__access_ok(src, 1)) 281 if (!access_ok(VERIFY_READ, src, 1))
282 return -EFAULT; 282 return -EFAULT;
283 return __strncpy_from_user(dst, src, count); 283 return __strncpy_from_user(dst, src, count);
284} 284}
@@ -291,6 +291,8 @@ strncpy_from_user(char *dst, const char __user *src, long count)
291#ifndef strnlen_user 291#ifndef strnlen_user
292static inline long strnlen_user(const char __user *src, long n) 292static inline long strnlen_user(const char __user *src, long n)
293{ 293{
294 if (!access_ok(VERIFY_READ, src, 1))
295 return 0;
294 return strlen((void * __force)src) + 1; 296 return strlen((void * __force)src) + 1;
295} 297}
296#endif 298#endif
@@ -316,7 +318,7 @@ static inline __must_check unsigned long
316clear_user(void __user *to, unsigned long n) 318clear_user(void __user *to, unsigned long n)
317{ 319{
318 might_sleep(); 320 might_sleep();
319 if (!__access_ok(to, n)) 321 if (!access_ok(VERIFY_WRITE, to, n))
320 return n; 322 return n;
321 323
322 return __clear_user(to, n); 324 return __clear_user(to, n);