public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andy Lutomirski <luto@MIT.EDU>
To: Colin Walters <walters@verbum.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	morgan@kernel.org, serue@us.ibm.com, dhowells@redhat.com,
	kzak@redhat.com
Subject: Re: chroot(2) and bind mounts as non-root
Date: Wed, 07 Dec 2011 11:40:19 -0800	[thread overview]
Message-ID: <4EDFC123.6070003@mit.edu> (raw)
In-Reply-To: <1323280461.10724.13.camel@lenny>

On 12/07/2011 09:54 AM, Colin Walters wrote:
> Hi,
> 
> (TL;DR version: Please audit the attached setuid program)
> 
> I've recently been doing some work in software compilation, and it'd be
> really handy if I could call chroot(2) as a non-root user.  The reason
> to chroot is to help avoid "host contamination" - I can set up a build
> root and then chroot in.  The reason to do it as non-root is, well,
> requiring root to build software sucks for multiple obvious reasons.
> 
> (Now you can do LD_PRELOAD hacks to talk to a daemon like
> https://github.com/wrpseudo/pseudo does, but really - too gross and too
> slow).
> 
> The historical reason one can't call chroot(2) as non-root is because of
> setuid binaries (hard link a setuid binary into chroot of your choice
> with trojaned libc.so).  But it turns out a while back this commit:
> 
> commit 3898b1b4ebff8dcfbcf1807e0661585e06c9a91c
> Author: Andrew G. Morgan <morgan@kernel.org>
> Date:   Mon Apr 28 02:13:40 2008 -0700
> 
>     capabilities: implement per-process securebits
> 
> Added *exactly* what we need.  We just call:
> 
> prctl (PR_SET_SECUREBITS, SECBIT_NOROOT | SECBIT_NOROOT_LOCKED);
> 
> A setuid program to call both this and chroot(2) is *almost* good enough
> for my use case - but it's a little hard to run most build software
> without say /dev/null, /dev/urandom and /proc.
> 
> The other key thing Linux recently gained is CLONE_NEWNS - with this
> (and also SECBIT_NOROOT), we can allow users to make bind mounts to
> their heart's content, which frankly is just cool.  Bind mounts are a
> really neat VFS feature.

I will personally always be nervous until something like this happens:

http://thread.gmane.org/gmane.linux.kernel.lsm/10659

execve() is IMO scary.

--Andy

  parent reply	other threads:[~2011-12-07 19:40 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-07 17:54 chroot(2) and bind mounts as non-root Colin Walters
2011-12-07 19:36 ` John Stoffel
2011-12-08 16:10   ` Colin Walters
2011-12-08 18:14     ` John Stoffel
2011-12-08 18:26       ` Colin Walters
2011-12-09  0:49         ` Sven-Haegar Koch
2011-12-09 14:55         ` John Stoffel
2011-12-09 15:06           ` Colin Walters
2011-12-08 17:04   ` Arnd Bergmann
2011-12-08 17:15     ` Colin Walters
2011-12-07 19:40 ` Andy Lutomirski [this message]
2011-12-08 16:58   ` Colin Walters
2011-12-07 20:34 ` H. Peter Anvin
2011-12-07 20:54   ` Alan Cox
2011-12-15 18:55     ` Andrew G. Morgan
2011-12-16 15:44       ` Colin Walters
2011-12-18  1:22         ` Andrew G. Morgan
2011-12-18 15:19           ` Colin Walters
2011-12-10  5:29 ` Serge E. Hallyn
2011-12-12 16:41   ` Colin Walters
2011-12-12 23:11     ` Serge E. Hallyn
2011-12-15 20:56       ` Colin Walters
2011-12-16  6:14         ` Eric W. Biederman
2011-12-18 16:01           ` Colin Walters
2011-12-19  0:55             ` Eric W. Biederman
2011-12-19  4:06               ` Serge E. Hallyn
2011-12-19  9:22                 ` Eric W. Biederman
2011-12-20 16:49                   ` Colin Walters
2011-12-20 21:23               ` Colin Walters
2011-12-21 18:15           ` Steve Grubb
2012-01-03 23:13             ` Eric W. Biederman

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=4EDFC123.6070003@mit.edu \
    --to=luto@mit.edu \
    --cc=dhowells@redhat.com \
    --cc=kzak@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=morgan@kernel.org \
    --cc=serue@us.ibm.com \
    --cc=walters@verbum.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