public inbox for [email protected]
 help / color / mirror / Atom feed
From: Arnd Bergmann <[email protected]>
To: Josh Triplett <[email protected]>
Cc: [email protected],
	Linux FS-devel Mailing List <[email protected]>,
	"[email protected]" <[email protected]>,
	Michael Kerrisk <[email protected]>,
	Alexander Viro <[email protected]>,
	Jens Axboe <[email protected]>, Aleksa Sarai <[email protected]>,
	linux-man <[email protected]>,
	Linux API <[email protected]>
Subject: Re: [PATCH v5 1/3] fs: Support setting a minimum fd for "lowest available fd" allocation
Date: Thu, 23 Apr 2020 11:24:49 +0200	[thread overview]
Message-ID: <CAK8P3a09h4jhJWckxVUMYLoUp8=vAJ5NXuMTzSmghRxuk2_PTQ@mail.gmail.com> (raw)
In-Reply-To: <05c9a6725490c5a5c4ee71be73326c2fedf35ba5.1587531463.git.josh@joshtriplett.org>

On Wed, Apr 22, 2020 at 7:19 AM Josh Triplett <[email protected]> wrote:
>
> Some applications want to prevent the usual "lowest available fd"
> allocation from allocating certain file descriptors. For instance, they
> may want to prevent allocation of a closed fd 0, 1, or 2 other than via
> dup2/dup3, or reserve some low file descriptors for other purposes.
>
> Add a prctl to increase the minimum fd and return the previous minimum.
>
> System calls that allocate a specific file descriptor, such as
> dup2/dup3, ignore this minimum.
>
> exec resets the minimum fd, to prevent one program from interfering with
> another program's expectations about fd allocation.

Have you considered making this a separate system call rather than
a part of prctl()?

At the moment, there are certain classes of things controlled by prctl,
e.g. capabilities, floating point handling and timer behavior, but nothing
that relates to file descriptors as such, so it's not an obvious decision.

Another option would be prlimit(), as it already controls the maximum
file descriptor number with RLIMIT_NOFILE, and adding a minimum
there would let you set min/max atomically.

     Arnd

  parent reply	other threads:[~2020-04-23  9:25 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-22  5:19 [PATCH v5 0/3] Support userspace-selected fds Josh Triplett
2020-04-22  5:19 ` [PATCH v5 1/3] fs: Support setting a minimum fd for "lowest available fd" allocation Josh Triplett
2020-04-22  6:06   ` Michael Kerrisk (man-pages)
2020-04-23  1:12   ` Dmitry V. Levin
2020-04-23  4:51     ` Josh Triplett
2020-04-23  9:24   ` Arnd Bergmann [this message]
2020-04-22  5:20 ` [PATCH v5 2/3] fs: openat2: Extend open_how to allow userspace-selected fds Josh Triplett
2020-04-22  6:06   ` Michael Kerrisk (man-pages)
2020-04-22  7:55     ` Miklos Szeredi
2020-04-23  0:48       ` Josh Triplett
2020-04-23  4:24         ` Miklos Szeredi
2020-04-23  4:42           ` Josh Triplett
2020-04-23  6:04             ` Miklos Szeredi
2020-04-23  7:33               ` Josh Triplett
2020-04-23  7:45                 ` Miklos Szeredi
2020-04-23  7:57                   ` Miklos Szeredi
2020-04-23  9:20                     ` Miklos Szeredi
2020-04-23  9:46                       ` Miklos Szeredi
2020-04-23  8:06                   ` Josh Triplett
2020-04-22  5:20 ` [PATCH v5 3/3] fs: pipe2: Support O_SPECIFIC_FD Josh Triplett
2020-04-22  6:06   ` Michael Kerrisk (man-pages)
2020-04-22 15:44   ` Florian Weimer
2020-04-23  0:44     ` Josh Triplett
2020-04-22  6:05 ` [PATCH v5 0/3] Support userspace-selected fds Michael Kerrisk (man-pages)

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='CAK8P3a09h4jhJWckxVUMYLoUp8=vAJ5NXuMTzSmghRxuk2_PTQ@mail.gmail.com' \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [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