lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3634A0BA-888F-445B-84A2-D7F7C957FFA8@vmware.com>
Date:   Mon, 30 Nov 2020 19:23:07 +0000
From:   Nadav Amit <namit@...are.com>
To:     Jens Axboe <axboe@...nel.dk>
CC:     "linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
        Andrea Arcangeli <aarcange@...hat.com>,
        Peter Xu <peterx@...hat.com>,
        Alexander Viro <viro@...iv.linux.org.uk>,
        "io-uring@...r.kernel.org" <io-uring@...r.kernel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        "linux-mm@...ck.org" <linux-mm@...ck.org>
Subject: Re: [RFC PATCH 07/13] fs/userfaultfd: support read_iter to use
 io_uring

> On Nov 30, 2020, at 10:20 AM, Jens Axboe <axboe@...nel.dk> wrote:
> 
> On 11/28/20 5:45 PM, Nadav Amit wrote:
>> From: Nadav Amit <namit@...are.com>
>> 
>> iouring with userfaultfd cannot currently be used fixed buffers since
>> userfaultfd does not provide read_iter(). This is required to allow
>> asynchronous (queued) reads from userfaultfd.
>> 
>> To support async-reads of userfaultfd provide read_iter() instead of
>> read().
>> 
>> Cc: Jens Axboe <axboe@...nel.dk>
>> Cc: Andrea Arcangeli <aarcange@...hat.com>
>> Cc: Peter Xu <peterx@...hat.com>
>> Cc: Alexander Viro <viro@...iv.linux.org.uk>
>> Cc: io-uring@...r.kernel.org
>> Cc: linux-fsdevel@...r.kernel.org
>> Cc: linux-kernel@...r.kernel.org
>> Cc: linux-mm@...ck.org
>> Signed-off-by: Nadav Amit <namit@...are.com>
>> ---
>> fs/userfaultfd.c | 18 ++++++++++--------
>> 1 file changed, 10 insertions(+), 8 deletions(-)
>> 
>> diff --git a/fs/userfaultfd.c b/fs/userfaultfd.c
>> index b6a04e526025..6333b4632742 100644
>> --- a/fs/userfaultfd.c
>> +++ b/fs/userfaultfd.c
>> @@ -1195,9 +1195,9 @@ static ssize_t userfaultfd_ctx_read(struct userfaultfd_ctx *ctx, int no_wait,
>> 	return ret;
>> }
>> 
>> -static ssize_t userfaultfd_read(struct file *file, char __user *buf,
>> -				size_t count, loff_t *ppos)
>> +static ssize_t userfaultfd_read_iter(struct kiocb *iocb, struct iov_iter *to)
>> {
>> +	struct file *file = iocb->ki_filp;
>> 	struct userfaultfd_ctx *ctx = file->private_data;
>> 	ssize_t _ret, ret = 0;
>> 	struct uffd_msg msg;
>> @@ -1207,16 +1207,18 @@ static ssize_t userfaultfd_read(struct file *file, char __user *buf,
>> 		return -EINVAL;
>> 
>> 	for (;;) {
>> -		if (count < sizeof(msg))
>> +		if (iov_iter_count(to) < sizeof(msg))
>> 			return ret ? ret : -EINVAL;
>> 		_ret = userfaultfd_ctx_read(ctx, no_wait, &msg);
> 
> 'no_wait' should be changed to factor in iocb->ki_flags & IOCB_NOWAIT as well,
> not just f_flags & O_NONBLOCK.
> 
> I didn't check your write_iter, but if appropriate, that should do that
> too.

Thanks, I completely missed this point and will fix it in v1 (if I get
a positive feedback on the rest from the userfaultfd people).

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ