From: Mike Frysinger <vapier@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Subject: [gentoo-dev] glibc: pt_chown setuid going away by default
Date: Wed, 10 Apr 2013 01:15:52 -0400 [thread overview]
Message-ID: <201304100115.53431.vapier@gentoo.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 2329 bytes --]
tl;dr: make sure your /dev/pts is mounted correctly w/gid=5 or bad things will
happen and it's (probably) all your fault
when you run grantpt(), glibc attempts to set up your pty with correct
ownership & permissions. it does so by executing a setuid helper called
pt_chown as needed. we all know setuid==bad, so let's do something about it.
this system is a throw back to the bad old bsd pty days where you had a ton of
pre-allocated nodes in /dev/ named pty??. since the user has requested a new
pty, the system had to make sure it had correct permissions before giving it
back (it might be the default of root:root, or it might have the previous
user's settings which would be super bad). this system sucks for many
reasons.
with Linux, we have devpts mounted at /dev/pts/ which provides dynamic UNIX 98
ptys via the /dev/ptmx control node. the kernel knows that when you request a
new pty, the sane thing is to set the default uid/gid to your own process's
uid/gid. it even goes further and allows you to specify (at mount time)
default gid/permissions.
with openrc (and in baselayout-1.12, but i'm pretty sure it's been this way
for even longer), our default mount uses gid=5 (the tty group) and mode=620
(what we want). that means when a new pty is requested, the kernel
automatically sets the ownership of the new file to the process's uid and the
mounted group setting (tty), as well as setting the perms to 620.
back to glibc, when you call grantpt(), it checks the current uid/gid/mode.
if they all match what it expects (and it should with our default devpts mount
opts), it returns w/out doing any real work (like calling the setuid pt_chown
helper). that means this binary is sitting around with setuid perms for no
good reason.
i plan on updating the latest glibc to add USE=suid. in pkg_preinst and
ROOT==/, the ebuild will read /proc/mounts for a devpts line with gid=5. if
it doesn't find one, i'll have it call `die`. if the bsd pty scenario wasn't
long dead, and the devpts option didn't have gid=/mode= options, then it might
be reasonable to have it warn and do `chmod +s`. but i can't think of any
legitimate reasons for not using devpts & mounting it correctly. this is the
right answer even in the embedded world.
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next reply other threads:[~2013-04-10 5:14 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-10 5:15 Mike Frysinger [this message]
2013-04-10 16:26 ` [gentoo-dev] glibc: pt_chown setuid going away by default "Paweł Hajdan, Jr."
2013-04-10 18:56 ` Rich Freeman
2013-04-10 19:32 ` Mike Frysinger
2013-04-11 2:27 ` [gentoo-dev] " Duncan
2013-04-11 15:43 ` [gentoo-dev] " James Cloos
2013-04-11 16:49 ` Mike Frysinger
2013-04-12 2:19 ` [gentoo-dev] " Duncan
2013-04-12 20:05 ` Mike Frysinger
2013-04-12 19:41 ` [gentoo-dev] " James Cloos
2013-04-12 20:08 ` Mike Frysinger
2013-04-13 17:06 ` Jeroen Roovers
2013-04-14 23:02 ` James Cloos
2013-04-17 18:35 ` Mike Frysinger
2013-04-17 18:36 ` Rich Freeman
2013-04-17 20:43 ` [gentoo-dev] " Duncan
2013-04-20 6:55 ` [gentoo-dev] " Sergei Trofimovich
2013-04-12 6:50 ` Maxim Kammerer
2013-04-12 16:22 ` Mike Frysinger
2013-04-12 17:20 ` Maxim Kammerer
2013-04-12 18:54 ` Mike Gilbert
2013-04-12 19:56 ` Mike Frysinger
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=201304100115.53431.vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/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