lkml.org 
[lkml]   [2024]   [Apr]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/3] userfaultfd: convert to ->read_iter()
On Wed, Apr 03, 2024 at 08:02:53AM -0600, Jens Axboe wrote:
> - if (count < sizeof(msg))
> + if (iov_iter_count(to) < sizeof(msg))
> return ret ? ret : -EINVAL;
> _ret = userfaultfd_ctx_read(ctx, no_wait, &msg, inode);
> if (_ret < 0)
> return ret ? ret : _ret;
> - if (copy_to_user((__u64 __user *) buf, &msg, sizeof(msg)))
> + _ret = copy_to_iter(&msg, sizeof(msg), to);
> + if (_ret < 0)
> return ret ? ret : -EFAULT;

Take a look in uio.h - you'll see

size_t copy_to_iter(const void *addr, size_t bytes, struct iov_iter *i)

in there. See the problem?

> + fd = get_unused_fd_flags(O_RDONLY | (flags & UFFD_SHARED_FCNTL_FLAGS));
> + if (fd < 0)
> + goto err_out;

Same comment as for the previous patch.

\
 
 \ /
  Last update: 2024-05-27 16:23    [W:0.082 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site