]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/compat.c
[PATCH] s390: segment operation error codes
[linux-2.6-omap-h63xx.git] / fs / compat.c
index 5333c7d7427f6feeee2d72678893cde41294a3f4..2e32bd3404748d94aed3fef0e053d822c69d0ef1 100644 (file)
@@ -114,6 +114,7 @@ asmlinkage long compat_sys_newlstat(char __user * filename,
        return error;
 }
 
+#ifndef __ARCH_WANT_STAT64
 asmlinkage long compat_sys_newfstatat(unsigned int dfd, char __user *filename,
                struct compat_stat __user *statbuf, int flag)
 {
@@ -134,6 +135,7 @@ asmlinkage long compat_sys_newfstatat(unsigned int dfd, char __user *filename,
 out:
        return error;
 }
+#endif
 
 asmlinkage long compat_sys_newfstat(unsigned int fd,
                struct compat_stat __user * statbuf)
@@ -1215,6 +1217,10 @@ static ssize_t compat_do_readv_writev(int type, struct file *file,
        if (ret < 0)
                goto out;
 
+       ret = security_file_permission(file, type == READ ? MAY_READ:MAY_WRITE);
+       if (ret)
+               goto out;
+
        fnv = NULL;
        if (type == READ) {
                fn = file->f_op->read;
@@ -1474,10 +1480,9 @@ int compat_do_execve(char * filename,
        int i;
 
        retval = -ENOMEM;
-       bprm = kmalloc(sizeof(*bprm), GFP_KERNEL);
+       bprm = kzalloc(sizeof(*bprm), GFP_KERNEL);
        if (!bprm)
                goto out_ret;
-       memset(bprm, 0, sizeof(*bprm));
 
        file = open_exec(filename);
        retval = PTR_ERR(file);
@@ -1638,15 +1643,6 @@ void compat_set_fd_set(unsigned long nr, compat_ulong_t __user *ufdset,
  * This is a virtual copy of sys_select from fs/select.c and probably
  * should be compared to it from time to time
  */
-static void *select_bits_alloc(int size)
-{
-       return kmalloc(6 * size, GFP_KERNEL);
-}
-
-static void select_bits_free(void *bits, int size)
-{
-       kfree(bits);
-}
 
 /*
  * We can actually return ERESTARTSYS instead of EINTR, but I'd
@@ -1685,7 +1681,7 @@ int compat_core_sys_select(int n, compat_ulong_t __user *inp,
         */
        ret = -ENOMEM;
        size = FDS_BYTES(n);
-       bits = select_bits_alloc(size);
+       bits = kmalloc(6 * size, GFP_KERNEL);
        if (!bits)
                goto out_nofds;
        fds.in      = (unsigned long *)  bits;
@@ -1719,7 +1715,7 @@ int compat_core_sys_select(int n, compat_ulong_t __user *inp,
        compat_set_fd_set(n, exp, fds.res_ex);
 
 out:
-       select_bits_free(bits, size);
+       kfree(bits);
 out_nofds:
        return ret;
 }
@@ -2168,9 +2164,12 @@ asmlinkage long compat_sys_nfsservctl(int cmd, struct compat_nfsctl_arg __user *
 
        default:
                err = -EINVAL;
-               goto done;
+               break;
        }
 
+       if (err)
+               goto done;
+
        oldfs = get_fs();
        set_fs(KERNEL_DS);
        /* The __user pointer casts are valid because of the set_fs() */