readdir.c: get rid of the last __put_user(), drop now-useless access_ok()
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 19 Feb 2020 03:34:07 +0000 (22:34 -0500)
committerAl Viro <viro@zeniv.linux.org.uk>
Sat, 2 May 2020 00:29:54 +0000 (20:29 -0400)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/readdir.c

index 9534675880ceefb61621de197b08eb24d4cc10cd..a49f07c11cfbd09ca448ac38cb9febe0d169a143 100644 (file)
@@ -276,9 +276,6 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
        };
        int error;
 
-       if (!access_ok(dirent, count))
-               return -EFAULT;
-
        f = fdget_pos(fd);
        if (!f.file)
                return -EBADF;
@@ -362,9 +359,6 @@ int ksys_getdents64(unsigned int fd, struct linux_dirent64 __user *dirent,
        };
        int error;
 
-       if (!access_ok(dirent, count))
-               return -EFAULT;
-
        f = fdget_pos(fd);
        if (!f.file)
                return -EBADF;
@@ -377,7 +371,7 @@ int ksys_getdents64(unsigned int fd, struct linux_dirent64 __user *dirent,
                typeof(lastdirent->d_off) d_off = buf.ctx.pos;
 
                lastdirent = (void __user *) buf.current_dir - buf.prev_reclen;
-               if (__put_user(d_off, &lastdirent->d_off))
+               if (put_user(d_off, &lastdirent->d_off))
                        error = -EFAULT;
                else
                        error = count - buf.count;
@@ -537,9 +531,6 @@ COMPAT_SYSCALL_DEFINE3(getdents, unsigned int, fd,
        };
        int error;
 
-       if (!access_ok(dirent, count))
-               return -EFAULT;
-
        f = fdget_pos(fd);
        if (!f.file)
                return -EBADF;