From: Linus Torvalds <torvalds@linux-foundation.org>
To: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Kyle Evans <self@kyle-evans.net>,
Victor Stinner <victor.stinner@gmail.com>,
Al Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
Linux API <linux-api@vger.kernel.org>,
Florian Weimer <fweimer@redhat.com>, Jann Horn <jannh@google.com>,
Oleg Nesterov <oleg@redhat.com>, Arnd Bergmann <arnd@arndb.de>,
Shuah Khan <shuah@kernel.org>,
David Howells <dhowells@redhat.com>,
"Dmitry V. Levin" <ldv@altlinux.org>
Subject: Re: [PATCH v5 0/3] close_range()
Date: Tue, 2 Jun 2020 17:08:22 -0700 [thread overview]
Message-ID: <CAHk-=wimp3tNuMcix2Z3uCF0sFfQt5GhVku=yhJAmSALucYGjg@mail.gmail.com> (raw)
In-Reply-To: <20200602233355.zdwcfow3ff4o2dol@wittgenstein>
On Tue, Jun 2, 2020 at 4:33 PM Christian Brauner
<christian.brauner@ubuntu.com> wrote:
> >
> > And maybe this _did_ get mentioned last time, and I just don't find
> > it. I also don't see anything like that in the patches, although the
> > flags argument is there.
>
> I spent some good time digging and I couldn't find this mentioned
> anywhere so maybe it just never got sent to the list?
It's entirely possible that it was just a private musing, and you
re-opening this issue just resurrected the thought.
I'm not sure how simple it would be to implement, but looking at it it
shouldn't be problematic to add a "max_fd" argument to unshare_fd()
and dup_fd().
Although the range for unsharing is obviously reversed, so I'd suggest
not trying to make "dup_fd()" take the exact range into account.
More like just making __close_range() do basically something like
rcu_read_lock();
cur_max = files_fdtable(files)->max_fds;
rcu_read_unlock();
if (flags & CLOSE_RANGE_UNSHARE) {
unsigned int max_unshare_fd = ~0u;
if (cur_max >= max_fd)
max_unshare_fd = fd;
unshare_fd(max_unsgare_fd);
}
.. do the rest of __close_range() here ..
and all that "max_unsgare_fd" would do would be to limit the top end
of the file descriptor table unsharing: we'd still do the exact range
handling in __close_range() itself.
Because teaching unshare_fd() and dup_fd() about anything more complex
than the above doesn't sound worth it, but adding a way to just avoid
the unnecessary copy of any high file descriptors sounds simple
enough.
But I haven't thought deeply about this. I might have missed something.
Linus
next prev parent reply other threads:[~2020-06-03 0:08 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-02 20:42 [PATCH v5 0/3] close_range() Christian Brauner
2020-06-02 20:42 ` [PATCH v5 1/3] open: add close_range() Christian Brauner
2020-06-02 23:30 ` Florian Weimer
2020-06-02 23:37 ` Christian Brauner
2020-06-03 10:24 ` Michael Kerrisk (man-pages)
2020-09-17 7:52 ` Michael Kerrisk (man-pages)
2020-06-05 14:55 ` Szabolcs Nagy
2020-06-06 2:54 ` Kyle Evans
2020-06-06 3:11 ` Kyle Evans
2020-06-06 11:55 ` Szabolcs Nagy
2020-06-06 14:43 ` Kyle Evans
2020-06-07 13:22 ` David Laight
2020-06-02 20:42 ` [PATCH v5 2/3] arch: wire-up close_range() Christian Brauner
2020-06-02 20:42 ` [PATCH v5 3/3] tests: add close_range() tests Christian Brauner
2020-06-02 21:03 ` [PATCH v5 0/3] close_range() Linus Torvalds
2020-06-02 23:33 ` Christian Brauner
2020-06-03 0:08 ` Linus Torvalds [this message]
2020-06-03 23:24 ` Christian Brauner
2020-06-04 0:13 ` Linus Torvalds
2020-06-04 1:15 ` Christian Brauner
2020-06-07 12:31 ` David Laight
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='CAHk-=wimp3tNuMcix2Z3uCF0sFfQt5GhVku=yhJAmSALucYGjg@mail.gmail.com' \
--to=torvalds@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=christian.brauner@ubuntu.com \
--cc=dhowells@redhat.com \
--cc=fweimer@redhat.com \
--cc=jannh@google.com \
--cc=ldv@altlinux.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=self@kyle-evans.net \
--cc=shuah@kernel.org \
--cc=victor.stinner@gmail.com \
--cc=viro@zeniv.linux.org.uk \
/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;
as well as URLs for NNTP newsgroup(s).