lkml.org 
[lkml]   [2020]   [Apr]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v5 1/3] fs: Support setting a minimum fd for "lowest available fd" allocation
On Wed, Apr 22, 2020 at 7:19 AM Josh Triplett <josh@joshtriplett.org> 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

\
 
 \ /
  Last update: 2020-04-23 11:26    [W:0.109 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site