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

From: Eric W. Biederman
Date: Mon Dec 19 2011 - 04:21:06 EST


"Serge E. Hallyn" <serge@xxxxxxxxxx> writes:

> If I understand you both right, I think what Eric said here is not relevant
> to what Colin cares about.

As long as Colin only cares about being able to be the root user I
agree. If Colin needs several uids during his build that is trickier.
But it sounds like Colin just needs to have a chroot build environment and
for that a single user sounds good enough.

Being able to use the other namespaces to get a good isolation from the
host environment is also nice and especially the pid namespace can
guarantee that processes won't escape his build environment.

> The mapping Eric is talking about here is new even to me, but I think it
> is an implementation detail referring to a proposal where each uid in the
> container maps to a real uid on the host. The only thing about that mapping
> that matters is that none of the host uids conflict with existing host
> uids (or uids mapped for other containers). Now if you want to do cool
> things like map uid 501 on the host to 1001 in the container as well as
> 502 on the host to 1010 in the container, that will be supported - and I
> think that's what Eric is referring to.
>
> But for the sake of fire-off-a-build, you can ignore that and use random
> uids on the host side of the mapping.

It is one of those worse is better implementation details but we can
discuss that more when I start posting patches in January.

I am not an immediate fan of writing random uids to disk. Uids being
persistent can be interesting to deal with if those uids are ever
reused.

Right now my implementation supports just 5 non-overlapping uid mapping
ranges. Which is enough to cover a lot of uids but still fit within one
cacheline. And I think to keep stat reasonable fast I want at to fit in
a cacheline at least for now. Oy. Hopefully it isn't too hard to find
some benchmarks to prove this out. I expect the torture case is to
time ls -l in a huge directory with a lot of files, owned by a lot of
different users.

Eric
--
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/