Re: chroot(2) and bind mounts as non-root

From: Serge E. Hallyn
Date: Sat Dec 10 2011 - 00:29:22 EST


Quoting Colin Walters (walters@xxxxxxxxxx):
> if (prctl (PR_SET_SECUREBITS,
> SECBIT_NOROOT | SECBIT_NOROOT_LOCKED) < 0)
> fatal_errno ("prctl (SECBIT_NOROOT)");

Sorry, only just saw this now. Haven't taken too close a look, but a
comment and a few warnings.

First, what you are after is an explicit goal of user namespaces: to
be able to change the environment without risk of fooling privileged
setuid programs with that environment. And, thereby, to allow unprivileged
users to clone namespaces and, in new namespaces, freely muck with the
resources they own or create. However, they're not quite usable yet.

So regarding your use of securebits: You are preventing a setuid-root
program from automatically acquiring capabilities, which is a good
start. However, a setuid-root program will still execute as root (or
a setuid-mysql program as setuid-mysql). That means it will own
root (or mysql) files while it is running. That could still be
plenty dangerous. (With user namespaces, programs running as the
container root will not own files belonging to the host root as they
are different users.) Second, programs with file capabilities -a
more finegrained alternative to setuid-root - will still run with
privilege. You could prevent that by not allowing xattrs I suppose.

-serge
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/