Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee13...
[powerpc.git] / arch / parisc / kernel / sys_parisc32.c
index d286f68..29be437 100644 (file)
@@ -9,7 +9,6 @@
  * environment. Based heavily on sys_ia32.c and sys_sparc32.c.
  */
 
-#include <linux/config.h>
 #include <linux/compat.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -112,13 +111,14 @@ struct __sysctl_args32 {
 
 asmlinkage long sys32_sysctl(struct __sysctl_args32 __user *args)
 {
+#ifndef CONFIG_SYSCTL_SYSCALL
+       return -ENOSYS;
+#else
        struct __sysctl_args32 tmp;
        int error;
        unsigned int oldlen32;
-       size_t oldlen, *oldlenp = NULL;
+       size_t oldlen, __user *oldlenp = NULL;
        unsigned long addr = (((long __force)&args->__unused[0]) + 7) & ~7;
-       extern int do_sysctl(int *name, int nlen, void *oldval, size_t *oldlenp,
-              void *newval, size_t newlen);
 
        DBG(("sysctl32(%p)\n", args));
 
@@ -145,8 +145,9 @@ asmlinkage long sys32_sysctl(struct __sysctl_args32 __user *args)
        }
 
        lock_kernel();
-       error = do_sysctl((int *)(u64)tmp.name, tmp.nlen, (void *)(u64)tmp.oldval,
-                         oldlenp, (void *)(u64)tmp.newval, tmp.newlen);
+       error = do_sysctl((int __user *)(u64)tmp.name, tmp.nlen,
+                         (void __user *)(u64)tmp.oldval, oldlenp,
+                         (void __user *)(u64)tmp.newval, tmp.newlen);
        unlock_kernel();
        if (oldlenp) {
                if (!error) {
@@ -158,10 +159,11 @@ asmlinkage long sys32_sysctl(struct __sysctl_args32 __user *args)
                                        error = -EFAULT;
                        }
                }
-               if (copy_to_user(&args->__unused[0], tmp.__unused, sizeof(tmp.__unused)))
+               if (copy_to_user(args->__unused, tmp.__unused, sizeof(tmp.__unused)))
                        error = -EFAULT;
        }
        return error;
+#endif
 }
 
 #endif /* CONFIG_SYSCTL */
@@ -238,14 +240,19 @@ int sys32_settimeofday(struct compat_timeval __user *tv, struct timezone __user
 
 int cp_compat_stat(struct kstat *stat, struct compat_stat __user *statbuf)
 {
+       compat_ino_t ino;
        int err;
 
        if (stat->size > MAX_NON_LFS || !new_valid_dev(stat->dev) ||
            !new_valid_dev(stat->rdev))
                return -EOVERFLOW;
 
+       ino = stat->ino;
+       if (sizeof(ino) < sizeof(stat->ino) && ino != stat->ino)
+               return -EOVERFLOW;
+
        err  = put_user(new_encode_dev(stat->dev), &statbuf->st_dev);
-       err |= put_user(stat->ino, &statbuf->st_ino);
+       err |= put_user(ino, &statbuf->st_ino);
        err |= put_user(stat->mode, &statbuf->st_mode);
        err |= put_user(stat->nlink, &statbuf->st_nlink);
        err |= put_user(0, &statbuf->st_reserved1);
@@ -306,23 +313,26 @@ struct readdir32_callback {
 
 #define ROUND_UP(x,a)  ((__typeof__(x))(((unsigned long)(x) + ((a) - 1)) & ~((a) - 1)))
 #define NAME_OFFSET(de) ((int) ((de)->d_name - (char __user *) (de)))
-static int
-filldir32 (void *__buf, const char *name, int namlen, loff_t offset, ino_t ino,
-          unsigned int d_type)
+static int filldir32 (void *__buf, const char *name, int namlen,
+                       loff_t offset, u64 ino, unsigned int d_type)
 {
        struct linux32_dirent __user * dirent;
        struct getdents32_callback * buf = (struct getdents32_callback *) __buf;
        int reclen = ROUND_UP(NAME_OFFSET(dirent) + namlen + 1, 4);
+       u32 d_ino;
 
        buf->error = -EINVAL;   /* only used if we fail.. */
        if (reclen > buf->count)
                return -EINVAL;
+       d_ino = ino;
+       if (sizeof(d_ino) < sizeof(ino) && d_ino != ino)
+               return -EOVERFLOW;
        dirent = buf->previous;
        if (dirent)
                put_user(offset, &dirent->d_off);
        dirent = buf->current_dir;
        buf->previous = dirent;
-       put_user(ino, &dirent->d_ino);
+       put_user(d_ino, &dirent->d_ino);
        put_user(reclen, &dirent->d_reclen);
        copy_to_user(dirent->d_name, name, namlen);
        put_user(0, dirent->d_name + namlen);
@@ -366,18 +376,21 @@ out:
        return error;
 }
 
-static int
-fillonedir32 (void * __buf, const char * name, int namlen, loff_t offset, ino_t ino,
-             unsigned int d_type)
+static int fillonedir32(void * __buf, const char * name, int namlen,
+                       loff_t offset, u64 ino, unsigned int d_type)
 {
        struct readdir32_callback * buf = (struct readdir32_callback *) __buf;
        struct old_linux32_dirent __user * dirent;
+       u32 d_ino;
 
        if (buf->count)
                return -EINVAL;
+       d_ino = ino;
+       if (sizeof(d_ino) < sizeof(ino) && d_ino != ino)
+               return -EOVERFLOW;
        buf->count++;
        dirent = buf->dirent;
-       put_user(ino, &dirent->d_ino);
+       put_user(d_ino, &dirent->d_ino);
        put_user(offset, &dirent->d_offset);
        put_user(namlen, &dirent->d_namlen);
        copy_to_user(dirent->d_name, name, namlen);