[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHk-=wimp3tNuMcix2Z3uCF0sFfQt5GhVku=yhJAmSALucYGjg@mail.gmail.com>
Date: Tue, 2 Jun 2020 17:08:22 -0700
From: Linus Torvalds <torvalds@...ux-foundation.org>
To: Christian Brauner <christian.brauner@...ntu.com>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Kyle Evans <self@...e-evans.net>,
Victor Stinner <victor.stinner@...il.com>,
Al Viro <viro@...iv.linux.org.uk>,
linux-fsdevel <linux-fsdevel@...r.kernel.org>,
Linux API <linux-api@...r.kernel.org>,
Florian Weimer <fweimer@...hat.com>,
Jann Horn <jannh@...gle.com>, Oleg Nesterov <oleg@...hat.com>,
Arnd Bergmann <arnd@...db.de>, Shuah Khan <shuah@...nel.org>,
David Howells <dhowells@...hat.com>,
"Dmitry V. Levin" <ldv@...linux.org>
Subject: Re: [PATCH v5 0/3] close_range()
On Tue, Jun 2, 2020 at 4:33 PM Christian Brauner
<christian.brauner@...ntu.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
Powered by blists - more mailing lists