All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Pavel Begunkov <asml.silence@gmail.com>,
	Xiaoguang Wang <xiaoguang.wang@linux.alibaba.com>,
	io-uring@vger.kernel.org
Subject: Re: [PATCH] io_uring: add io_uring_enter(2) fixed file support
Date: Thu, 3 Mar 2022 20:03:09 -0700	[thread overview]
Message-ID: <feb75cbb-120e-5f85-4db7-8d6bde90b37c@kernel.dk> (raw)
In-Reply-To: <69e494cc-a199-db59-ecc0-4b430ac35bb5@gmail.com>

On 3/3/22 7:39 PM, Pavel Begunkov wrote:
> On 3/4/22 02:19, Jens Axboe wrote:
>> On 3/3/22 6:52 PM, Pavel Begunkov wrote:
>>> On 3/3/22 16:31, Jens Axboe wrote:
>>>> On 3/3/22 7:40 AM, Jens Axboe wrote:
>>>>> On 3/3/22 7:36 AM, Jens Axboe wrote:
> [...]
>>>>
>>>> diff --git a/fs/io_uring.c b/fs/io_uring.c
>>>> index ad3e0b0ab3b9..8a1f97054b71 100644
>>>> --- a/fs/io_uring.c
>>>> +++ b/fs/io_uring.c
>>> [...]
>>>>    static void *io_uring_validate_mmap_request(struct file *file,
>>>>                            loff_t pgoff, size_t sz)
>>>>    {
>>>> @@ -10191,12 +10266,23 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit,
>>>>        io_run_task_work();
>>>>          if (unlikely(flags & ~(IORING_ENTER_GETEVENTS | IORING_ENTER_SQ_WAKEUP |
>>>> -                   IORING_ENTER_SQ_WAIT | IORING_ENTER_EXT_ARG)))
>>>> +                   IORING_ENTER_SQ_WAIT | IORING_ENTER_EXT_ARG |
>>>> +                   IORING_ENTER_REGISTERED_RING)))
>>>>            return -EINVAL;
>>>>    -    f = fdget(fd);
>>>> -    if (unlikely(!f.file))
>>>> -        return -EBADF;
>>>> +    if (flags & IORING_ENTER_REGISTERED_RING) {
>>>> +        struct io_uring_task *tctx = current->io_uring;
>>>> +
>>>> +        if (fd >= IO_RINGFD_REG_MAX || !tctx)
>>>> +            return -EINVAL;
>>>> +        f.file = tctx->registered_rings[fd];
>>>
>>> btw, array_index_nospec(), possibly not only here.
>>
>> Yeah, was thinking that earlier too in fact but forgot about it. Might
>> as well, though I don't think it's strictly required as it isn't a user
>> table.
> 
> I may have missed in what cases it's used, but shouldn't it be
> in all cases when we use a user passed index for array addressing?
> e.g. to protect from pre-caching a chunk of memory computed from
> an out-of-array malevolent index
> 
> I just don't see any relevant difference from normal file tables

Indeed, I guess it's the indexing that matters, not the table itself.
I'll make the edit.

-- 
Jens Axboe


  reply	other threads:[~2022-03-04  3:03 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-03  5:28 [PATCH] io_uring: add io_uring_enter(2) fixed file support Xiaoguang Wang
2022-03-03  8:56 ` Hao Xu
2022-03-03 13:38 ` Jens Axboe
2022-03-03 14:36   ` Jens Axboe
2022-03-03 14:40     ` Jens Axboe
2022-03-03 16:31       ` Jens Axboe
2022-03-03 17:18         ` Jens Axboe
2022-03-03 20:41           ` Jens Axboe
2022-03-03 21:19             ` Jens Axboe
2022-03-04  0:07               ` Jens Axboe
2022-03-04 13:39                 ` Xiaoguang Wang
2022-03-04 13:44                   ` Jens Axboe
2022-03-04 15:16                     ` Xiaoguang Wang
2022-03-04 15:22                       ` Jens Axboe
2022-03-08  8:38                         ` Xiaoguang Wang
2022-03-08 13:10                           ` Jens Axboe
2022-03-03 22:24             ` Vito Caputo
2022-03-03 22:26               ` Jens Axboe
2022-03-04  1:49         ` Pavel Begunkov
2022-03-04  2:18           ` Jens Axboe
2022-03-04  2:28             ` Pavel Begunkov
2022-03-04  2:35               ` Pavel Begunkov
2022-03-04  2:43               ` Jens Axboe
2022-03-04  1:52         ` Pavel Begunkov
2022-03-04  2:19           ` Jens Axboe
2022-03-04  2:39             ` Pavel Begunkov
2022-03-04  3:03               ` Jens Axboe [this message]
2022-04-21 14:16     ` Hao Xu

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=feb75cbb-120e-5f85-4db7-8d6bde90b37c@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=asml.silence@gmail.com \
    --cc=io-uring@vger.kernel.org \
    --cc=xiaoguang.wang@linux.alibaba.com \
    /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.