lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200423045112.GI161058@localhost>
Date:   Wed, 22 Apr 2020 21:51:12 -0700
From:   Josh Triplett <josh@...htriplett.org>
To:     "Dmitry V. Levin" <ldv@...linux.org>
Cc:     io-uring@...r.kernel.org, linux-fsdevel@...r.kernel.org,
        linux-kernel@...r.kernel.org, mtk.manpages@...il.com,
        Alexander Viro <viro@...iv.linux.org.uk>,
        Arnd Bergmann <arnd@...db.de>, Jens Axboe <axboe@...nel.dk>,
        Aleksa Sarai <cyphar@...har.com>, linux-man@...r.kernel.org,
        Linux API <linux-api@...r.kernel.org>
Subject: Re: [PATCH v5 1/3] fs: Support setting a minimum fd for "lowest
 available fd" allocation

On Thu, Apr 23, 2020 at 04:12:53AM +0300, Dmitry V. Levin wrote:
> On Tue, Apr 21, 2020 at 10:19:49PM -0700, Josh Triplett 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.
> 
> Please make this aspect properly documented in "Effect on process
> attributes" section of execve(2) manual page.

Done. I'll include updated manpage patches in v6.

> > +unsigned int increase_min_fd(unsigned int num)
> > +{
> > +	struct files_struct *files = current->files;
> > +	unsigned int old_min_fd;
> > +
> > +	spin_lock(&files->file_lock);
> > +	old_min_fd = files->min_fd;
> > +	files->min_fd += num;
> > +	spin_unlock(&files->file_lock);
> > +	return old_min_fd;
> > +}
>
> If it's "increase", there should be an overflow check.
> Otherwise it's "assign" rather than "increase".

I'll add a check in v6, to make sure that the value cannot overflow into
the errno range. (Note that this is not security-sensitive, it's just
providing a footgun-resistant interface. It should absolutely check,
though.)

- Josh Triplett

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ