diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2016-12-27 10:29:34 -0500 |
|---|---|---|
| committer | Al Viro <viro@zeniv.linux.org.uk> | 2017-04-06 19:35:50 -0400 |
| commit | 7bb8a503e8fad51e4fb5ed2453b9e23bedd82012 (patch) | |
| tree | 9ce1fbe7a6abbb49b68cb5fbf2fd09a9f494b489 /arch/ia64 | |
| parent | 11836ecee96e8e1a62d5bd3ddd60eb9ecc01c375 (diff) | |
ia64: sanitize __access_ok()
turn into static inline, kill the 'segment' argument.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'arch/ia64')
| -rw-r--r-- | arch/ia64/include/asm/uaccess.h | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h index 24b39341f816..22c4e6d5d104 100644 --- a/arch/ia64/include/asm/uaccess.h +++ b/arch/ia64/include/asm/uaccess.h | |||
| @@ -59,14 +59,14 @@ | |||
| 59 | * address TASK_SIZE is never valid. We also need to make sure that the address doesn't | 59 | * address TASK_SIZE is never valid. We also need to make sure that the address doesn't |
| 60 | * point inside the virtually mapped linear page table. | 60 | * point inside the virtually mapped linear page table. |
| 61 | */ | 61 | */ |
| 62 | #define __access_ok(addr, size, segment) \ | 62 | static inline int __access_ok(const void __user *p, unsigned long size) |
| 63 | ({ \ | 63 | { |
| 64 | __chk_user_ptr(addr); \ | 64 | unsigned long addr = (unsigned long)p; |
| 65 | (likely((unsigned long) (addr) <= (segment).seg) \ | 65 | unsigned long seg = get_fs().seg; |
| 66 | && ((segment).seg == KERNEL_DS.seg \ | 66 | return likely(addr <= seg) && |
| 67 | || likely(REGION_OFFSET((unsigned long) (addr)) < RGN_MAP_LIMIT))); \ | 67 | (seg == KERNEL_DS.seg || likely(REGION_OFFSET(addr) < RGN_MAP_LIMIT)); |
| 68 | }) | 68 | } |
| 69 | #define access_ok(type, addr, size) __access_ok((addr), (size), get_fs()) | 69 | #define access_ok(type, addr, size) __access_ok((addr), (size)) |
| 70 | 70 | ||
| 71 | /* | 71 | /* |
| 72 | * These are the main single-value transfer routines. They automatically | 72 | * These are the main single-value transfer routines. They automatically |
| @@ -186,7 +186,7 @@ extern void __get_user_unknown (void); | |||
| 186 | __typeof__ (size) __gu_size = (size); \ | 186 | __typeof__ (size) __gu_size = (size); \ |
| 187 | long __gu_err = -EFAULT; \ | 187 | long __gu_err = -EFAULT; \ |
| 188 | unsigned long __gu_val = 0; \ | 188 | unsigned long __gu_val = 0; \ |
| 189 | if (!check || __access_ok(__gu_ptr, size, get_fs())) \ | 189 | if (!check || __access_ok(__gu_ptr, size)) \ |
| 190 | switch (__gu_size) { \ | 190 | switch (__gu_size) { \ |
| 191 | case 1: __get_user_size(__gu_val, __gu_ptr, 1, __gu_err); break; \ | 191 | case 1: __get_user_size(__gu_val, __gu_ptr, 1, __gu_err); break; \ |
| 192 | case 2: __get_user_size(__gu_val, __gu_ptr, 2, __gu_err); break; \ | 192 | case 2: __get_user_size(__gu_val, __gu_ptr, 2, __gu_err); break; \ |
| @@ -214,7 +214,7 @@ extern void __put_user_unknown (void); | |||
| 214 | __typeof__ (size) __pu_size = (size); \ | 214 | __typeof__ (size) __pu_size = (size); \ |
| 215 | long __pu_err = -EFAULT; \ | 215 | long __pu_err = -EFAULT; \ |
| 216 | \ | 216 | \ |
| 217 | if (!check || __access_ok(__pu_ptr, __pu_size, get_fs())) \ | 217 | if (!check || __access_ok(__pu_ptr, __pu_size)) \ |
| 218 | switch (__pu_size) { \ | 218 | switch (__pu_size) { \ |
| 219 | case 1: __put_user_size(__pu_x, __pu_ptr, 1, __pu_err); break; \ | 219 | case 1: __put_user_size(__pu_x, __pu_ptr, 1, __pu_err); break; \ |
| 220 | case 2: __put_user_size(__pu_x, __pu_ptr, 2, __pu_err); break; \ | 220 | case 2: __put_user_size(__pu_x, __pu_ptr, 2, __pu_err); break; \ |
| @@ -258,7 +258,7 @@ __copy_from_user (void *to, const void __user *from, unsigned long count) | |||
| 258 | const void *__cu_from = (from); \ | 258 | const void *__cu_from = (from); \ |
| 259 | long __cu_len = (n); \ | 259 | long __cu_len = (n); \ |
| 260 | \ | 260 | \ |
| 261 | if (__access_ok(__cu_to, __cu_len, get_fs())) { \ | 261 | if (__access_ok(__cu_to, __cu_len)) { \ |
| 262 | check_object_size(__cu_from, __cu_len, true); \ | 262 | check_object_size(__cu_from, __cu_len, true); \ |
| 263 | __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \ | 263 | __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \ |
| 264 | } \ | 264 | } \ |
| @@ -269,7 +269,7 @@ static inline unsigned long | |||
| 269 | copy_from_user(void *to, const void __user *from, unsigned long n) | 269 | copy_from_user(void *to, const void __user *from, unsigned long n) |
| 270 | { | 270 | { |
| 271 | check_object_size(to, n, false); | 271 | check_object_size(to, n, false); |
| 272 | if (likely(__access_ok(from, n, get_fs()))) | 272 | if (likely(__access_ok(from, n))) |
| 273 | n = __copy_user((__force void __user *) to, from, n); | 273 | n = __copy_user((__force void __user *) to, from, n); |
| 274 | else | 274 | else |
| 275 | memset(to, 0, n); | 275 | memset(to, 0, n); |
| @@ -293,7 +293,7 @@ extern unsigned long __do_clear_user (void __user *, unsigned long); | |||
| 293 | #define clear_user(to, n) \ | 293 | #define clear_user(to, n) \ |
| 294 | ({ \ | 294 | ({ \ |
| 295 | unsigned long __cu_len = (n); \ | 295 | unsigned long __cu_len = (n); \ |
| 296 | if (__access_ok(to, __cu_len, get_fs())) \ | 296 | if (__access_ok(to, __cu_len)) \ |
| 297 | __cu_len = __do_clear_user(to, __cu_len); \ | 297 | __cu_len = __do_clear_user(to, __cu_len); \ |
| 298 | __cu_len; \ | 298 | __cu_len; \ |
| 299 | }) | 299 | }) |
| @@ -309,7 +309,7 @@ extern long __must_check __strncpy_from_user (char *to, const char __user *from, | |||
| 309 | ({ \ | 309 | ({ \ |
| 310 | const char __user * __sfu_from = (from); \ | 310 | const char __user * __sfu_from = (from); \ |
| 311 | long __sfu_ret = -EFAULT; \ | 311 | long __sfu_ret = -EFAULT; \ |
| 312 | if (__access_ok(__sfu_from, 0, get_fs())) \ | 312 | if (__access_ok(__sfu_from, 0)) \ |
| 313 | __sfu_ret = __strncpy_from_user((to), __sfu_from, (n)); \ | 313 | __sfu_ret = __strncpy_from_user((to), __sfu_from, (n)); \ |
| 314 | __sfu_ret; \ | 314 | __sfu_ret; \ |
| 315 | }) | 315 | }) |
| @@ -321,7 +321,7 @@ extern unsigned long __strlen_user (const char __user *); | |||
| 321 | ({ \ | 321 | ({ \ |
| 322 | const char __user *__su_str = (str); \ | 322 | const char __user *__su_str = (str); \ |
| 323 | unsigned long __su_ret = 0; \ | 323 | unsigned long __su_ret = 0; \ |
| 324 | if (__access_ok(__su_str, 0, get_fs())) \ | 324 | if (__access_ok(__su_str, 0)) \ |
| 325 | __su_ret = __strlen_user(__su_str); \ | 325 | __su_ret = __strlen_user(__su_str); \ |
| 326 | __su_ret; \ | 326 | __su_ret; \ |
| 327 | }) | 327 | }) |
| @@ -337,7 +337,7 @@ extern unsigned long __strnlen_user (const char __user *, long); | |||
| 337 | ({ \ | 337 | ({ \ |
| 338 | const char __user *__su_str = (str); \ | 338 | const char __user *__su_str = (str); \ |
| 339 | unsigned long __su_ret = 0; \ | 339 | unsigned long __su_ret = 0; \ |
| 340 | if (__access_ok(__su_str, 0, get_fs())) \ | 340 | if (__access_ok(__su_str, 0)) \ |
| 341 | __su_ret = __strnlen_user(__su_str, len); \ | 341 | __su_ret = __strnlen_user(__su_str, len); \ |
| 342 | __su_ret; \ | 342 | __su_ret; \ |
| 343 | }) | 343 | }) |
