mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [PATCH 0/1] openpty: use TIOCGPTPEER to open slave side fd
Date: Fri, 1 Sep 2017 12:07:16 -0400	[thread overview]
Message-ID: <20170901160716.GL1627@brightrain.aerifal.cx> (raw)
In-Reply-To: <20170901160049.GK1627@brightrain.aerifal.cx>

On Fri, Sep 01, 2017 at 12:00:49PM -0400, Rich Felker wrote:
> On Fri, Sep 01, 2017 at 05:35:57PM +0200, Christian Brauner wrote:
> > Hi,
> > 
> > Newer kernels expose the ioctl TIOCGPTPEER [1] call to userspace which allows to
> > safely allocate a file descriptor for a pty slave based solely on the master
> > file descriptor. This allows us to avoid path-based operations and makes this
> > function a lot safer in the face of devpts mounts in different mount namespaces.
> > 
> > [1]: https://patchwork.kernel.org/patch/9760743/
> > 
> [....]
> Otherwise this looks like a good change, but I do wonder a bit about
> how the cases where it would help are intended to work, since the

Actually I'm also rather concerned about security of this whole kernel
patch in general.

Consider the case where a daemon running as root performs
posix_openpt, chowns the corresponding ptsname to a user and hands the
pts off to a user process, then drops from root to nobody, possibly
after chrooting itself or similar. In this scenario it should not be
able to open the user's pts, but with TIOCGPTPEER it can bypass the
filesystem permissions and open it.

I'm not sure what mischief this lets you achieve, but it seems like a
violation of an important permissions invariant...

Rich


      reply	other threads:[~2017-09-01 16:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-01 15:35 Christian Brauner
2017-09-01 15:35 ` [PATCH 1/1] " Christian Brauner
2017-09-01 16:00 ` [PATCH 0/1] " Rich Felker
2017-09-01 16:07   ` Rich Felker [this message]

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=20170901160716.GL1627@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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).