Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

asm-generic: uaccess: fix up local access_ok() usage

There's no reason that I can see to use the short __access_ok() form
directly when the access_ok() is clearer in intent and for most people,
expands to the same C code (i.e. always specify the first field -- access
type). Not all no-mmu systems lack memory protection, so the read/write
could feasibly be checked.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

authored by

Mike Frysinger and committed by
Arnd Bergmann
a9ede5b3 9844813f

+6 -6
+6 -6
include/asm-generic/uaccess.h
··· 163 163 #define put_user(x, ptr) \ 164 164 ({ \ 165 165 might_sleep(); \ 166 - __access_ok(ptr, sizeof (*ptr)) ? \ 166 + access_ok(VERIFY_WRITE, ptr, sizeof(*ptr)) ? \ 167 167 __put_user(x, ptr) : \ 168 168 -EFAULT; \ 169 169 }) ··· 219 219 #define get_user(x, ptr) \ 220 220 ({ \ 221 221 might_sleep(); \ 222 - __access_ok(ptr, sizeof (*ptr)) ? \ 222 + access_ok(VERIFY_READ, ptr, sizeof(*ptr)) ? \ 223 223 __get_user(x, ptr) : \ 224 224 -EFAULT; \ 225 225 }) ··· 244 244 const void __user * from, unsigned long n) 245 245 { 246 246 might_sleep(); 247 - if (__access_ok(from, n)) 247 + if (access_ok(VERIFY_READ, from, n)) 248 248 return __copy_from_user(to, from, n); 249 249 else 250 250 return n; ··· 254 254 const void *from, unsigned long n) 255 255 { 256 256 might_sleep(); 257 - if (__access_ok(to, n)) 257 + if (access_ok(VERIFY_WRITE, to, n)) 258 258 return __copy_to_user(to, from, n); 259 259 else 260 260 return n; ··· 278 278 static inline long 279 279 strncpy_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 282 return -EFAULT; 283 283 return __strncpy_from_user(dst, src, count); 284 284 } ··· 318 318 clear_user(void __user *to, unsigned long n) 319 319 { 320 320 might_sleep(); 321 - if (!__access_ok(to, n)) 321 + if (!access_ok(VERIFY_WRITE, to, n)) 322 322 return n; 323 323 324 324 return __clear_user(to, n);