From: Gabriel Krisman Bertazi <krisman@suse.de>
To: Pavel Begunkov <asml.silence@gmail.com>
Cc: io-uring@vger.kernel.org, Jens Axboe <axboe@kernel.dk>
Subject: Re: [PATCH for-next v2 1/1] io_uring/rsrc: disallow multi-source reg buffers
Date: Mon, 20 Feb 2023 11:53:00 -0300 [thread overview]
Message-ID: <87y1oscrsj.fsf@suse.de> (raw)
In-Reply-To: <6d973a629a321aa73c286f2d64d5375327d5c02a.1676902832.git.asml.silence@gmail.com> (Pavel Begunkov's message of "Mon, 20 Feb 2023 14:20:57 +0000")
Pavel Begunkov <asml.silence@gmail.com> writes:
> If two or more mappings go back to back to each other they can be passed
> into io_uring to be registered as a single registered buffer. That would
> even work if mappings came from different sources, e.g. it's possible to
> mix in this way anon pages and pages from shmem or hugetlb. That is not
> a problem but it'd rather be less prone if we forbid such mixing.
>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
> ---
> io_uring/rsrc.c | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/io_uring/rsrc.c b/io_uring/rsrc.c
> index a59fc02de598..70d7f94670f9 100644
> --- a/io_uring/rsrc.c
> +++ b/io_uring/rsrc.c
> @@ -1162,18 +1162,19 @@ struct page **io_pin_pages(unsigned long ubuf, unsigned long len, int *npages)
> pret = pin_user_pages(ubuf, nr_pages, FOLL_WRITE | FOLL_LONGTERM,
> pages, vmas);
> if (pret == nr_pages) {
> + struct file *file = vmas[0]->vm_file;
> +
> /* don't support file backed memory */
> for (i = 0; i < nr_pages; i++) {
> - struct vm_area_struct *vma = vmas[i];
> -
> - if (vma_is_shmem(vma))
> + if (vmas[i]->vm_file != file)
> + break;
Perhaps, return -EINVAL instead of -EOPNOTSUPP
> + if (!file)
> continue;
> - if (vma->vm_file &&
> - !is_file_hugepages(vma->vm_file)) {
> - ret = -EOPNOTSUPP;
> + if (!vma_is_shmem(vmas[i]) && !is_file_hugepages(file))
> break;
> - }
> }
> + if (i != nr_pages)
> + ret = -EOPNOTSUPP;
> *npages = nr_pages;
> } else {
> ret = pret < 0 ? pret : -EFAULT;
--
Gabriel Krisman Bertazi
next prev parent reply other threads:[~2023-02-20 14:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-20 14:20 [PATCH for-next v2 1/1] io_uring/rsrc: disallow multi-source reg buffers Pavel Begunkov
2023-02-20 14:53 ` Gabriel Krisman Bertazi [this message]
2023-02-21 16:29 ` Jens Axboe
2023-02-21 18:40 ` Pavel Begunkov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y1oscrsj.fsf@suse.de \
--to=krisman@suse.de \
--cc=asml.silence@gmail.com \
--cc=axboe@kernel.dk \
--cc=io-uring@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.