On Fri, May 08, 2020 at 11:22:21AM +0200, Christoph Hellwig wrote:
> Fold it into the two callers.

In 5.7-rc4, it looks like __vfs_read() is called from
security/integrity/iint.c

Was that removed somewhere prior to this patch?

> 
> Signed-off-by: Christoph Hellwig <h...@lst.de>
> ---
>  fs/read_write.c    | 43 +++++++++++++++++++++----------------------
>  include/linux/fs.h |  1 -
>  2 files changed, 21 insertions(+), 23 deletions(-)
> 
> diff --git a/fs/read_write.c b/fs/read_write.c
> index 0ffbed5fd8136..f0009b506014c 100644
> --- a/fs/read_write.c
> +++ b/fs/read_write.c
> @@ -419,17 +419,6 @@ static ssize_t new_sync_read(struct file *filp, char 
> __user *buf, size_t len, lo
>       return ret;
>  }
>  
> -ssize_t __vfs_read(struct file *file, char __user *buf, size_t count,
> -                loff_t *pos)
> -{
> -     if (file->f_op->read)
> -             return file->f_op->read(file, buf, count, pos);
> -     else if (file->f_op->read_iter)
> -             return new_sync_read(file, buf, count, pos);
> -     else
> -             return -EINVAL;
> -}
> -
>  ssize_t __kernel_read(struct file *file, void *buf, size_t count, loff_t 
> *pos)
>  {
>       mm_segment_t old_fs = get_fs();
> @@ -441,7 +430,12 @@ ssize_t __kernel_read(struct file *file, void *buf, 
> size_t count, loff_t *pos)
>       if (count > MAX_RW_COUNT)
>               count =  MAX_RW_COUNT;
>       set_fs(KERNEL_DS);
> -     ret = __vfs_read(file, (void __user *)buf, count, pos);
> +     if (file->f_op->read)
> +             ret = file->f_op->read(file, (void __user *)buf, count, pos);
> +     else if (file->f_op->read_iter)
> +             ret = new_sync_read(file, (void __user *)buf, count, pos);
> +     else
> +             ret = -EINVAL;
>       set_fs(old_fs);
>       if (ret > 0) {
>               fsnotify_access(file);
> @@ -474,17 +468,22 @@ ssize_t vfs_read(struct file *file, char __user *buf, 
> size_t count, loff_t *pos)
>               return -EFAULT;
>  
>       ret = rw_verify_area(READ, file, pos, count);
> -     if (!ret) {
> -             if (count > MAX_RW_COUNT)
> -                     count =  MAX_RW_COUNT;
> -             ret = __vfs_read(file, buf, count, pos);
> -             if (ret > 0) {
> -                     fsnotify_access(file);
> -                     add_rchar(current, ret);
> -             }
> -             inc_syscr(current);
> -     }
> +     if (ret)
> +             return ret;
> +     if (count > MAX_RW_COUNT)
> +             count =  MAX_RW_COUNT;

Couldn't this clean up still happen while keeping __vfs_read()?

Ira

> +     if (file->f_op->read)
> +             ret = file->f_op->read(file, buf, count, pos);
> +     else if (file->f_op->read_iter)
> +             ret = new_sync_read(file, buf, count, pos);
> +     else
> +             ret = -EINVAL;
> +     if (ret > 0) {
> +             fsnotify_access(file);
> +             add_rchar(current, ret);
> +     }
> +     inc_syscr(current);
>       return ret;
>  }
>  
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 6441aaa25f8f2..4c10a07a36178 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -1905,7 +1905,6 @@ ssize_t rw_copy_check_uvector(int type, const struct 
> iovec __user * uvector,
>                             struct iovec *fast_pointer,
>                             struct iovec **ret_pointer);
>  
> -extern ssize_t __vfs_read(struct file *, char __user *, size_t, loff_t *);
>  extern ssize_t vfs_read(struct file *, char __user *, size_t, loff_t *);
>  extern ssize_t vfs_write(struct file *, const char __user *, size_t, loff_t 
> *);
>  extern ssize_t vfs_readv(struct file *, const struct iovec __user *,
> -- 
> 2.26.2
> 

Reply via email to