diff options
| author | Alexander Viro <viro@parcelfarce.linux.theplanet.co.uk> | 2004-07-24 21:12:16 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-07-24 21:12:16 -0700 |
| commit | ee886bb8780a33dbb0fd8525a592f836680f153e (patch) | |
| tree | ec6a25acd473fe35208652edeb65c6498d6254a3 | |
| parent | 94abb5160a4c39f76a1147ccd63ed6e84d635327 (diff) | |
[PATCH] sparse: simplify and tighten sparse typechecking
This takes advantage of the simplified typeof semantics of sparse
address spaces, (should be enough for alpha, i386, ppc, ppc64, sparc,
sparc64, x86_64 - most of them didn't actually need anything to be done)
and couple of missing annotations that got caught by that.
| -rw-r--r-- | arch/i386/kernel/sys_i386.c | 2 | ||||
| -rw-r--r-- | arch/ppc/kernel/syscalls.c | 2 | ||||
| -rw-r--r-- | include/asm-alpha/uaccess.h | 4 | ||||
| -rw-r--r-- | include/asm-i386/uaccess.h | 2 | ||||
| -rw-r--r-- | include/asm-ppc/uaccess.h | 12 | ||||
| -rw-r--r-- | include/asm-ppc64/uaccess.h | 2 | ||||
| -rw-r--r-- | include/asm-x86_64/uaccess.h | 2 | ||||
| -rw-r--r-- | include/linux/atmdev.h | 2 |
8 files changed, 16 insertions, 12 deletions
diff --git a/arch/i386/kernel/sys_i386.c b/arch/i386/kernel/sys_i386.c index 0c36130afb04..a4a61976ecb9 100644 --- a/arch/i386/kernel/sys_i386.c +++ b/arch/i386/kernel/sys_i386.c @@ -149,7 +149,7 @@ asmlinkage int sys_ipc (uint call, int first, int second, union semun fourth; if (!ptr) return -EINVAL; - if (get_user(fourth.__pad, (void * __user *) ptr)) + if (get_user(fourth.__pad, (void __user * __user *) ptr)) return -EFAULT; return sys_semctl (first, second, third, fourth); } diff --git a/arch/ppc/kernel/syscalls.c b/arch/ppc/kernel/syscalls.c index 7f2531d12569..994426833fbe 100644 --- a/arch/ppc/kernel/syscalls.c +++ b/arch/ppc/kernel/syscalls.c @@ -78,7 +78,7 @@ sys_ipc (uint call, int first, int second, int third, void __user *ptr, long fif if (!ptr) break; if ((ret = verify_area (VERIFY_READ, ptr, sizeof(long))) - || (ret = get_user(fourth.__pad, (void *__user *)ptr))) + || (ret = get_user(fourth.__pad, (void __user *__user *)ptr))) break; ret = sys_semctl (first, second, third, fourth); break; diff --git a/include/asm-alpha/uaccess.h b/include/asm-alpha/uaccess.h index afdb02a94aa6..c9bb9f103ca6 100644 --- a/include/asm-alpha/uaccess.h +++ b/include/asm-alpha/uaccess.h @@ -107,7 +107,7 @@ extern void __get_user_unknown(void); #define __get_user_check(x,ptr,size,segment) \ ({ \ long __gu_err = -EFAULT, __gu_val = 0; \ - const __typeof__(*(ptr)) *__gu_addr = (ptr); \ + const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ __chk_user_ptr(ptr); \ if (__access_ok((unsigned long)__gu_addr,size,segment)) { \ __gu_err = 0; \ @@ -222,7 +222,7 @@ extern void __put_user_unknown(void); #define __put_user_check(x,ptr,size,segment) \ ({ \ long __pu_err = -EFAULT; \ - __typeof__(*(ptr)) *__pu_addr = (ptr); \ + __typeof__(*(ptr)) __user *__pu_addr = (ptr); \ __chk_user_ptr(ptr); \ if (__access_ok((unsigned long)__pu_addr,size,segment)) { \ __pu_err = 0; \ diff --git a/include/asm-i386/uaccess.h b/include/asm-i386/uaccess.h index 656be13d0abd..bb202d21268f 100644 --- a/include/asm-i386/uaccess.h +++ b/include/asm-i386/uaccess.h @@ -261,7 +261,7 @@ extern void __put_user_bad(void); #define __put_user_check(x,ptr,size) \ ({ \ long __pu_err = -EFAULT; \ - __typeof__(*(ptr)) *__pu_addr = (ptr); \ + __typeof__(*(ptr)) __user *__pu_addr = (ptr); \ might_sleep(); \ if (access_ok(VERIFY_WRITE,__pu_addr,size)) \ __put_user_size((x),__pu_addr,(size),__pu_err,-EFAULT); \ diff --git a/include/asm-ppc/uaccess.h b/include/asm-ppc/uaccess.h index 0a1a1a86a1de..b9d763e0d886 100644 --- a/include/asm-ppc/uaccess.h +++ b/include/asm-ppc/uaccess.h @@ -34,7 +34,8 @@ ((addr) <= current->thread.fs.seg \ && ((size) == 0 || (size) - 1 <= current->thread.fs.seg - (addr))) -#define access_ok(type, addr, size) __access_ok((unsigned long)(addr),(size)) +#define access_ok(type, addr, size) \ + (__chk_user_ptr(addr),__access_ok((unsigned long)(addr),(size))) extern inline int verify_area(int type, const void __user * addr, unsigned long size) { @@ -105,6 +106,7 @@ extern long __put_user_bad(void); #define __put_user_nocheck(x,ptr,size) \ ({ \ long __pu_err; \ + __chk_user_ptr(ptr); \ __put_user_size((x),(ptr),(size),__pu_err); \ __pu_err; \ }) @@ -112,7 +114,7 @@ extern long __put_user_bad(void); #define __put_user_check(x,ptr,size) \ ({ \ long __pu_err = -EFAULT; \ - __typeof__(*(ptr)) *__pu_addr = (ptr); \ + __typeof__(*(ptr)) __user *__pu_addr = (ptr); \ if (access_ok(VERIFY_WRITE,__pu_addr,size)) \ __put_user_size((x),__pu_addr,(size),__pu_err); \ __pu_err; \ @@ -179,6 +181,7 @@ do { \ #define __get_user_nocheck(x, ptr, size) \ ({ \ long __gu_err, __gu_val; \ + __chk_user_ptr(ptr); \ __get_user_size(__gu_val, (ptr), (size), __gu_err); \ (x) = (__typeof__(*(ptr)))__gu_val; \ __gu_err; \ @@ -188,6 +191,7 @@ do { \ ({ \ long __gu_err; \ long long __gu_val; \ + __chk_user_ptr(ptr); \ __get_user_size64(__gu_val, (ptr), (size), __gu_err); \ (x) = (__typeof__(*(ptr)))__gu_val; \ __gu_err; \ @@ -196,7 +200,7 @@ do { \ #define __get_user_check(x, ptr, size) \ ({ \ long __gu_err = -EFAULT, __gu_val = 0; \ - const __typeof__(*(ptr)) *__gu_addr = (ptr); \ + const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ if (access_ok(VERIFY_READ, __gu_addr, (size))) \ __get_user_size(__gu_val, __gu_addr, (size), __gu_err); \ (x) = (__typeof__(*(ptr)))__gu_val; \ @@ -207,7 +211,7 @@ do { \ ({ \ long __gu_err = -EFAULT; \ long long __gu_val = 0; \ - const __typeof__(*(ptr)) *__gu_addr = (ptr); \ + const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ if (access_ok(VERIFY_READ, __gu_addr, (size))) \ __get_user_size64(__gu_val, __gu_addr, (size), __gu_err); \ (x) = (__typeof__(*(ptr)))__gu_val; \ diff --git a/include/asm-ppc64/uaccess.h b/include/asm-ppc64/uaccess.h index 4d2d6097802b..77906c9354dd 100644 --- a/include/asm-ppc64/uaccess.h +++ b/include/asm-ppc64/uaccess.h @@ -175,7 +175,7 @@ do { \ #define __get_user_check(x,ptr,size) \ ({ \ long __gu_err = -EFAULT, __gu_val = 0; \ - const __typeof__(*(ptr)) *__gu_addr = (ptr); \ + const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ if (access_ok(VERIFY_READ,__gu_addr,size)) \ __get_user_size(__gu_val,__gu_addr,(size),__gu_err,-EFAULT);\ (x) = (__typeof__(*(ptr)))__gu_val; \ diff --git a/include/asm-x86_64/uaccess.h b/include/asm-x86_64/uaccess.h index ed4dc1cca10a..ba3d49d8a888 100644 --- a/include/asm-x86_64/uaccess.h +++ b/include/asm-x86_64/uaccess.h @@ -148,7 +148,7 @@ extern void __put_user_bad(void); #define __put_user_check(x,ptr,size) \ ({ \ int __pu_err = -EFAULT; \ - __typeof__(*(ptr)) *__pu_addr = (ptr); \ + __typeof__(*(ptr)) __user *__pu_addr = (ptr); \ if (likely(access_ok(VERIFY_WRITE,__pu_addr,size))) \ __put_user_size((x),__pu_addr,(size),__pu_err); \ __pu_err; \ diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h index b19303d3fa6b..ad454dadd221 100644 --- a/include/linux/atmdev.h +++ b/include/linux/atmdev.h @@ -147,7 +147,7 @@ struct atm_dev_stats { struct atm_iobuf { int length; - void *buffer; + void __user *buffer; }; /* for ATM_GETCIRANGE / ATM_SETCIRANGE */ |
