From: Jann Horn <[email protected]>
To: Jens Axboe <[email protected]>
Cc: io-uring <[email protected]>,
Pavel Begunkov <[email protected]>
Subject: Re: [PATCH 2/2] io_uring: implement ->flush() sequence to handle ->files validity
Date: Fri, 11 Sep 2020 23:57:43 +0200 [thread overview]
Message-ID: <CAG48ez06Pm1h7CH3nYojwqnSFrHhfrn1tcFxRrpu68Da=6tCGQ@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
On Fri, Sep 11, 2020 at 11:28 PM Jens Axboe <[email protected]> wrote:
> The current scheme stashes away ->ring_fd and ->ring_file, and uses
> that to check against whether or not ->files could have changed. This
> works, but doesn't work so well for SQPOLL. If the application does
> close the ring_fd, then we require that applications enter the kernel
> to refresh our state.
I don't understand the intent; please describe the scenario this is
trying to fix. Is this something about applications that call dup()
and close() on the uring fd, or something like that?
> Add an atomic sequence for the ->flush() count on the ring fd, and if
> we get a mismatch between checking this sequence before and after
> grabbing the ->files, then we fail the request.
Is this expected to actually be possible during benign usage?
> This should offer the same protection that we currently have, with the
> added benefit of being able to update the ->files automatically.
Please clarify what "update the ->files" is about.
> Signed-off-by: Jens Axboe <[email protected]>
> ---
> fs/io_uring.c | 137 ++++++++++++++++++++++++++++++--------------------
> 1 file changed, 83 insertions(+), 54 deletions(-)
>
> diff --git a/fs/io_uring.c b/fs/io_uring.c
> index 4958a9dca51a..49be5e21f166 100644
> --- a/fs/io_uring.c
> +++ b/fs/io_uring.c
> @@ -308,8 +308,11 @@ struct io_ring_ctx {
> */
> struct fixed_file_data *file_data;
> unsigned nr_user_files;
> - int ring_fd;
> - struct file *ring_file;
> +
> + /* incremented when ->flush() is called */
> + atomic_t files_seq;
If this ends up landing, all of this should probably use 64-bit types
(atomic64_t and s64). 32-bit counters in fast syscalls can typically
be wrapped around in a reasonable amount of time. (For example, the
VMA cache sequence number wraparound issue
<https://googleprojectzero.blogspot.com/2018/09/a-cache-invalidation-bug-in-linux.html>
could be triggered in about an hour according to my blogpost from back
then. For this sequence number, it should be significantly faster, I
think.)
(I haven't properly looked at the rest of this patch so far - I stared
at it for a bit, but wasn't able to immediately figure out what's
actually going on. So I figured I'd ask the more fundamental questions
first.)
next prev parent reply other threads:[~2020-09-11 21:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-11 21:26 [PATCH 0/2 for-next] Rework ->files tracking Jens Axboe
2020-09-11 21:26 ` [PATCH 1/2] io_uring: stash ctx task reference instead of task files Jens Axboe
2020-09-11 21:26 ` [PATCH 2/2] io_uring: implement ->flush() sequence to handle ->files validity Jens Axboe
2020-09-11 21:57 ` Jann Horn [this message]
2020-09-11 22:33 ` Jens Axboe
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='CAG48ez06Pm1h7CH3nYojwqnSFrHhfrn1tcFxRrpu68Da=6tCGQ@mail.gmail.com' \
[email protected] \
[email protected] \
[email protected] \
[email protected] \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox